如何在lambda云形成模板中添加vpcconfig部分
为了能够与Internet连接,我想使用CloudFormation模板在我的lambda中添加VPCCONFIG。 AWS提供了一个示例,说明了如何将lambda与VPC 在这里。但是我的要求有点扩展。我已经从其他模板中导出了导出部分中的子网ID和安全组ID,从那里我必须在lambda模板中导入相同的内容。首先,我在lambda模板的参数部分中添加了其密钥,然后遵循上述URL中提到的过程。
我的代码就像: 在lambda模板的参数部分中:
Parameters:
SecurityGroupId:
Description: |-
VPC security group id
Type:String
Default: 'sg-importkey'
SubnetId1:
Description: |-
Subnet id 1
Type:String
Default: 'sb1-importkey'
SubnetId2:
Description: |-
Subnet id 2
Type:String
Default: 'sb2-importkey'
然后在lambda函数的属性部分中,添加了vpCsection:
VpcConfig:
SecurityGroupIds: !ImportValue
'fn::sub': 'SecurityGroupId'
SubnetIds: !importValue
'fn::sub': 'SubnetId1'
'fn::sub': 'SubnetId2'
部署时获取错误: “属性验证因资源函数而失败,并使用消息:#/vpcconfig/securitygroupsids:预期类型:jsonarray,找到:字符串:
To be able to connect with internet, I want to add vpcconfig section in my lambda using cloudformation template. AWS has given one example of how to connect lambda with VPC here . But my requirement is little bit extended. I have exported subnet ids and security group id in export section from other template and from there i have to import the same in my lambda template. to do that first i am adding its key in parameter section of lambda template and then follow the process mentioned in mentioned url above.
My code is like :
in parameter section of lambda template :
Parameters:
SecurityGroupId:
Description: |-
VPC security group id
Type:String
Default: 'sg-importkey'
SubnetId1:
Description: |-
Subnet id 1
Type:String
Default: 'sb1-importkey'
SubnetId2:
Description: |-
Subnet id 2
Type:String
Default: 'sb2-importkey'
Then in properties section of lambda function, added following vpcsection:
VpcConfig:
SecurityGroupIds: !ImportValue
'fn::sub': 'SecurityGroupId'
SubnetIds: !importValue
'fn::sub': 'SubnetId1'
'fn::sub': 'SubnetId2'
getting error while deploying:
"Properties validation failed for resource function with message:#/VpcConfig/SecurityGroupsIds: expected type: JSONArray, found:String"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SecurityGroupsIds
必须是 list ,而不是字符串:对于
subnetids
相同。SecurityGroupsIds
must be a list, not a string:Same for
SubnetIds
.