Skip to content

Commit

Permalink
Add setup, exercise, and solution information
Browse files Browse the repository at this point in the history
  • Loading branch information
jbutz committed Aug 21, 2024
1 parent 4486560 commit dbd44e0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,44 @@ References:
- [AWS Lambda Pricing](https://aws.amazon.com/lambda/pricing/)
- [AWS CloudFormation Pricing](https://aws.amazon.com/cloudformation/pricing/)

## Setup

You will need [Node.js](https://nodejs.org/en) v20 and [Git](https://git-scm.com/) installed. You will also need access to an AWS account, to be safe you should have administrator access. You can probably complete this exercise with lower access levels, but due to the number of potential configurations I can't say that for certain.

### Codebase Setup

1. Using git, clone this respository to your machine. The command below will only clone the most recent code, since you don't need the code's entire history for this exercise.
```bash
git clone --depth 1 https://github.com/jbutz/aws-cfn-rollback-exercise.git
```
2. Install the node modules using NPM
```bash
npm install
```

### Exercise Setup

1. Configure your [command line to have access to your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-authentication.html).
2. If it is not already set, set the `AWS_REGION` environment variable to the AWS Region you want to use, it will make things easier
```bash
# On Linux and Mac you can use the command below to set the region to US East 2 (Ohio)
export AWS_REGION=us-east-2
```
3. [Bootstrap](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping-env.html) the AWS CDK into your account and region
```bash
npm run bootstrap
```
4. [Deploy](https://docs.aws.amazon.com/cdk/v2/guide/deploy.html) the application into your AWS account using the CDK. The deployment will ask your permission to make IAM changes. You must allow these to deploy the exercise.
```bash
npm run deploy
```
5. Without making any code changes, deploy the application again. This will cause the `UPDATE_ROLLBACK_FAILED` error and enable you to resolve the issue.
```bash
npm run deploy
```

## The Exercise

You should use the AWS Management Console for the exercise and navigate to the CloudFormation service to view your CloudFormation stack, it should be called `CfnRollbackExercise`. Click the _Stack actions_ button, notice that there is an option there labeled _Continue update rollback_. Your goal is to be able to use that option and successfully rollback the stack and have the stack in the `UPDATE_ROLLBACK_COMPLETE` status. Once you have done that, delete the stack from the console. If the delete fails, discovery the issue and resolve it.

To view the notes about the solutions, go to [SOLUTION.md](./SOLUTION.md).
15 changes: 15 additions & 0 deletions SOLUTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Solutions

> **If you have not completed the exercise, this page will spoil the was to resolve the issue.**
## The Problem

This exercise uses a [CloudFormation custom resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html) to create an artificial scenario that causes CloudFormation to end up in a `UPDATE_ROLLBACK_FAILED` or `DELETE_FAILED` state.

## The Solution

Manually adjusting the memory limit for the Lambda function deployed by the CloudFormation stack to 129MB causes the custom resource to complete successfully, allowing rollbacks and deletes to succeed. The Lambda function's name should start with `CfnRollbackExercise-function`. You can quickly access it via the _Resources_ tab when viewing the CloudFormation stack. By reading through the messages in the _Events_ tab of the stack, you can make this determination.

### Skipping Resources

You can complete the stack rollback and stack deletion by skipping the _exercise_ resource, this is sometimes the solution to use out in the world, but it can result in unused resources being left in your AWS account. These should be manually cleaned up. For this exercise, nothing will be leftover when choosing to skip the _exercise_ resource.

0 comments on commit dbd44e0

Please sign in to comment.