PacktPublishing / AWS-CDK-in-Practice

AWS CDK in Practice, published by Packt
MIT License
53 stars 55 forks source link

aws region hard coded us-east-1 #4

Open lsdeva opened 1 year ago

lsdeva commented 1 year ago

Let CDK default region to AWS CLI profile default region.

rajat-packt commented 1 year ago

Hey @lsdeva,

To set the AWS CDK default region to the AWS CLI profile default region, you can use the environment variables provided by the AWS CDK CLI: CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION. These variables are set based on the AWS profile specified using the --profile option, or the default AWS profile if you don’t specify one.

Here is an example of how you can set it:

export CDK_DEFAULT_REGION=$(aws configure get region)

This command will set the CDK_DEFAULT_REGION environment variable to the default region of your current AWS CLI profile.

In chapter 4, This can be changed by changing the value for region to:

region: process.env.CDK_DEFAULT_REGION

in line 10 of the file located at: chapter-4-complete-web-application-deployment-with-aws-cdk/infrastructure/bin/chapter-4.ts

totterman commented 10 months ago

Better not change the default region from us-east-1, otherwise you will have a mountain of trouble working out the TLS certificates that have to reside in us-east-1 for CloudFront to work.