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
?
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'