const envs:any = {
dev: { region: 'eu-west-1', account: 'xxx' },
production: { region: 'eu-west-1', account: 'yyy' },
};
class MyApp extends cdk.Construct {
constructor(scope:any, id:any, props:any ) {
super(scope, id);
new OurStack1(this, 'ourstack1', { env: props.env, stackName: `${id}-ourstack1` });
new OurStack2(this, 'ourstack2', { env: props.env, stackName: `${id}-ourstack1` });
// ..
}
}
const app = new cdk.App();
Object.entries(envs).forEach(([envName, env]) => {
new MyApp(app, envName, { env });
});
> cdk list
dev-ourstack1
dev-ourstack2
production-ourstack1
production-ourstack2
See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html
Thanks - have updated accordingly