user2901044
user2901044

Reputation: 11

How to assign values to my CloudFormation template written in YAML while deploying

I have written a CloudFormation template in YAML to deploy my AWS Lambda functions. I have to deploy multiple Lambda function and I want to be able to changes the key-value pair at run-time, so that I don't have to copy the entire thing again and again to make changes before deployment.

I was reading about the set builtin of Linux, but didn't find it of much help

NameOfMyLambda:
  Type: AWS::Serverless::Function
  Properties: 
    FunctionName:  !Sub '@My_Function_Name'
    Handler: app.lambda_handler
    Runtime: python3.7
    MemorySize: 256     
    Role: !GetAtt MyExecutionRole.Arn
    CodeUri: 'path/to/my/python/file'

In the above given code, I want to be able to change the "FunctionName" and "Role" at time of deployment.

Upvotes: 1

Views: 217

Answers (1)

TheClassic
TheClassic

Reputation: 1044

Your exact use case isn't completely clear (how are you running your cloudformation?), but it sounds like you want to use CloudFormation Parameters possibly combined with Nested stacks

This would allow you to reference your cloudformation template multiple times from within an outer template, passing different parameters each time.

Upvotes: 1

Related Questions