I don't want to use my default aws profile and account for cdk development
So I created a new account and a new profile cdkprof
using aws configure --profile cdkprof
.
I have verified in ~/.aws/credentials
and ~/.aws/config
files that the new profile created correctly. running export AWS_PROFILE=cdkprof && aws configure list && aws sts get-caller-identity
returns me my profile details correctly.
I have also exported
and these are available as environment variables in bash.
However when I try to run :
$ npx cdk bootstrap --profile cdkprof
I get the error
Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment
How do I use my new profile and account with the cdk commands?
Thanks.
Bootstrapping is the process of provisioning resources for the AWS CDK before you can deploy AWS CDK apps into an AWS environment. (An AWS environment is a combination of an AWS account and Region).
The AWS CDK Toolkit, the CLI command cdk , is the primary tool for interacting with your AWS CDK app. It executes your app, interrogates the application model you defined, and produces and deploys the AWS CloudFormation templates generated by the AWS CDK.
By default, CDK commands will use the default AWS CLI profile. However, you can specify a named profile for a project by adding it to the file which handles CDK commands. For a TypeScript project, this is done in cdk.json
at the project root:
{
"app": "npx ts-node --prefer-ts-exts bin/project.ts",
"profile": "cdkprof",
"context": {
...
}
}
Then, your named profile will be used when you run commands such as cdk bootstrap
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With