【问题标题】:AWS Cloudformation Template Parameters for SAM LocalSAM Local 的 AWS Cloudformation 模板参数
【发布时间】:2018-08-10 01:40:05
【问题描述】:

在 SAM Local 的template.yaml 中,是否可以定义一组参数,使其成为 Cloudformation 参数?

我想要这个的原因是我想创建一个Launch Stack Url,允许用户提供 Cloudformation 参数值。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation aws-sam-cli


    【解决方案1】:

    在摆弄了一下之后,这看起来是可能的。您需要像定义普通 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
    

    【讨论】:

      【解决方案2】:

      正如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-22
        • 2021-07-01
        • 1970-01-01
        • 2018-10-12
        • 2022-01-16
        • 2018-08-31
        • 1970-01-01
        • 2020-03-08
        • 2018-10-14
        相关资源
        最近更新 更多