Instructions with CDK script for deploying single-page-app to S3. After executing manual steps from section prerequisities you can run the CDK script. The script will create
- S3 bucket for storing the files
- TLS certificate to region "us-east-1" via ACM
- Cloudfront distribution with the TLS certificate for the S3 bucket
- Route53 record in a pre-existing hosted zone for the cloudfront distribution
- IAM user with S3 bucket update permissions for CI use
-
Make sure you have installed node.js, AWS CDK and Typescript:
# node nvm install # aws cdk npm install -g aws-cdk # typescript npm install -g typescript
-
You need AWS Account. Create IAM user and AWS Access keys via console if you don't have one already.
-
Create a public hosted zone to AWS Route53 for your domain. If your domain registrar is different from AWS Route53, you need to store the AWS nameservers to your domain settings (via the domain registrar UI).
-
Declare following environment variables:
# default region for AWS e.g. eu-north-1 export AWS_DEFAULT_REGION=<xxx> # IAM user access key ID export AWS_ACCESS_KEY_ID=<xxx> # IAM user secret access key export AWS_SECRET_ACCESS_KEY=<xxx> # default region for AWS e.g. eu-north-1 export CDK_DEFAULT_REGION=<xxx> # AWS account number export CDK_DEFAULT_ACCOUNT=<xxx>
# install deps
npm install
# bootstrap CDK
cdk bootstrap
# deploy CDK
cdk deploy