diff --git a/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts b/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts index bd97490845cc2..097599934c060 100644 --- a/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts +++ b/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts @@ -105,7 +105,7 @@ describe('new style synthesis', () => { }); - test('can set session tags on default stack synthesizer', () => { + test('can set role additional options tags on default stack synthesizer', () => { // GIVEN stack = new Stack(app, 'SessionTagsStack', { synthesizer: new DefaultStackSynthesizer({ @@ -122,6 +122,9 @@ describe('new style synthesis', () => { Tags: [{ Key: 'Department', Value: 'Engineering-LookupRoleTag' }], }, }), + env: { + account: '111111111111', region: 'us-east-1', + }, }); stack.synthesizer.addFileAsset({ @@ -135,9 +138,15 @@ describe('new style synthesis', () => { sourceHash: 'dockerHash', }); + ContextProvider.getValue(stack, { + provider: cxschema.ContextProvider.VPC_PROVIDER, + props: {}, + dummyValue: undefined, + }).value; + // THEN const asm = app.synth(); - const manifest = app.synth().getStackByName('SessionTagsStack').manifest; + const manifest = asm.getStackByName('SessionTagsStack').manifest; // Validates that the deploy and lookup role session tags were set in the Manifest: expect((manifest.properties as cxschema.AwsCloudFormationStackProperties).assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-DeployRoleTag' }]); expect((manifest.properties as cxschema.AwsCloudFormationStackProperties).lookupRole?.assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-LookupRoleTag' }]); @@ -148,6 +157,10 @@ describe('new style synthesis', () => { // Validates that the image and file asset session tags were set in the asset manifest: expect(assetManifestJSON.dockerImages?.dockerHash.destinations['current_account-current_region'].assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-ImageAssetTag' }]); expect(assetManifestJSON.files?.fileHash.destinations['current_account-current_region'].assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-FileAssetTag' }]); + + // assert that lookup role options are added to the missing lookup context + expect(asm.manifest.missing![0].props.assumeRoleAdditionalOptions).toEqual({}); + }); test('customize version parameter', () => { @@ -233,6 +246,29 @@ describe('new style synthesis', () => { }); + test('generates missing context with the lookup role external id as one of the missing context properties', () => { + // GIVEN + stack = new Stack(app, 'Stack2', { + synthesizer: new DefaultStackSynthesizer({ + generateBootstrapVersionRule: false, + lookupRoleExternalId: 'External', + }), + env: { + account: '111111111111', region: 'us-east-1', + }, + }); + ContextProvider.getValue(stack, { + provider: cxschema.ContextProvider.VPC_PROVIDER, + props: {}, + dummyValue: undefined, + }).value; + + // THEN + const assembly = app.synth(); + expect(assembly.manifest.missing![0].props.lookupRoleExternalId).toEqual('External'); + + }); + test('nested Stack uses the lookup role ARN of the parent stack', () => { // GIVEN const myapp = new App();