This document provides step by step instructions to setup AWS CDK.
- Homebrew (for MacOS) or Chocolatey (for Windows)
- Node.js and npm
- AWS CDK
- Amazon Web Services account
- Change
product: 'awscdk-example-ecs-for-fargate'
to your project name in theconfig/default.ts
file. - Adjust each parameter in
config/<NODE_ENV>.ts
as per your project requirements. - The parameters in
config/default.ts
will be overridden by those inconfig/<NODE_ENV>.ts
. - Visual Studio Code (VS Code) for code editing (Download Here).
- ESLint and Prettier plugins for VS Code for better coding practices.
AWS CDK is required. For MacOS, you can install it via Homebrew. For Windows, you can use Chocolatey.
-
MacOS:
brew install aws-cdk
-
Windows:
choco install aws-cdk
To configure your AWS credentials and account/settings details, set the following environment variables:
-
MacOS:
export AWS_PROFILE=<Your AWS Profile> export NODE_ENV=<Your Node.js environment>
-
Windows:
$env:AWS_PROFILE="<Your AWS Profile>" $env:NODE_ENV="<Your Node.js environment>"
Please replace <Your AWS Profile>
and <Your Node.js environment>
with your actual Your AWS Profile and Node.js environment respectively.
Navigate to your working directory and install the required npm packages:
npm install
To compile your TypeScript code into JavaScript, use:
npm run build
To see the differences between your current state and the changes the AWS CDK is going to deploy, use:
cdk diff
To deploy your infrastructure, use the following command:
cdk deploy
To destroy your infrastructure, use the following command:
cdk destroy
It removes all the resources provisioned by your AWS CDK configuration. Be careful when using this command, as it will permanently destroy all your resources.
That's it. You've now deployed your infrastructure on AWS using AWS CDK!