Skip to content

Commit

Permalink
more readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
blytheaw committed Jan 12, 2021
1 parent 72cb43a commit f089b41
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# CloudFormation Custom Resource Deployment Process

This project is meant to demonstrate a multi-project deployment process using a CloudFormatioon Custom Resource. The specific requirements are found in `INSTRUCTIONS.md` within this repo. The project is broken up into three primary components:
This project is meant to demonstrate a multi-project deployment process using a CloudFormation Custom Resource. The specific requirements are found in `INSTRUCTIONS.md` within this repo. The project is broken up into three primary components:

- `weather-api/` - Lambda Function to be used with API Gateway that returns weather for Tulsa, OK from the OpenWeatherMap API
- `weather-app/` - Simple Angular SPA that retrieves the weather data from the API and displays a subset of it on a page
- `deployment/` - The CloudFormatioon Custom Resource that deploys both projects and wires them up. The bulk of the code is here.
- `deployment/` - The CloudFormation Custom Resource that deploys both projects and wires them up. The bulk of the code is here.

In addition, there is a GitHub Actions workflow defined under `./github/workflows` that builds the code artifacts, creates a GitHub Release, and uploads the artifacts to the release. The deployment CloudFormatioon resource downloads these artifacts for deployment.
In addition, there is a GitHub Actions workflow defined under `./github/workflows` that builds the code artifacts, creates a GitHub Release, and uploads the artifacts to the release. The deployment CloudFormation resource downloads these artifacts for deployment.

## Setup

### Prerequisites:

- You will need an AWS account with sufficient IAM permissions to build the resources in this project. Deploying the CloudFormatioon Custom Resource requires the following high level permissions:
- Create CloudFormatioon Stacks
- You will need an AWS account with sufficient IAM permissions to build the resources in this project. Deploying the CloudFormation Custom Resource requires the following high level permissions:
- Create CloudFormation Stacks
- Create IAM roles and pass them to Lambda functions
- Create S3 Buckets and upload objects
- Create and invoke Lambda Functionos
Expand All @@ -23,7 +23,7 @@ In addition, there is a GitHub Actions workflow defined under `./github/workflow
- `npm install -g serverless`
- Lastly, you will need an API Key for OpenWeatherMap API. You can create a free account and generate a key here: https://home.openweathermap.org/users/sign_up

### Deploy the CloudFormatioon Custom Resource
### Deploy the CloudFormation Custom Resource

1. Navigate to the `deployment/` directory in a terminal
2. Run `npm install` to download dependencies
Expand Down Expand Up @@ -56,20 +56,20 @@ Outputs:

The only values you should need to update are:

- ServiceToken: set this to the Lambda ARN of your custom resource function
- OpenWeatherApiKey: set this to the API you generated with OpenWeatherMap
- `ServiceToken`: set this to the Lambda ARN of your custom resource function
- `OpenWeatherApiKey`: set this to the API you generated with OpenWeatherMap

The other properties can be left alone, but here is an explanation:

- Region: this configures the AWS SDK clients to create resources in this region. Leave as default to use the CloudFormation stack's region.
- AccountId: this is used to populate some ARN's in the custom resource that require the accountId. Again, it is passed through via CloudFormation.
- APICodeUrl/SPACodeUrl: these are URLs to download the code artifacts from GitHub.
- `Region`: this configures the AWS SDK clients to create resources in this region. Leave as default to use the CloudFormation stack's region.
- `AccountId`: this is used to populate some ARN's in the custom resource that require the accountId. Again, it is passed through via CloudFormation.
- `APICodeUrl/SPACodeUrl`: these are URLs to download the code artifacts from GitHub.

### Outputs

This stack outputs one value:

S3WebsiteUrl: the S3 static website URL to view the running applicatioon
`S3WebsiteUrl`: the S3 static website URL to view the running applicatioon

### Creating the Stack

Expand All @@ -91,14 +91,14 @@ When CloudFormation sends a delete request to the custom resource, it will attem

## Lessons Learned

1. CloudFormatioon Custom Resources are very powerful, but they can also be tricky to test and debug due to how they work.
1. CloudFormation Custom Resources are very powerful, but they can also be tricky to test and debug due to how they work.
2. I learned a pretty clean way to do a sleep timer in NodeJS:
```
import { promisify } from "util";
const sleep = promisify(setTimeout);
await sleep(1000);
```
3. `cfn-response` and similar libraries are helpful when dealing with CloudFormatioon Custom Resources, but in some cases lack flexibility to modify the responses send to CloudFormatioon.
3. `cfn-response` and similar libraries are helpful when dealing with CloudFormation Custom Resources, but in some cases lack flexibility to modify the responses send to CloudFormation.
4. Loading Angular configuration at runtime when the app initializes.

## Enhancements
Expand Down

0 comments on commit f089b41

Please sign in to comment.