Search code examples
amazon-web-servicesaws-cloudformationaws-sam-cli

AWS Cloudformation Template Parameters for SAM Local


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.


Solution

  • After fiddling around a bit this looks possible. You need to define a root level Parameters as you would for a normal cloudformation template. Hence here is what mine looks like:

    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