Nx with NPM workspace that manages AWS infrastructure and resource provisioning code (IaC)
Install AWS v2 CLI tool on OSX
In the case you use a different operating system please check the reference https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
Check the installation succeed
which aws
/usr/local/bin/aws
aws --version
aws-cli/2.4.5 Python/3.8.8 Darwin/18.7.0 botocore/2.4.5
Rename version 1 and install the new version
which aws
/usr/local/bin/aws
mv /usr/local/bin/aws /usr/local/bin/aws1
#Β then follow the steps of previous section
aws configure
β ~ aws configure
AWS Access Key ID [****************XXXXX]:
AWS Secret Access Key [****************+XXXXX]:
Default region name [us-east-1]:
Default output format [json]:
β ~
cd packages/demo-app
npm run build
const app = new cdk.App();
new DemoAppStack(app, 'DemoAppStack', {
/* If you don't specify 'env', this stack will be environment-agnostic.
* Account/Region-dependent features and context lookups will not work,
* but a single synthesized template can be deployed anywhere. */
/* Uncomment the next line to specialize this stack for the AWS Account
* and Region that are implied by the current CLI configuration. */
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
/* Uncomment the next line if you know exactly what Account and Region you
* want to deploy the stack to. */
// env: { account: '123456789012', region: 'us-east-1' },
/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */
});
export CDK_DEFAULT_ACCOUNT=XXXXXXX
export CDK_DEFAULT_REGION=us-east-1
β demo-app git:(develop) β npm run cdk-bootstrap
> @tkssharma/demo-app@0.1.0 cdk-bootstrap
> cdk bootstrap
β³ Bootstrapping environment aws://146050578321/us-east-1...
β demo-app git:(develop) β npm run cdk-deploy
> @tkssharma/demo-app@0.1.0 cdk-deploy
> cdk deploy
β¨ Synthesis time: 2.33s
DemoAppStack: building assets...
Run nx graph
to see a diagram of the dependencies of the projects.
Run npx nx connect-to-nx-cloud
to enable remote caching and make CI faster.
Visit the Nx Documentation to learn more.