问题描述
我正在尝试通过参数将 Lambda 策略列表传递到我的 CloudFormation 脚本中,我发现了一些关于如何执行此操作的 examples,但是当我尝试拆分我的 LambdaPolicies 参数时,它给出了 ManagedPolicyArns 属性的值必须是 List of String 类型。
AWstemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description:
An AWS Lambda application that calls the Lambda API.
Parameters:
- LambdaName
- LambdaVersion
- LambdaCodeUriKey
- LambdaCodeUriBucket
- LambdaHandler
- LambdaRuntime
- LambdaTimeout
- Lambdamemory
- LambdaDescription
- LambdaPolicies
- LambdaTracing
Parameters:
LambdaName:
Description: The name of the Lambda function,this will be viewable within the AWS Management Console
Type: String
AllowedPattern: ^[-_A-Za-z-0-9][-_A-Za-z0-9 ]{1,126}[-_A-Za-z-0-9]$
ConstraintDescription: The parameter must only contain Uppercase and lowercase letters and numbers
LambdaVersion:
Description: The version number for the component
Type: String
AllowedPattern: ^[0-9]+\.[0-9]+\.[0-9]+$
ConstraintDescription: The parameter must match the following pattern for version. 10.2.3
LambdaCodeUriKey:
Description: The path to the Lambda code within the S3 bucket
Type: String
LambdaCodeUriBucket:
Description: The name of the S3 bucket containing the Lambda code
Type: String
Default: 'default-s3-bucket'
LambdaHandler:
Description: The name for the Lambda handler which triggers the function
Type: String
Default: 'Handler::Handler.Bootstrap::ExecuteFunction'
LambdaRuntime:
Description: The name for the Lambda runtime
Type: String
Default: 'dotnetcore3.1'
LambdaTimeout:
Description: The timeout to be assigned to the Lambda function in seconds
Type: Number
Default: 30
Lambdamemory:
Description: The memory to be assigned to the Lambda function in MB
Type: Number
Default: 512
LambdaPolicies:
Description: A comma delimited list of Lambda policies to be assigned to the function
Type: String
Default: "AWSLambdaBasicExecutionRole,AWSLambda_ReadOnlyAccess,AWSXraywriteonlyAccess"
Resources:
function:
Type: AWS::Serverless::Function
Properties:
Handler: Handler::Handler.Bootstrap::ExecuteFunction
Runtime: dotnetcore3.1
CodeUri:
Bucket: !Ref LambdaCodeUriBucket
Key: !Ref LambdaCodeUriKey
Description: Call the AWS Lambda API
Timeout: 30
MemorySize: 512
# Function's execution role
Policies: !Split [',',!Ref LambdaPolicies]
Tracing: Active
以下是我尝试通过参数创建的示例
Policies:
- AWSLambdaBasicExecutionRole
- AWSLambda_ReadOnlyAccess
- AWSXraywriteonlyAccess
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)