> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Building Your First Stack

> Guide to creating and updating an AWS CloudFormation stack that provisions an S3 bucket and adds tags.

In this lesson you'll create a simple AWS CloudFormation stack that provisions an Amazon S3 bucket, then update that stack to add tags. A CloudFormation stack is a collection of AWS resources you create and manage together from a template — effectively a group of resources managed as one unit.

This guide walks through:

* authoring a minimal CloudFormation YAML template,
* uploading the template to the AWS Management Console,
* creating the stack,
* updating the stack to add metadata (tags),
* and verifying the result in the S3 console.

## What you'll create

* A CloudFormation stack named (for example) `DemoStack`
* One S3 bucket resource with logical ID `MyBucket`
* An update that adds an `Author: Arno` tag to the bucket

## Prerequisites

* An AWS account and permissions to create CloudFormation stacks and S3 buckets.
* A code editor (Visual Studio Code recommended).

## Step 1 — Open CloudFormation in the Console

Open the AWS Management Console, use the service search box, type "CloudFormation" (typing "CloudF" is sufficient), and select CloudFormation. If you've used CloudFormation before you'll land on the Stacks dashboard; otherwise you'll see the CloudFormation homepage.

Click "Create stack" and follow the guided steps:

1. Create stack
2. Specify stack details
3. Configure stack options
4. Review and create

Templates can come from multiple sources. A short reference of common choices:

| Template source | When to use |
| - | - |
| Upload a template file | Quick, local development and testing (`stack.yaml`) |
| Amazon S3 template | Reuse templates shared across accounts and teams |
| Git repository | CI/CD pipelines and versioned templates |

For this lesson we'll create a local YAML template and upload it directly via the console.

## Step 2 — Create `stack.yaml` locally

Open your project folder in Visual Studio Code and create a new file named `stack.yaml`. Example Windows path:

```text theme={null}
C:\Users\Arno\Desktop\Project\stack.yaml
```

![A dark-themed Visual Studio Code window with the Explorer open and a file named "stack.yaml" selected. The editor shows the "stack.yaml" tab with a single line containing the number "1".](https://mintcdn.com/kodekloud-c4ac6d9a/5BuH6-_lHDMy3nuh/images/AWS-Certified-DevOps-Engineer-Professional/Domain-2-Configuration-Management-and-IaC/Demo-Building-Your-First-Stack/vscode-dark-explorer-stack-yaml-1.jpg?fit=max\&auto=format\&n=5BuH6-_lHDMy3nuh\&q=85\&s=4272bc80328cb240327f6567e538f34b)

Start the template with the required version header and a single `Resources` section declaring an S3 bucket with logical ID `MyBucket`:

```yaml theme={null}
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
```

Save `stack.yaml`.

## Step 3 — Upload the template and create the stack

In the CloudFormation console choose "Upload a template file", select the `stack.yaml` you created, then click Next and proceed through the stack creation wizard. CloudFormation will internally upload your template (it stores it in a managed S3 location) and then create the stack.

![A screenshot of the AWS CloudFormation "Create stack" page showing the "Upload a template file" panel with "stack.yaml" selected and an S3 URL displayed, plus the Next and Cancel buttons.](https://mintcdn.com/kodekloud-c4ac6d9a/5BuH6-_lHDMy3nuh/images/AWS-Certified-DevOps-Engineer-Professional/Domain-2-Configuration-Management-and-IaC/Demo-Building-Your-First-Stack/aws-cloudformation-upload-stack-yaml-s3.jpg?fit=max\&auto=format\&n=5BuH6-_lHDMy3nuh\&q=85\&s=a15fcdefcc31ea5ce9c933ccdad4c313)

Submit the create request. On the stack details page open the Events tab to follow progress. Initially the bucket creation will show `CREATE_IN_PROGRESS` and then `CREATE_COMPLETE`.

![A screenshot of the AWS CloudFormation console showing the "DemoStack" events list with operation IDs, timestamps, and logical IDs like "MyBucket" and "DemoStack." Several resources are marked "CREATE\_IN\_PROGRESS."](https://mintcdn.com/kodekloud-c4ac6d9a/5BuH6-_lHDMy3nuh/images/AWS-Certified-DevOps-Engineer-Professional/Domain-2-Configuration-Management-and-IaC/Demo-Building-Your-First-Stack/cloudformation-demostack-events-create-in-progress.jpg?fit=max\&auto=format\&n=5BuH6-_lHDMy3nuh\&q=85\&s=50e758a945cafce4b5a77392a877140d)

## Step 4 — Verify the S3 bucket

When the stack completes, open the Amazon S3 service in a new console tab and browse buckets. CloudFormation typically prefixes the physical bucket name with the stack name and logical ID; for example `demostack-mybucket-<random-suffix>`.

![A screenshot of the Amazon S3 web console showing the bucket "demostack-mybucket-uhiv0vbctobm" with the Objects tab open. Visible controls include Upload, Create folder, Copy URL, and navigation links for Buckets and other S3 sections.](https://mintcdn.com/kodekloud-c4ac6d9a/5BuH6-_lHDMy3nuh/images/AWS-Certified-DevOps-Engineer-Professional/Domain-2-Configuration-Management-and-IaC/Demo-Building-Your-First-Stack/s3-console-demostack-mybucket-uhiv0vbctobm-objects.jpg?fit=max\&auto=format\&n=5BuH6-_lHDMy3nuh\&q=85\&s=b7bf09a61ab9bd3a828f6b346c40c05f)

## Step 5 — Update the stack to add tags

Tags are key-value pairs used to store metadata such as author, environment, or cost center. We'll update the template to add an `Author` tag for the bucket.

YAML indentation is significant. Use consistent spaces (commonly two spaces per level). Under a resource's `Properties`, `Tags` is a list where each item is a `Key`/`Value` mapping.

Edit `stack.yaml` and add a `Properties` block with `Tags`. The updated template should look like this:

```yaml theme={null}
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      Tags:
        - Key: Author
          Value: Arno
```

Save the file.

In the CloudFormation console select your stack, then choose "Update stack". Choose "Replace current template", upload the updated `stack.yaml`, and proceed through the update wizard. Submit the change.

Watch the Events pane to follow the update operation — you should see `UPDATE_IN_PROGRESS` followed by `UPDATE_COMPLETE` entries for the stack and the `MyBucket` resource.

![A screenshot of the AWS CloudFormation console showing the Events pane for a stack called "DemoStack," listing operation IDs, timestamps and resources (e.g., MyBucket) with statuses like UPDATE\_IN\_PROGRESS. The browser header shows the CloudWithDjango-Org account and standard AWS navigation controls.](https://mintcdn.com/kodekloud-c4ac6d9a/5BuH6-_lHDMy3nuh/images/AWS-Certified-DevOps-Engineer-Professional/Domain-2-Configuration-Management-and-IaC/Demo-Building-Your-First-Stack/cloudformation-demostack-events-screenshot.jpg?fit=max\&auto=format\&n=5BuH6-_lHDMy3nuh\&q=85\&s=84c709d014d9f9fc615f19dcb21189dc)

## Step 6 — Confirm the update

When the update completes the stack status will show `UPDATE_COMPLETE`. Verify the S3 bucket's properties in the S3 console (Properties → Tags) to confirm the `Author: Arno` tag appears.

![A screenshot of the AWS CloudFormation console listing one stack named "DemoStack" with status "UPDATE\_COMPLETE" and a creation timestamp. The page shows CloudFormation controls (Delete/Update/Create stack) and the AWS account/region header.](https://mintcdn.com/kodekloud-c4ac6d9a/5BuH6-_lHDMy3nuh/images/AWS-Certified-DevOps-Engineer-Professional/Domain-2-Configuration-Management-and-IaC/Demo-Building-Your-First-Stack/aws-cloudformation-demo-stack-update-complete.jpg?fit=max\&auto=format\&n=5BuH6-_lHDMy3nuh\&q=85\&s=7a653a20ddb9981cac84b42810bbab67)

## Troubleshooting tips

* If the stack update fails, check the Events tab for the failing resource and the associated error message.
* Ensure the IAM permissions for your user/role include CloudFormation and S3 actions required for stack creation and updates.
* Verify there are no bucket name conflicts; CloudFormation-generated physical names include a random suffix to help avoid collisions.

## Links and references

* [CloudFormation Documentation](https://learn.kodekloud.com/user/courses/aws-cloud-formation)
* [Amazon S3 Documentation](https://learn.kodekloud.com/user/courses/amazon-simple-storage-service)

That's it — you created a CloudFormation stack, added an S3 bucket, and updated the stack to attach tags. Well done.

> **[Watch Video](https://learn.kodekloud.com/user/courses/aws-certified-devops-engineer-professional/module/42510d3c-bacc-4a37-adb8-2cfea86f1a36/lesson/a705f943-42d6-4f46-9ec9-b4a460efd61f)**

> **[Practice Lab](https://learn.kodekloud.com/user/courses/aws-certified-devops-engineer-professional/module/42510d3c-bacc-4a37-adb8-2cfea86f1a36/lesson/ffa8c19b-cabe-41d4-b9dc-ee700929e94d)**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.