简体   繁体   中英

AWS SAM - How to pass parameters to Lambda Function

I am trying to pass Parameter values when executing sam deploy . For example:

sam package \
    --template-file lambda.yaml \
    --s3-bucket myexamplebucket \
    --output-template-file packaged.yaml

sam deploy --template-file ./packaged.yaml \
    --stack-name stack-test-lambda \
    --parameter-overrides ${lambda_param} \
    --no-fail-on-empty-changeset

However, I get: An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameters: [LambdaRoleARN] must have values.

lambda_param contains: "LambdaRoleARN"="arn:aws:iam::111111111111:role/my-lambda-role"

Do I need to pass parameters in a different way? Currently the Code Uri is just pointing to the 'lambda_example.py' file.

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Parameters:
  LambdaRoleARN:
    Type: String

Resources:
  LambdaS3EventResponse: 
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: lambda-s3-event-response
      Role: !Ref LambdaRoleARN
      Handler: lambda_example.lambda_handler
      Runtime: python3.7
      MemorySize: 128
      Timeout: 300
      CodeUri: ../../lambda/src/helpers

I got the issue. The " was not being passed correctly in Bash script. By passing the command into an array and executing as below ensured the " was correctly passed.

array=(
sam deploy --template-file ./packaged.yaml \
    --stack-name stack-test-lambda \
    --parameter-overrides ${lambda_param} \
    --no-fail-on-empty-changeset
)
eval $(echo ${array[@]})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM