Skip to content

Commit 2d1e47f

Browse files
authored
feat: fix issue with many stacks and parallelize bootstrap
1 parent 51be045 commit 2d1e47f

File tree

12 files changed

+408
-388
lines changed

12 files changed

+408
-388
lines changed

.projen/deps.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const project = new awscdk.AwsCdkConstructLibrary({
5353
],
5454
/* Runtime dependencies of this module that are NOT jsii-enabled. */
5555
bundledDeps: [
56-
5756
'@aws-sdk/client-sts',
5857
'@aws-sdk/credential-providers',
5958
'@aws-sdk/client-cost-explorer',

API.md

Lines changed: 150 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/content/docs/getting-started.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ for more information.
8080
[Tagging](/components/account-management/tagging) for details.
8181
5. **AWS Organization**: Provide details about your AWS Organization, including the Organization ID, OU IDs, and
8282
Account IDs. Copy the IDs of accounts created by Control Tower, such as the management, security log, and security
83-
audit accounts. Additional accounts can be created manually or moved under the Workloads OU. For more details, see
84-
[AWS Organization](/components/account-management/aws-organization). In the code snippet below, we define a single
85-
development account.
83+
audit accounts. Additional accounts can be created manually or moved under the Workloads OU.. In the code snippet
84+
below, we define a single development account.
8685

8786
<DualCode>
8887
<Fragment slot="ts">

docs/src/content/docs/reference/api.md

Lines changed: 150 additions & 165 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
npm uninstall cdk-express-pipeline
2+
npm link cdk-express-pipeline

package-lock.json

Lines changed: 21 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/scripts/bootstrap/index.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DataLandingZoneProps, DlzAllRegions } from '../../data-landing-zone-types';
22
import { assumeRole, runCommand } from '../lib/helpers';
3+
import { synth } from '../synth';
34

45
const tags = '--tags Owner=infra --tags Project=dlz --tags Environment=dlz';
56

@@ -13,6 +14,7 @@ async function bootstrapChildAccount(props: DataLandingZoneProps, bootstrapRoleN
1314
`--trust ${props.organization.root.accounts.management.accountId}`,
1415
tags,
1516
`aws://${accountId}/${region}`,
17+
'--app cdk.out',
1618
].join(' '),
1719
{
1820
env: {
@@ -22,34 +24,56 @@ async function bootstrapChildAccount(props: DataLandingZoneProps, bootstrapRoleN
2224
AWS_SECRET_ACCESS_KEY: accountCreds.SecretAccessKey!,
2325
AWS_SESSION_TOKEN: accountCreds.SessionToken!,
2426
},
25-
});
27+
},
28+
`(${region}) `);
29+
}
30+
31+
let bootstrapSynthed = false;
32+
async function synthOnce(props: DataLandingZoneProps) {
33+
if (!bootstrapSynthed) {
34+
bootstrapSynthed = true;
35+
await synth(props);
36+
}
2637
}
2738

2839
async function management(props: DataLandingZoneProps) {
40+
await synthOnce(props);
2941
await runCommand('cdk', [
3042
'bootstrap',
3143
'--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess',
3244
`--profile ${props.localProfile}`,
3345
tags,
3446
`aws://${props.organization.root.accounts.management.accountId}/${props.regions.global}`,
47+
'--app cdk.out',
3548
].join(' '));
3649
}
3750
async function log(props: DataLandingZoneProps, bootstrapRoleName: string = 'AWSControlTowerExecution') {
51+
await synthOnce(props);
52+
53+
const regionBootStrapPromises = [];
3854
for (let region of DlzAllRegions(props.regions)) {
39-
await bootstrapChildAccount(props, bootstrapRoleName, props.organization.ous.security.accounts.log.accountId, region);
55+
regionBootStrapPromises.push(bootstrapChildAccount(props, bootstrapRoleName, props.organization.ous.security.accounts.log.accountId, region));
4056
}
57+
await Promise.all(regionBootStrapPromises);
4158
}
4259
async function audit(props: DataLandingZoneProps, bootstrapRoleName: string = 'AWSControlTowerExecution') {
60+
await synthOnce(props);
61+
62+
const regionBootStrapPromises = [];
4363
for (let region of DlzAllRegions(props.regions)) {
44-
await bootstrapChildAccount(props, bootstrapRoleName, props.organization.ous.security.accounts.audit.accountId, region);
64+
regionBootStrapPromises.push(bootstrapChildAccount(props, bootstrapRoleName, props.organization.ous.security.accounts.audit.accountId, region));
4565
}
66+
await Promise.all(regionBootStrapPromises);
4667
}
47-
4868
async function workloadAccounts(props: DataLandingZoneProps, bootstrapRoleName: string = 'AWSControlTowerExecution') {
69+
await synthOnce(props);
70+
4971
for (const account of props.organization.ous.workloads.accounts) {
72+
const regionBootStrapPromises = [];
5073
for (let region of DlzAllRegions(props.regions)) {
51-
await bootstrapChildAccount(props, bootstrapRoleName, account.accountId, region);
74+
regionBootStrapPromises.push(bootstrapChildAccount(props, bootstrapRoleName, account.accountId, region));
5275
}
76+
await Promise.all(regionBootStrapPromises);
5377
}
5478
}
5579

0 commit comments

Comments
 (0)