Using AWS SAM Local I can test my serverless application locally, which is awesome.
I can also deploy to AWS, which apparently takes the same flags as aws cloudformation deploy
, so I can pass a parameters file with e.g. application secrets (API keys and such).
However, I can't find anything in aws local start-api --help
or in the docs on Github about how to use a parameter file when testing locally.
How do I point to a parameters file to use with my template when running sam local start-api
?
Note that a serverless application is more than just a Lambda function—it can include additional resources such as APIs, databases, and event source mappings. You can use AWS SAM to define your serverless applications.
SAM templates are a superset of Cloudformation. Any Cloudformation template can be run through SAM unchanged, and it will work. SAM supports all the types available in Cloudformation templates, so you can think of SAM as "CloudFormation++".
You can use the --parameter-overrides
switch. The syntax is quite long winded, as below:
sam local start-api --parameter-overrides ParameterKey=Key1,ParameterValue=value1 ParameterKey=Key2,ParameterValue=value2
That is, you need to specify the key and value of each pair with comma separation.
And then each pair is separated with a space.
From sam local start-api --help
:
--parameter-overrides Optional. A string that contains
CloudFormation parameter overrides encoded
as key=value pairs. Use the same format as
the AWS CLI, e.g. 'ParameterKey=KeyPairName,
ParameterValue=MyKey ParameterKey=InstanceTy
pe,ParameterValue=t1.micro'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With