Create a stack from the CloudFormation console - AWS CloudFormation

Create a stack from the CloudFormation console

This topic describes the process of creating a stack from the CloudFormation console. The console provides a wizard-driven interface with predefined options to streamline the stack creation process.

To create a new stack, you need to provide a CloudFormation template. This template is a JSON or YAML formatted text file that specifies the resources you want to provision and the configuration properties for those resources. For more information, see Working with CloudFormation templates.

For examples of using the create-stack CLI command to create a stack, see Create, update, and delete CloudFormation stacks with the AWS CLI and PowerShell.

Creating a stack

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

To create a stack
  1. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation.

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

  3. 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 with a resource import.

  4. On the Create stack page, do one of the following:

    • To use an existing template, for Prepare template, choose Template is ready. 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 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/, or the AWS CLI. For more information, see Setting default server-side encryption behavior for Amazon S3 buckets 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 Use a sample template to use a sample template from the template library or Build from Application Composer to create a template with Application Composer. For more information, see Application Composer.

  5. 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.

  6. 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.

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

  8. Choose Next to continue creating the stack.

  9. (Optional) On the Configure stack options page, change the default stack options. For more information, see Configure stack options.

  10. Choose Next to continue.

  11. 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.

  12. If your template contains IAM resources, select the acknowledgment check box to acknowledge that CloudFormation might create IAM resources with custom names. For more information, see Acknowledging IAM resources in CloudFormation templates.

  13. (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.

  14. 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.

Configure stack options

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

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.

Permissions

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 AWS CloudFormation service role.

Stack failure options

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.

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

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.

Rollback configuration

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.

Notification options

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

The following options are included for stack creation, but aren't available as part of stack updates.

Timeout

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.

Termination protection is Disabled by default.

Preview the configuration of your stack

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.

Creating a change set for a new stack

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.

  2. 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.

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