I need to use the AWS Command Line Interface (CLI) to create an AWS CloudFormation stack from an AWS CloudFormation template. The template that I am using contains AWS-specific parameter types. How do I use the CLI to pass multiple values to a list parameter type?

CloudFormation template parameters include AWS-specific list parameter types that allow you to create a CloudFormation stack with multiple instances of the same type of resource, such as Amazon EC2 instance IDs or subnet IDs. When using the AWS CLI cloudformation create-stack command, you must pass parameter values for AWS-specific list parameter types as a comma-delimited string.

Add an AWS-specific list parameter type to your CloudFormation template. The AWS-specific list parameter types can be found at the end of the AWS-Specific Parameter Types section of the AWS CloudFormation User Guide. In the following CloudFormation template snippet, the parameter with the parameter key SubnetIds specifies a list parameter type that can accept multiple distinct subnet ID values:

{
    "Parameters": {
        "VPCId": {
            "Type": "String",
            "Default": "vpc-xxxxxx",
            "Description": "Select virtual private cloud ID for this deployment!"
        },
        "SubnetIds": {
            "Type": "List",
            "Description": "Select two or more subnets in different Availability Zones!"
        },
        "EC2InstanceTypeParameter": {
            "Type": "String",
            "Default": "t2.micro",
            "AllowedValues": [
                "t2.micro",
                "m1.small",
                "m1.large"
            ]
        }
    },
    "Resources": {"myEC2Instance": {
        "Type": "AWS::EC2::Instance",
        "Properties": {
            "ImageId": "ami-6869aa05",
            "InstanceType": {"Ref": "EC2InstanceTypeParameter"},
            "KeyName": "xxxxxxxxx",
            "SecurityGroupIds": ["sg-xxxxxxxx"]
        }
    }}
}

AWS CLI syntax

Important: The example AWS CLI command listed here follows the syntax for quoting strings required by the Windows command prompt. The AWS CLI can run on multiple command processors, which have different rules for quoting strings. See Quoting Strings to determine the rules for quoting strings required by the command processor that you use to run the AWS CLI.

Run the following AWS CLI command from a Windows command prompt to create a CloudFormation stack from a template that contains the parameters listed shown earlier:

aws cloudformation create-stack --stack-name $stackname --template-url $templateurl --parameters ParameterKey=SubnetIds,ParameterValue=\"subnet1,subnet2,subnet3\"

CloudFormation, AWS CLI, create-stack, AWS specific parameter types, stack, template


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-12-23