

# Create a stack from the CloudFormation console
<a name="cfn-console-create-stack"></a>

You can create a stack template and then use it to create a stack using either the CloudFormation console or a command line tool. The console provides a wizard-driven interface with predefined options, which streamlines the stack creation process.

**Topics**
+ [

## Creating a stack
](#create-stack)
+ [

## Configure stack options
](#configure-stack-options)
+ [

## Preview the configuration of your stack
](#cfn-console-create-stacks-changesets)

## Creating a stack
<a name="create-stack"></a>

Follow the steps in this section to deploy your template and create a stack.

**Prerequisites**
+ You must have created a stack template. For more information, see [Working with CloudFormation templates](template-guide.md).

**To create a stack (console)**

1. Open the CloudFormation console at [https://console.aws.amazon.com/cloudformation](https://console.aws.amazon.com/cloudformation/).

1. On the navigation bar at the top of the screen, choose the AWS Region to create the stack in.

1. On the **Stacks** page, choose **Create stack** at top right, and then choose **With new resources (standard)**.

   Alternatively, you can choose the **With existing resources (import resources)** option to import existing AWS resources that are described in your template. For more information on this option, see [Import AWS resources into a CloudFormation stack](import-resources.md).

1. On the **Create stack** page, do one of the following:
   + To use an existing template, for **Prerequisite - Prepare template**, choose **Choose an existing template**. Then, under **Specify template**, choose either **Amazon S3 URL** or **Upload a template file** based on the template's location.
     + If you choose **Amazon S3 URL**, provide a URL to the template file in an S3 bucket.

       If your template includes nested stacks (for example, stacks described in other template documents located in subdirectories), make sure that your S3 bucket contains the necessary files and directories.

       If you have a template from a versioning-enabled bucket, you can specify a specific version of the template by appending `?versionId=version-id` to the URL. For more information about versioning-enabled buckets, see [Working with objects in a versioning-enabled bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-objects-versioned-bucket.html) in the *Amazon Simple Storage Service User Guide*.

       The URL must point to a template with a maximum size of 1 MB that is stored in an S3 bucket that you have read permissions to. The URL can be a maximum of 1024 characters long. Some resources may require that the bucket be in the same Region as the stack.
     + If you choose **Upload a template file**, choose **Choose File** to choose a template file from your local computer. The template file size must be 1 MB or less. 

       Once you have chosen your template, CloudFormation uploads the file and displays the S3 URL. CloudFormation uploads it to an Amazon S3 bucket in your AWS account. If you already have an S3 bucket that was created by CloudFormation in your AWS account, CloudFormation adds the template to that bucket. If you don't already have an existing CloudFormation-created bucket, it creates a unique bucket for each Region where you upload a template file. 

       The following are considerations when using the S3 buckets created by CloudFormation:
       + The buckets are accessible to anyone with Amazon S3 permissions in your AWS account.
       + CloudFormation creates the buckets with server-side encryption enabled by default, thereby encrypting all objects stored in the bucket.

         You can directly manage encryption options for buckets that CloudFormation has created, for example, using the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/), or the AWS CLI. For more information, see [Setting default server-side encryption behavior for Amazon S3 buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-encryption.html) in the *Amazon Simple Storage Service User Guide*.
       + You can use your own bucket and manage its permissions by manually uploading templates to Amazon S3. When you create or update a stack, specify the Amazon S3 URL of a template file. 
   + If you don't have a template ready, you can choose **Build from Infrastructure Composer** to create a template with Infrastructure Composer. For more information, see [Infrastructure Composer](infrastructure-composer-for-cloudformation.md).

1. Choose **Next** to continue and to validate the template.

   Before continuing, CloudFormation validates your template to catch syntactic and some semantic errors, such as circular dependencies. During validation, CloudFormation first checks if the template is valid JSON. If it isn't, CloudFormation checks if the template is valid YAML. If both checks fail, CloudFormation returns a template validation error.

1. On the **Specify stack details** page, type a stack name in the **Stack name** box.

   The stack name is an identifier that helps you find a particular stack from a list of stacks. A stack name can contain only alphanumeric characters (case-sensitive) and hyphens. It must start with an alphabetic character and can't be longer than 128 characters.

1. In the **Parameters** section, specify values for the parameters that were defined in the template.

1. Choose **Next** to continue creating the stack.

1. (Optional) On the **Configure stack options** page, change the default stack options. For more information, see [Configure stack options](#configure-stack-options).

1. If your template contains IAM resources, for **Capabilities**, choose **I acknowledge that this template may create IAM resources** to specify that you want to use IAM resources in the template. For more information, see [Acknowledging IAM resources in CloudFormation templates](control-access-with-iam.md#using-iam-capabilities).

1. Choose **Next** to continue.

1. On the **Review and create** page, review the details of your stack.

   To change any of the values before launching the stack, choose **Edit** on the section that has the setting that you want to change.

1. (Optional) You can create a change set to preview the configuration of the stack before creating it. On the **Review and create** page, choose **Create change set** and follow the directions. For more information, see [Preview the configuration of your stack](#cfn-console-create-stacks-changesets).

1. Choose **Submit** to launch your stack.

CloudFormation will then proceed to create all the resources defined in the template.

You can monitor the progress and status of the stack creation on the **Events** tab for your new stack. For more information, see [Monitor stack progress](monitor-stack-progress.md).

**To create a stack using the command line**  
You can use one of the following commands:
+ [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) (AWS CLI)
+ [https://docs.aws.amazon.com/powershell/latest/reference/items/New-CFNStack.html](https://docs.aws.amazon.com/powershell/latest/reference/items/New-CFNStack.html) (AWS Tools for Windows PowerShell)

For examples of using the command line to create a stack, see [Examples of CloudFormation stack operation commands for the AWS CLI and PowerShell](service_code_examples.md).

## Configure stack options
<a name="configure-stack-options"></a>

On the **Configure stack options** page, you can configure options for your CloudFormation stacks like tags, notification of stack events, or a stack policy.

You can set the following stack options:

**Tags**  <a name="configure-stack-options-tags"></a>
You can add up to 50 tag key pairs to your stack and to any resources that CloudFormation supports tagging for. A tag is a customer-defined key and value that can be assigned to AWS resources for purposes such as cost tracking.   
A **Key** consists of any alphanumeric characters or spaces. Tag keys can be up to 127 characters long.  
A **Value** consists of any alphanumeric characters or spaces. Tag values can be up to 255 characters long.  
After stack creation, adding, updating, or removing stack-level tags will initiate a stack update. All resources that support stack-level tag propagation will be updated accordingly.

**Permissions**  <a name="configure-stack-options-permissions"></a>
An existing IAM service role that CloudFormation can assume. Instead of using your account credentials, CloudFormation uses the role's credentials to create your stack. For more information, see [CloudFormation service role](using-iam-servicerole.md).

**Stack failure options**  <a name="configure-stack-options-rollback"></a>
Specifies the provision failure options for all stack deployments and change set operations. For more information, see [Choose how to handle failures when provisioning resources](stack-failure-options.md).  
The **Roll back all stack resources** option will roll back all resources specified in the template when the stack status is `CREATE_FAILED` or `UPDATE_FAILED`.  
For create operations, the **Preserve successfully provisioned resources** option preserves the state of successful resources, while failed resources will stay in a failed state until the next update operation is performed.  
For update and change set operations, the **Preserve successfully provisioned resources** option preserve the state of successful resources while rolling back failed resources to the last known stable state. Failed resources will be in an `UPDATE_FAILED` state. Resources without a last known stable state will be deleted upon the next stack operation.

You can also set the following advanced options for stack creation:

**Stack policy**  <a name="configure-stack-options-stack-policy"></a>
Defines the resources that you want to protect from unintentional updates during a stack update. By default, all resources can be updated during a stack update.  
You can enter the stack policy directly as JSON, or upload a JSON file containing the stack policy. For more information, see [Prevent updates to stack resources](protect-stack-resources.md).

**Rollback configuration**  <a name="configure-stack-options-rollback-configuration"></a>
You can have CloudFormation monitor the state of your stack during stack creation and updating, and roll back that operation if the stack breaches the threshold of any of the alarms you've specified. Specify the CloudWatch alarms that CloudFormation should monitor. If any of the alarms goes to `ALARM` state during the stack operation or the monitoring period, CloudFormation rolls back the entire stack operation. For more information, see [Roll back your CloudFormation stack on alarm breach with rollback triggers](using-cfn-rollback-triggers.md).

**Notification options**  <a name="configure-stack-options-notification"></a>
You can specify a new or existing Amazon Simple Notification Service topic where notifications about stack events are sent.  
If you create an Amazon SNS topic, you must specify a name and an email address where stack event notifications are to be sent.

**Stack creation options**  <a name="configure-stack-options-creation-options"></a>
The following options are included for stack creation, but aren't available as part of stack updates.    
**Timeout**  <a name="configure-stack-options-creation-timeout"></a>
Specifies the amount of time, in minutes, that CloudFormation should allot before timing out stack creation operations. If CloudFormation can't create the entire stack in the time allotted, it fails the stack creation due to timeout and rolls back the stack.  
By default, there is no timeout for stack creation. However, individual resources may have their own timeouts based on the nature of the service they implement. For example, if an individual resource in your stack times out, stack creation also times out even if the timeout you specified for stack creation hasn't yet been reached.  
**Termination protection**  
Prevents a stack from being accidentally deleted. If a user attempts to delete a stack with termination protection enabled, the deletion fails and the stack, including its status, remains unchanged. For more information, see [Protect CloudFormation stacks from being deleted](using-cfn-protect-stacks.md).  
Termination protection is **Disabled** by default.

## Preview the configuration of your stack
<a name="cfn-console-create-stacks-changesets"></a>

To preview how a CloudFormation stack will be configured before creating the stack, create a change set. This functionality allows you to examine various configurations and make corrections and changes to your stack before executing the change set. For more information on change sets, see [Update CloudFormation stacks using change sets](using-cfn-updating-stacks-changesets.md).

### Creating a change set for a new stack
<a name="cfn-console-create-stacks-changesets-create-new-stack"></a>

To create a change set for a new stack, select your stack template and specify the configuration of your stack as you would if you were creating a new stack, then choose to create a new change set rather than a new stack.

**To create a change set for a new stack**

1. On the **Review and create** page, choose **Create change set**.

1. In the **Create change set** dialog box, enter a name for the change set, and a description if desired. Choose **Create change set**.

   When you create a change set for a new stack, CloudFormation does the following:
   + Launches a new stack with a status of `REVIEW_IN_PROGRESS`.
   + Creates a change set for the new stack that reflects the stack configuration you specified in the previous steps.

   CloudFormation displays the **Change sets** page for the proposed stack. While CloudFormation creates the change set, its status is `CREATE_IN_PROGRESS`, and its execution status is `UNAVAILABLE`. When CloudFormation completes successfully creating the change set, it sets the change set status to `CREATE_COMPLETE`, and its execution status is `AVAILABLE`. The stack status is updated to `REVIEW_IN_PROGRESS`. At this point, you can execute the change set to complete creating the new stack.

   In the **Changes** pane, CloudFormation displays the proposed configuration of your stack.

   If CloudFormation fails to create the change set, it sets the changes set status to `CREATE_FAILED`. Fix the error displayed in the **Status reason** field, and then create a new change set. At this stage, you can try various configurations and make corrections and changes to your stack before executing the next change set.

1. To complete creating a new stack based on the change set, choose **Execute**, specify your rollback configuration, and then choose **Execute change set**.