【发布时间】:2018-08-10 01:40:05
【问题描述】:
在 SAM Local 的template.yaml 中,是否可以定义一组参数,使其成为 Cloudformation 参数?
我想要这个的原因是我想创建一个Launch Stack Url,允许用户提供 Cloudformation 参数值。
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-sam-cli
在 SAM Local 的template.yaml 中,是否可以定义一组参数,使其成为 Cloudformation 参数?
我想要这个的原因是我想创建一个Launch Stack Url,允许用户提供 Cloudformation 参数值。
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-sam-cli
在摆弄了一下之后,这看起来是可能的。您需要像定义普通 cloudformation 模板一样定义根级别 Parameters。因此这是我的样子:
AWSTemplateFormatVersion: '2010-09-09'
Globals:
Function:
Timeout: 300
...
Parameters:
MyUserParameter:
Type: String
Resources:
HelloWorldFunction:
Properties:
CodeUri: s3://blah/blah
Environment:
Variables:
FOO: bar
Events:
CatchAll:
Properties:
Method: GET
Path: /hello
Type: Api
Handler: hello-world
Runtime: go1.x
Tracing: Active
Type: AWS::Serverless::Function
Transform: AWS::Serverless-2016-10-31
【讨论】:
正如n00b所说的
你需要定义一个根级参数
但这些参数在配置中按字母顺序排序。 如果您想按照链接中的方式组织它们,则必须使用元数据:
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: Name of your parameter group
Parameters:
- Parameter
ParameterLabels:
ParameterName:
default: Complete name of your parameter with spaces if you want
【讨论】: