AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Table Of Contents

Feedback

[ aws . cloudformation ]

create-stack

Description

Creates a stack as specified in the template. After the call completes successfully, the stack creation starts. You can check the status of the stack via the describe-stacks API.

Synopsis

  create-stack
--stack-name <value>
[--template-body <value>]
[--template-url <value>]
[--parameters <value>]
[--disable-rollback | --no-disable-rollback]
[--timeout-in-minutes <value>]
[--notification-ar-ns <value>]
[--capabilities <value>]
[--on-failure <value>]
[--stack-policy-body <value>]
[--stack-policy-url <value>]
[--tags <value>]

Options

--stack-name (string)

The name associated with the stack. The name must be unique within your AWS account.

Note

Must contain only alphanumeric characters (case sensitive) and start with an alpha character. Maximum length of the name is 255 characters.

--template-body (string)

Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes. For more information, go to Template Anatomy in the AWS CloudFormation User Guide.

Conditional: You must specify either the --template-body or the --template-url parameter, but not both.

--template-url (string)

Location of file containing the template body. The URL must point to a template (max size: 307,200 bytes) located in an S3 bucket in the same region as the stack. For more information, go to the Template Anatomy in the AWS CloudFormation User Guide.

Conditional: You must specify either the --template-body or the --template-url parameter, but not both.

--parameters (list)

A list of Parameter structures that specify input parameters for the stack.

Shorthand Syntax:

  Key value pairs, with multiple values separated by a space.
--parameters ParameterKey=string,ParameterValue=string

JSON Syntax:

[
  {
    "ParameterKey": "string",
    "ParameterValue": "string"
  }
  ...
]

--disable-rollback | --no-disable-rollback (boolean)

Set to true to disable rollback of the stack if stack creation failed. You can specify either --disable-rollback or --on-failure , but not both.

Default: false

--timeout-in-minutes (integer)

The amount of time that can pass before the stack status becomes CREATE_FAILED; if --disable-rollback is not set or is set to false , the stack will be rolled back.

--notification-ar-ns (list)

The Simple Notification Service (SNS) topic ARNs to publish stack related events. You can find your SNS topic ARNs using the SNS console or your Command Line Interface (CLI).

Syntax:

"string" "string" ...

--capabilities (list)

The list of capabilities that you want to allow in the stack. If your template contains certain resources, you must specify the CAPABILITY_IAM value for this parameter; otherwise, this action returns an InsufficientCapabilities error. The following resources require you to specify the capabilities parameter: AWS::CloudFormation::Stack , AWS::IAM::AccessKey , AWS::IAM::Group , AWS::IAM::InstanceProfile , AWS::IAM::Policy , AWS::IAM::Role , AWS::IAM::User , and AWS::IAM::UserToGroupAddition .

Syntax:

"string" "string" ...

Where valid values are:
  CAPABILITY_IAM

--on-failure (string)

Determines what action will be taken if stack creation fails. This must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify either --on-failure or --disable-rollback , but not both.

Default: ROLLBACK

--stack-policy-body (string)

Structure containing the stack policy body. For more information, go to Prevent Updates to Stack Resources in the AWS CloudFormation User Guide. You can specify either the --stack-policy-body or the --stack-policy-url parameter, but not both.

--stack-policy-url (string)

Location of a file containing the stack policy. The URL must point to a policy (max size: 16KB) located in an S3 bucket in the same region as the stack. You can specify either the --stack-policy-body or the --stack-policy-url parameter, but not both.

--tags (list)

A set of user-defined --tags to associate with this stack, represented by key/value pairs. --tags defined for the stack are propagated to EC2 resources that are created as part of the stack. A maximum number of 10 tags can be specified.

Shorthand Syntax:

  Key value pairs, with multiple values separated by a space.
--tags Key=string,Value=string

JSON Syntax:

[
  {
    "Key": "string",
    "Value": "string"
  }
  ...
]

Examples

To create an AWS CloudFormation stack

The following create-stacks command creates a stack with the name myteststack using the sampletemplate.json template:

aws cloudformation create-stack --stack-name myteststack --template-body file:////home//local//test//sampletemplate.json

Output:

[
    {
        "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896",
        "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
        "Tags": [],
        "Outputs": [
            {
                "Description": "Name of S3 bucket to hold website content",
                "OutputKey": "BucketName",
                "OutputValue": "myteststack-s3bucket-jssofi1zie2w"
            }
        ],
        "StackStatusReason": null,
        "CreationTime": "2013-08-23T01:02:15.422Z",
        "Capabilities": [],
        "StackName": "myteststack",
        "StackStatus": "CREATE_COMPLETE",
        "DisableRollback": false
    }
]

For more information, see Stacks in the AWS CloudFormation User Guide.

Output

StackId -> (string)

Unique identifier of the stack.