This is how to properly select AWS CLI profiles for your stacks/accounts #3961
Labels
management/devenv
Related to CDK development/build environment
management/tracking
Issues that track a subject or multiple issues
ops-excellence
Operational Excellence
package/tools
Related to AWS CDK Tools or CLI
There are various discussions here about how to use select the appropriate CLI profiles. I have not found any suitable solution until now.
In particular,
AWS_PROFILE
wasn't enough since cdk needs to make calls in different accounts for different stacks.I wanted a solution that could:
The trick is to use the plugin feature which really means just a javascript class.
You can define a class which will be loaded at runtime. It allows you to pick some profile for a certain account ID.
Here is the gist and an example cdk.json:
https://gist.github.com/jeshan/178dfa811df0f652b30d3cc61058512d/
Note that you can also specify plugins with:
cdk --plugin ... deploy
I'm leaving this here as a how-to for the community. Feel free to copy the class into your project.
If anybody knows of a simpler way to achieve this, please let me know.
The text was updated successfully, but these errors were encountered: