Skip to content

Commit 46b8e6c

Browse files
authored
Merge branch 'main' into docs/supplement-for-build-error
2 parents 9692046 + a9e2789 commit 46b8e6c

5 files changed

Lines changed: 45 additions & 2 deletions

File tree

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/bootstrapping.integtest.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ integTest('can use the custom permissions boundary to bootstrap', withoutBootstr
255255
expect(template).toContain('permission-boundary-name');
256256
}));
257257

258+
integTest('can use the custom permissions boundary (with slashes) to bootstrap', withoutBootstrap(async (fixture) => {
259+
let template = await fixture.cdkBootstrapModern({
260+
// toolkitStackName doesn't matter for this particular invocation
261+
toolkitStackName: fixture.bootstrapStackName,
262+
showTemplate: true,
263+
customPermissionsBoundary: 'permission-boundary-name/with/path',
264+
});
265+
266+
expect(template).toContain('permission-boundary-name/with/path');
267+
}));
268+
258269
integTest('can remove customPermissionsBoundary', withoutBootstrap(async (fixture) => {
259270
const bootstrapStackName = fixture.bootstrapStackName;
260271
const policyName = `${bootstrapStackName}-pb`;

packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ export class Bootstrapper {
279279

280280
private validatePolicyName(permissionsBoundary: string) {
281281
// https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicy.html
282-
const regexp: RegExp = /[\w+=,.@-]+/;
282+
// Added support for policy names with a path
283+
// See https://github.com/aws/aws-cdk/issues/26320
284+
const regexp: RegExp = /[\w+\/=,.@-]+/;
283285
const matches = regexp.exec(permissionsBoundary);
284286
if (!(matches && matches.length === 1 && matches[0] === permissionsBoundary)) {
285287
throw new Error(`The permissions boundary name ${permissionsBoundary} does not match the IAM conventions.`);

packages/aws-cdk/lib/cdk-toolkit.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export class CdkToolkit {
143143
}
144144
}
145145

146+
stream.write(format('\n✨ Number of stacks with differences: %s\n', diffs));
147+
146148
return diffs && options.fail ? 1 : 0;
147149
}
148150

packages/aws-cdk/test/api/bootstrap2.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,28 @@ describe('Bootstrapping v2', () => {
207207
]));
208208
});
209209

210+
test('adding permission boundary with path in policy name', async () => {
211+
mockTheToolkitInfo({
212+
Parameters: [
213+
{
214+
ParameterKey: 'InputPermissionsBoundary',
215+
ParameterValue: '',
216+
},
217+
],
218+
});
219+
await bootstrapper.bootstrapEnvironment(env, sdk, {
220+
parameters: {
221+
customPermissionsBoundary: 'permissions-boundary-name/with/path',
222+
},
223+
});
224+
225+
expect(stderrMock.mock.calls).toEqual(expect.arrayContaining([
226+
expect.arrayContaining([
227+
expect.stringMatching(/Adding new permissions boundary permissions-boundary-name\/with\/path/),
228+
]),
229+
]));
230+
});
231+
210232
test('passing trusted accounts without CFN managed policies results in an error', async () => {
211233
await expect(bootstrapper.bootstrapEnvironment(env, sdk, {
212234
parameters: {

packages/aws-cdk/test/diff.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe('non-nested stacks', () => {
8181
expect(plainTextOutput).toContain('Stack A');
8282
expect(plainTextOutput).toContain('Stack B');
8383

84+
expect(buffer.data.trim()).toContain('✨ Number of stacks with differences: 2');
8485
expect(exitCode).toBe(0);
8586
});
8687

@@ -96,6 +97,7 @@ describe('non-nested stacks', () => {
9697
});
9798

9899
// THEN
100+
expect(buffer.data.trim()).toContain('✨ Number of stacks with differences: 1');
99101
expect(exitCode).toBe(1);
100102
});
101103

@@ -121,6 +123,7 @@ describe('non-nested stacks', () => {
121123
});
122124

123125
// THEN
126+
expect(buffer.data.trim()).toContain('✨ Number of stacks with differences: 1');
124127
expect(exitCode).toBe(1);
125128
});
126129

@@ -255,7 +258,10 @@ Resources
255258
└─ [~] .Properties:
256259
└─ [~] .Prop:
257260
├─ [-] old-value
258-
└─ [+] new-value`);
261+
└─ [+] new-value
262+
263+
264+
✨ Number of stacks with differences: 3`);
259265

260266
expect(exitCode).toBe(0);
261267
});

0 commit comments

Comments
 (0)