由于我是无数堆栈的新手,因此我试图创建一个用于部署的yml文件(NodeJS lambda函数)。但是我在部署时会发现语法错误。
请在下面的serverless.yml中找到
service: secretManager
provider:
name: aws
runtime: nodejs10.x
timeout: 300
memorySize: 512
region: us-east-2
stage: ${opt:stage,'v1'}
role: secretManager
stackTags:
ApplicationId: ACL_9999999
Product: secretManager
Project: secretManager
functions:
getParams:
handler: getFromParamStore.getParams
role: secretManager
resources:
Resources:
secretManager:
Type: AWS::IAM::Role
Properties:
Policies:
- PolicyName: myPolicy
PolicyDocument:
Version: '2017'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- ssm:GetParameters
- ssm:GetParameter
- ssm:DescribeParameters
Resource:
- 'Fn::Join':
- ':'
- 'arn:aws:logs'
- 'log-group:/aws/lambda/*:*:*'
- 'arn:aws:ssm:*:*:parameter/*'
package:
include:
- serverless.yml
部署无服务器时抛出错误。
错误:CloudFormation模板无效:模板错误:每个Fn :: Join对象都需要两个参数,(1)字符串定界符和(2)要连接的字符串列表或返回字符串列表的函数(例如Fn :: GetAZs)。
请帮助
答案 0 :(得分:0)
正确使用\d
的方法是:
Fn::Join
第一个参数resources:
Resources:
secretManagerLambdaRole:
Type: AWS::IAM::Role
Properties:
Policies:
- PolicyName: myPolicy
PolicyDocument:
Version: '2017'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- ssm:GetParameters
- ssm:GetParameter
- ssm:DescribeParameters
Resource:
- 'Fn::Join':
- ':' # delimiter
- - 'arn:aws:logs'
- 'log-group:/aws/lambda/*:*:*'
- 'arn:aws:ssm:*:*:parameter/*'
是分隔符,第二个参数是要连接的字符串的列表。