Creating a CloudFormation stack means writing (or choosing) a template that describes your AWS resources, then letting AWS CloudFormation provision and manage them as a single unit. The fastest route is the AWS Console: open CloudFormation, choose Create stack, upload or select a template, fill in any parameters, and submit — AWS handles the rest in order, respecting dependencies between resources. This guide walks through the whole process, from preparing the template to verifying the deployment.
What You'll Need
- An AWS account with sign-in access
- IAM permissions that allow CloudFormation actions (such as creating, updating, and describing stacks) plus whatever the template creates (for example, permissions to create S3 buckets or EC2 instances)
- A CloudFormation template in JSON or YAML — either one you wrote, a sample from AWS documentation, or one saved to an S3 bucket
- A name for your stack (unique within your account and region)
Step-by-Step
- Prepare your template. Write it in YAML or JSON. At minimum it needs a Resources section describing at least one AWS resource. A simple example that creates an S3 bucket looks like this in YAML:
Resources:thenMyBucket:withType: AWS::S3::Bucket. Save the file locally, for example astemplate.yaml. - Validate before deploying. If you use the AWS CLI, run
aws cloudformation validate-template --template-body file://template.yaml. In the console you can skip this; CloudFormation checks syntax when you upload. - Open the CloudFormation console. Sign in to the AWS Management Console, search for CloudFormation, and open it. Make sure you are in the AWS Region where you want the resources created — check the region selector in the top-right corner.
- Start the wizard. Choose Create stack, then With new resources (standard). (Exact button labels can vary slightly between console versions.)
- Provide the template. Choose Upload a template file, select your local file, and choose Next. Alternatively, if your template is already in S3, choose Amazon S3 URL and paste the object URL.
- Name the stack and set parameters. Enter a stack name (letters, numbers, and hyphens only; no spaces). If your template declares Parameters, fill them in now — for example a bucket name or instance type. Choose Next.
- Configure stack options (optional). Here you can add tags, an IAM role for the stack to assume, a rollback configuration, or a termination protection setting. For a first stack, the defaults are fine — choose Next.
- Review and create. Check the summary. If your template creates IAM resources, tick the box acknowledging that CloudFormation may create IAM resources with custom names. Choose Create stack.
- Watch the events. Open the stack, then the Events tab. Resources are created in dependency order, and each one moves through statuses like CREATE_IN_PROGRESS and CREATE_COMPLETE. The stack itself shows CREATE_COMPLETE when everything succeeded.
- Verify the outputs. Check the Outputs tab for any values your template exports (such as a bucket name or URL), then confirm the resources exist in their respective service consoles.
You can also do all of this from the command line: aws cloudformation deploy --template-file template.yaml --stack-name my-stack --capabilities CAPABILITY_IAM creates or updates the stack in one command.
Common Mistakes
- Deploying in the wrong Region — the stack and its resources live only in the region you had selected.
- Using spaces or invalid characters in the stack name; stick to alphanumerics and hyphens.
- Forgetting the IAM capability acknowledgment when the template creates IAM roles or users — creation will fail.
- Naming an S3 bucket with a name that already exists globally; bucket names must be unique across all of AWS, so let CloudFormation generate one unless you are certain yours is free.
- Manually changing or deleting resources that CloudFormation created — the stack's record of them goes stale, and later updates or deletes fail.
- Editing the template on S3 after deployment and expecting the stack to change; stacks only change when you run an update.
Tips
- Start tiny: a single S3 bucket or security group is a perfect first stack before attempting multi-resource architectures.
- Define Parameters for anything you might change between environments, and use the same template for dev and production.
- Use the Outputs section to surface important values (bucket names, instance IDs) so you don't have to hunt for them in other consoles.
- Enable termination protection on stacks you don't want deleted by accident — it's on the stack's actions menu after creation.
- Use change sets for updates on important stacks: they show you a preview of what will be added, modified, or removed before anything actually happens.
Troubleshooting
- Stack shows CREATE_FAILED and rolled back: open the Events tab, find the red failed event, and read its status reason. Common causes are missing IAM permissions, a resource name conflict, or an invalid property value in the template. Fix the template or permissions and create the stack again — a failed create deletes everything it made.
- Validation error on upload: the template has a syntax problem. Check YAML indentation (two spaces, consistent) or JSON commas, and confirm every Resource has a Type.
- Stuck in CREATE_IN_PROGRESS: some resources simply take several minutes (for example, VPCs with NAT gateways). If it genuinely never finishes, check the Events tab for the resource holding things up.
- Update fails: the Events tab shows exactly which resource and why. Some property changes require resource replacement — CloudFormation will tell you beforehand if you use a change set.
- Insufficient permissions error: your IAM user or role needs permission for CloudFormation actions and for the services in the template. An administrator can attach the appropriate managed policy.
- Stack stuck in UPDATE_ROLLBACK_FAILED or similar stuck state: you can often continue the rollback from the stack's actions menu; if that fails, deleting the stack (which removes the resources it still tracks) is usually the cleanest recovery — back up any data first.
Frequently Asked Questions
Is CloudFormation free?
Yes — there is no additional charge for CloudFormation itself. You pay only for the AWS resources it creates, such as EC2 instances or S3 storage.
Should I use JSON or YAML?
Both are fully supported and equivalent. YAML is more readable and is what most examples use; use whichever your team prefers.
What happens if I delete a stack?
CloudFormation deletes every resource the stack created. Data in those resources is lost, so empty or back up buckets and databases first if you need the contents.
Can I create a stack from the AWS CLI?
Yes. Use aws cloudformation deploy or aws cloudformation create-stack with a local template file or an S3 URL. The CLI and console produce the same result.
Can one template create resources in multiple regions?
No. A single stack operates in one region. To deploy the same template to multiple regions, create a separate stack per region, or use CloudFormation StackSets, which deploy across regions and accounts from one place.