在serverless.yml的VPC定义中使用变量时,例如:
vpc:
securityGroupIds:
-$ { self:custom.prod_sg_a }
-$ { self:custom.prod_sg_b }
subnetIds:
-$ { self:custom.prod_subnet_a }
-$ { self:custom.prod_subnet_b }
serverless在部署中引发以下错误:
无服务器:部署失败!
无服务器错误---------------------------------------
An error occurred while provisioning your stack: LambdaFunction
- Value of property SecurityGroupIds must be of type
List of String.
得到支持 - - - - - - - - - - - - - - - - - - - - - -
文件:docs.serverless.com
错误:github.com/serverless/serverless/issues
您的环境信息-----------------------------
操作系统:darwin
节点版本:5.1.1
无服务器版本:1.6.1
应该能够使用变量(包括嵌套变量)来支持跨不同帐户(因此跨不同VPC)的部署。
我为此使用变量,但它与1.3。 您是否有确切的serverless.yml
文件?
以下是我如何执行此操作的示例。 已对其进行了修改,因此可能并不完全正确,但应该为您提供一个起点。
custom:
vpc:
securityGroupIds: ${self:custom.SecurityGroupId}
subnetIds: ${self:custom.SubnetId}
SubnetId:
- TBA
SecurityGroupId:
- TBA
functions:
test:
handler: handlers/test.handler
vpc: ${self:custom.vpc}
谢谢! 这似乎可以解决问题。 必须将变量设置为列表而不是变量列表。 或类似的东西。 感谢帮助!
编辑:忽略-我从网上某个地方复制了此配置,并且粘贴了连字符而不是破折号,导致出现了我看到的错误。
我遇到了同样的错误。 我只有一个安全组。
我都尝试过
provider:
name: aws
runtime: nodejs6.10
vpc:
securityGroupIds:
— "sg-abcdefg1"
subnetIds:
— "subnet-abcdefg1"
— "subnet-abcdefg2"
和
provider:
name: aws
runtime: nodejs6.10
vpc:
securityGroupIds: "sg-abcdefg1"
subnetIds:
— "subnet-abcdefg1"
— "subnet-abcdefg2"
这只是一件事吗?
编辑:忽略-我从网上某个地方复制了此配置,并且粘贴了连字符而不是破折号,导致出现了我看到的错误。
最有用的评论
编辑:忽略-我从网上某个地方复制了此配置,并且粘贴了连字符而不是破折号,导致出现了我看到的错误。
我遇到了同样的错误。 我只有一个安全组。
我都尝试过
和
这只是一件事吗?
编辑:忽略-我从网上某个地方复制了此配置,并且粘贴了连字符而不是破折号,导致出现了我看到的错误。