https://github.com/dsandor/cdk-static-website
Deploy a SPA Website to AWS S3 with CloudFront CDN using AWS CDK
https://github.com/dsandor/cdk-static-website
Last synced: 8 months ago
JSON representation
Deploy a SPA Website to AWS S3 with CloudFront CDN using AWS CDK
- Host: GitHub
- URL: https://github.com/dsandor/cdk-static-website
- Owner: dsandor
- Created: 2019-07-27T02:19:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T23:48:41.000Z (about 3 years ago)
- Last Synced: 2024-11-14T17:47:56.256Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://medium.com/@david.sandor/deploy-a-spa-website-to-aws-s3-with-cloudfront-cdn-in-40-lines-of-typescript-using-aws-cdk-ff800b6c1bb8?sk=2ac0f2d36e7ec6c55d946b32df1c8ed5
- Size: 1.57 MB
- Stars: 25
- Watchers: 2
- Forks: 6
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-list - cdk-static-website
README
# cdk-rocks
> Simple SPA application to demonstrate CDK deployment of static assets to AWS.
## Prerequisites
- NodeJS 8+
- Install AWS CLI
- Install AWS SAM
- Install AWS CDK CLI
- Configure your AWS Credentials for your AWS Account
- Bootstrap the CDK `cdk bootstrap`
## Build Setup
``` bash
# install dependencies
yarn install
# build for production with minification
yarn build
```
**Example Website**
[https://cdk-example.awsexamples.dev/](https://cdk-example.awsexamples.dev/)
## Bootstrap the CDK in your account.
Otherwise you will get this error when trying to deploy.
```
This stack uses assets, so the toolkit stack must be deployed to the environment (Run "cdk bootstrap aws://unknown-account/unknown-region")
```
Bootstrapping is easy. Just run this CLI command:
`cdk bootstrap`
Bootstrapping creates the following resources (S3 Bucket) in your AWS account and is used to move the static assets within your account.
```
⏳ Bootstrapping environment aws://123456789012/us-east-1...
CDKToolkit: creating CloudFormation changeset...
0/2 | 11:42:51 | CREATE_IN_PROGRESS | AWS::S3::Bucket | StagingBucket
0/2 | 11:42:52 | CREATE_IN_PROGRESS | AWS::S3::Bucket | StagingBucket Resource creation Initiated
1/2 | 11:43:13 | CREATE_COMPLETE | AWS::S3::Bucket | StagingBucket
2/2 | 11:43:15 | CREATE_COMPLETE | AWS::CloudFormation::Stack | CDKToolkit
✅ Environment aws://123456789012/us-east-1 bootstrapped.
```
## Configure a Certificate for your website (optional)
After creating a certificate for your website in the AWS Certificate Manager (this is free by the way) notate the ARN for the cert. Then add a file to the root of this project called `config-cdk-sample.json` in this file add the following and replace the fake ARN with the ARN of your certificate.
```
{
"certificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/000000-0000-0000-0000-000000000000"
}
```