1

In SAM Local's template.yaml, is it possible to define a set of parameters such that they become Cloudformation parameters?

The reason I want this is I'd like to create a Launch Stack Url that allows the user to provide Cloudformation parameter values.

4

2 回答 2

0

在摆弄了一下之后,这看起来是可能的。您需要像定义Parameters普通 cloudformation 模板一样定义根级别。因此,这就是我的样子:

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
于 2018-08-09T05:28:59.583 回答
0

正如 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

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html

于 2018-08-09T17:40:05.560 回答