似乎无服务器语法和 CloudFormation 语法之间存在冲突
Seems to conflict between Serverless syntax and CloudFormation syntax
以下是Serverless加载的CloudForamtion文件部分
# resource.yml
.
.
.
{"Fn::Sub": "arn:aws:sqs:*:${AWS::AccountId}:sqs-spoon-*-${env:SERVICE}"}
# serverless.yml
.
.
resources:
- ${file:resource.yml}
${AWS::AccountId}
是 CloudFormation 伪参数,${env:SERVICE}
是无服务器变量。
当我运行sls deploy
时,它returns错误。
Invalid variable reference syntax for variable AWS::AccountId. You can only reference env vars, options, & files. You can check our docs for more info.
似乎是说 Serverless 将 ${AWS::AccountId}
识别为 Serverless 变量,而不是 CloudFormation 伪参数。
对吧?
如果是这样,如何让Serverless不解析伪参数,以便稍后由CloudFormation解析?
我可以用plugin解决。
使用插件,可以通过将${AWS::AccountId}
替换为#{AWS::AccountId}
来解决。
{"Fn::Sub": "arn:aws:sqs:*:#{AWS::AccountId}:sqs-spoon-*-${env:SERVICE}"}
您可以通过 serverless.yml
中的单个配置行来定义 variableSyntax
来完成对原生 AWS 语法的支持。可以在此处找到详细信息 https://github.com/serverless/serverless/pull/3694。
provider:
name: aws
runtime: nodejs8.10
variableSyntax: "${((env|self|opt|file|cf|s3)[:\(][ :a-zA-Z0-9._,\-\/\(\)]*?)}"
以下是Serverless加载的CloudForamtion文件部分
# resource.yml
.
.
.
{"Fn::Sub": "arn:aws:sqs:*:${AWS::AccountId}:sqs-spoon-*-${env:SERVICE}"}
# serverless.yml
.
.
resources:
- ${file:resource.yml}
${AWS::AccountId}
是 CloudFormation 伪参数,${env:SERVICE}
是无服务器变量。
当我运行sls deploy
时,它returns错误。
Invalid variable reference syntax for variable AWS::AccountId. You can only reference env vars, options, & files. You can check our docs for more info.
似乎是说 Serverless 将 ${AWS::AccountId}
识别为 Serverless 变量,而不是 CloudFormation 伪参数。
对吧?
如果是这样,如何让Serverless不解析伪参数,以便稍后由CloudFormation解析?
我可以用plugin解决。
使用插件,可以通过将${AWS::AccountId}
替换为#{AWS::AccountId}
来解决。
{"Fn::Sub": "arn:aws:sqs:*:#{AWS::AccountId}:sqs-spoon-*-${env:SERVICE}"}
您可以通过 serverless.yml
中的单个配置行来定义 variableSyntax
来完成对原生 AWS 语法的支持。可以在此处找到详细信息 https://github.com/serverless/serverless/pull/3694。
provider:
name: aws
runtime: nodejs8.10
variableSyntax: "${((env|self|opt|file|cf|s3)[:\(][ :a-zA-Z0-9._,\-\/\(\)]*?)}"