运行AWS SAM Local时如何指定模板参数? [英] How do I specify template parameters when running AWS SAM Local?
问题描述
使用 AWS SAM本地,我可以在本地测试我的无服务器应用程序,这很棒。
Using AWS SAM Local I can test my serverless application locally, which is awesome.
我也可以部署到AWS ,它显然带有与 aws cloudformation deploy
相同的标志,因此我可以使用例如应用程序机密(API密钥等)。
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).
但是,我在 aws local start-api --help $中找不到任何内容c $ c>或Github上的文档中,有关在本地测试时如何使用参数文件。
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.
如何在以下情况下指向要与模板一起使用的参数文件正在运行 sam本地启动api
?
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.
从 sam本地start-api-帮助
:
--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'
这篇关于运行AWS SAM Local时如何指定模板参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!