This project contains the infrastructure as code for the Digital Asset Portfolio Tracker application. It is written with the AWS CDK in TypeScript and is used to deploy AWS Services.
The AWS CloudFormation Stacks generated by this project's CDK include:
- AWS CodeCommit Repository for source code and AWS Amplify App source
- Amazon Cognito Identity Pool for anonymous/guest user access to Amazon Managed Blockchain Query
- Identity Pool configured for unauthenticated identities:
- AWS IAM Roles to enable the basic (classic) authflow:
- AWS Amplify App with AWS Hosting to build and deploy web application when commits are made to AWS CodeCommit:
bin/
- Main CDK entrypoint
- Instantiates each Stack
lib/
- Source code for each Stack written with the CDK
stacks/
- AWS CDK Stack classes that define the AWS resources of the project
utility/
- CDK helper functions
cdk.json
- Defines how the CDK should build and deploy the infrastructure
See the project README
-
Install dependencies
npm install
-
Bootstrap the CDK in your AWS environment
Your AWS account needs to be bootstraped only once
npx cdk bootstrap
Developing with the CDK is as simple as updating source code files. Once you're happy with your code, there are a couple of commands you can run to test your code:
npx cdk synth
- Generates an AWS CloudFormation template using your local CDK code
- Errors are thrown for invalid configuration
npx cdk diff
- Synthesizes your local CDK code and compares it with the deployed template
The CDK documentation will come in handy when writing new CDK code: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html
Deploy your infrastructure with the cdk deploy
command. Since this CDK project contains multiple stacks, we pass the --all
flag to deploy all of them:
npx cdk deploy --all
The CDK will deploy an AWS CodeCommit Repository and an AWS Amplify App configured to build and deploy the web application from the main
branch of the CodeCommit Repository. To push this repository to the main
branch of the CodeCommit Repository, follow the steps below:
-
Authenticate your local git repository with AWS CodeCommit
- Navigate to this CodeCommit Repository in the AWS Console
- The Repository should be empty, showing the
Connection steps
- The Repository should be empty, showing the
- Follow the connection steps that fit your AWS account setup
- Navigate to this CodeCommit Repository in the AWS Console
-
Set the remote URL of your repo to the CodeCommit Clone URL that matches your authentication method from the previous step:
git remote set-url origin <CodeCommit Clone URL>
Clone URLs can be copied from the
Clone URL
dropdown in the top right of the AWS CodeCommit console of the repo. They are also output by thecdk deploy
command. -
Push the source code to AWS CodeCommit and kickoff the AWS Amplify App build to deploy the web app:
git push -u origin main
After the code is successfully pushed to the CodeCommit Repository main
branch, the Amplify App deployment will initiate. Progress can be monitored in the AWS Amplify Console.
Once the Amplify App is deployed, it will be live at the Amplify App URL. The Amplify App URL can be found in the AWS Amplify Console and is also output by the cdk deploy
command.
To destroy all AWS resources deployed by this CDK project, run the following command:
npx cdk destroy --all
NOTE: If you generated Git credentials for your IAM user when you cloned the AWS CodeCommit repo, be sure to delete them.