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-arns <value>]
[--capabilities <value>]
[--on-failure <value>]
[--stack-policy-body <value>]
[--stack-policy-url <value>]
[--tags <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton]

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,UsePreviousValue=boolean ParameterKey=string,ParameterValue=string,UsePreviousValue=boolean

JSON Syntax:

[
  {
    "ParameterKey": "string",
    "ParameterValue": "string",
    "UsePreviousValue": true|false
  }
  ...
]

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

Set to true to disable rollback of the stack if stack creation failed. You can specify either no-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 no-disable-rollback is not set or is set to false , the stack will be rolled back.

--notification-arns (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)

A list of capabilities that you must specify before AWS CloudFormation can create or update certain stacks. Some stack templates might include resources that can affect permissions in your AWS account. For those stacks, you must explicitly acknowledge their capabilities by specifying this parameter.

Currently, the only valid value is CAPABILITY_IAM , which is required for the following resources: 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 . If your stack template contains these resources, we recommend that you review any permissions associated with them. If you don't specify this parameter, this action returns an InsufficientCapabilities error.

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 no-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 Key=string,Value=string

JSON Syntax:

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

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, it will not clobber their values.

--generate-cli-skeleton (boolean) Prints a sample input JSON to standard output. Note the specified operation is not run if this argument is specified. The sample input can be used as an argument for --cli-input-json.

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.