From d76c8105d0a1d498ae7bcb215cf6dc51f6403045 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Tue, 5 Dec 2023 14:45:33 -0500 Subject: [PATCH 1/3] fix(appconfig): extensions always create cdk diff --- .../aws-appconfig-alpha/lib/application.ts | 2 +- .../aws-appconfig-alpha/lib/configuration.ts | 4 +- .../aws-appconfig-alpha/lib/environment.ts | 2 +- .../aws-appconfig-alpha/lib/extension.ts | 42 +- .../test/application.test.ts | 90 ++- .../test/extension.test.ts | 52 +- .../aws-appconfig-extension.assets.json | 6 +- .../aws-appconfig-extension.template.json | 411 +++++++---- ...efaultTestDeployAssert64BA6C4E.assets.json | 2 +- .../test/integ.extension.js.snapshot/cdk.out | 2 +- .../integ.extension.js.snapshot/integ.json | 2 +- .../integ.extension.js.snapshot/manifest.json | 66 +- .../integ.extension.js.snapshot/tree.json | 654 ++++++++++++------ .../test/integ.extension.ts | 4 - 14 files changed, 879 insertions(+), 460 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/application.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/application.ts index cd6eb38adcbb2..27b38f506b571 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/application.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/application.ts @@ -352,7 +352,7 @@ export class Application extends ApplicationBase { resourceName: this.applicationId, }); - this.extensible = new ExtensibleBase(scope, this.applicationArn, this.name); + this.extensible = new ExtensibleBase(this, this.applicationArn, this.name); } } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts index de9f661b5c488..d9924984f5561 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts @@ -445,7 +445,7 @@ export class HostedConfiguration extends ConfigurationBase { resource: 'application', resourceName: `${this.applicationId}/configurationprofile/${this.configurationProfileId}`, }); - this.extensible = new ExtensibleBase(scope, this.configurationProfileArn, this.name); + this.extensible = new ExtensibleBase(this, this.configurationProfileArn, this.name); this.content = props.content.content; this.contentType = props.content.contentType; @@ -607,7 +607,7 @@ export class SourcedConfiguration extends ConfigurationBase { resource: 'application', resourceName: `${this.applicationId}/configurationprofile/${this.configurationProfileId}`, }); - this.extensible = new ExtensibleBase(scope, this.configurationProfileArn, this.name); + this.extensible = new ExtensibleBase(this, this.configurationProfileArn, this.name); this.addExistingEnvironmentsToApplication(); this.deployConfigToEnvironments(); diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index c77bbe8975106..4a646a9ecaed0 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -269,7 +269,7 @@ export class Environment extends EnvironmentBase { resource: 'application', resourceName: `${this.applicationId}/environment/${this.environmentId}`, }); - this.extensible = new ExtensibleBase(scope, this.environmentArn, this.name); + this.extensible = new ExtensibleBase(this, this.environmentArn, this.name); this.application.addExistingEnvironment(this); } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts index 3f21307843370..02baa27500d8c 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts @@ -75,6 +75,12 @@ export class LambdaDestination implements IEventDestination { this.policyDocument = new iam.PolicyDocument({ statements: [policy], }); + + if (!func.permissionsNode.tryFindChild('AppConfigPermission')) { + func.addPermission('AppConfigPermission', { + principal: new iam.ServicePrincipal('appconfig.amazonaws.com'), + }); + } } } @@ -500,21 +506,19 @@ export class Extension extends Resource implements IExtension { this.parameters = props.parameters; const resource = new CfnExtension(this, 'Resource', { - actions: this.actions.reduce((acc: {[key: string]: {[key: string]: string}[]}, cur: Action) => { + actions: this.actions.reduce((acc: {[key: string]: {[key: string]: string}[]}, cur: Action, index) => { const extensionUri = cur.eventDestination.extensionUri; const sourceType = cur.eventDestination.type; this.executionRole = cur.executionRole; + const name = cur.name ?? `${this.name}-${index}`; cur.actionPoints.forEach((actionPoint) => { acc[actionPoint] = [ { - Name: cur.name || Names.uniqueResourceName(this, { - maxLength: 64, - separator: '-', - }), + Name: name, Uri: extensionUri, ...(sourceType === SourceType.EVENTS || cur.invokeWithoutExecutionRole ? {} - : { RoleArn: this.executionRole?.roleArn || this.getExecutionRole(cur.eventDestination).roleArn }), + : { RoleArn: this.executionRole?.roleArn || this.getExecutionRole(cur.eventDestination, name).roleArn }), ...(cur.description ? { Description: cur.description } : {}), }, ]; @@ -543,8 +547,10 @@ export class Extension extends Resource implements IExtension { }); } - private getExecutionRole(eventDestination: IEventDestination): iam.IRole { - this.executionRole = new iam.Role(this, `Role${getHash(eventDestination.extensionUri)}`, { + private getExecutionRole(eventDestination: IEventDestination, actionName: string): iam.IRole { + const versionNumber = this.latestVersionNumber ? this.latestVersionNumber + 1 : 1; + const combinedObjects = stringifyObjects(this.name, versionNumber, actionName); + this.executionRole = new iam.Role(this, `Role${getHash(combinedObjects)}`, { roleName: PhysicalName.GENERATE_IF_NEEDED, assumedBy: new iam.ServicePrincipal('appconfig.amazonaws.com'), inlinePolicies: { @@ -658,7 +664,12 @@ export class ExtensibleBase implements IExtensible { } private getExtensionForActionPoint(eventDestination: IEventDestination, actionPoint: ActionPoint, options?: ExtensionOptions) { - const extension = new Extension(this.scope, `Extension${this.getExtensionHash(eventDestination, actionPoint, options)}`, { + const name = options?.name || Names.uniqueResourceName(this.scope, { + maxLength: 54, + separator: '-', + }) + '-Extension'; + const versionNumber = options?.latestVersionNumber ? options?.latestVersionNumber + 1 : 1; + const extension = new Extension(this.scope, `Extension${this.getExtensionHash(name, versionNumber)}`, { actions: [ new Action({ eventDestination, @@ -667,16 +678,17 @@ export class ExtensibleBase implements IExtensible { ], }), ], + name, ...(options?.description ? { description: options.description } : {}), ...(options?.latestVersionNumber ? { latestVersionNumber: options.latestVersionNumber } : {}), - ...(options?.name ? { name: options.name } : {}), ...(options?.parameters ? { parameters: options.parameters } : {}), }); this.addExtensionAssociation(extension, options); } private addExtensionAssociation(extension: IExtension, options?: ExtensionOptions) { - new CfnExtensionAssociation(this.scope, `AssociationResource${this.getExtensionAssociationHash(extension)}`, { + const versionNumber = options?.latestVersionNumber ? options?.latestVersionNumber + 1 : 1; + new CfnExtensionAssociation(this.scope, `AssociationResource${this.getExtensionAssociationHash(extension.name!, versionNumber)}`, { extensionIdentifier: extension.extensionId, resourceIdentifier: this.resourceArn, extensionVersionNumber: extension.extensionVersionNumber, @@ -689,14 +701,14 @@ export class ExtensibleBase implements IExtensible { }); } - private getExtensionHash(eventDestination: IEventDestination, actionPoint: ActionPoint, options?: ExtensionOptions) { - const combinedString = stringifyObjects(eventDestination, actionPoint, options); + private getExtensionHash(name: string, versionNumber: number) { + const combinedString = stringifyObjects(name, versionNumber); return getHash(combinedString); } - private getExtensionAssociationHash(extension: IExtension) { + private getExtensionAssociationHash(name: string, versionNumber: number) { const resourceIdentifier = this.resourceName ? this.resourceName : this.resourceArn; - const combinedString = stringifyObjects(resourceIdentifier, extension.name, extension.extensionVersionNumber); + const combinedString = stringifyObjects(resourceIdentifier, name, versionNumber); return getHash(combinedString); } } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/application.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/application.test.ts index a94427b770681..a5c85dad77d95 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/application.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/application.test.ts @@ -64,7 +64,7 @@ describe('appconfig', () => { }); }); - test('pre create hosted configuration version', () => { + test('specifying action point for extensible action on', () => { const stack = new cdk.Stack(); const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { @@ -72,29 +72,26 @@ describe('appconfig', () => { runtime: Runtime.PYTHON_3_7, code: Code.fromInline('# this is my code'), }); - Object.defineProperty(func, 'functionArn', { - value: 'arn:lambda:us-east-1:123456789012:function:my-function', - }); appconfig.on(ActionPoint.ON_DEPLOYMENT_STEP, new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'Extension28486', + Name: 'MyAppConfig-Extension', Actions: { ON_DEPLOYMENT_STEP: [ { - Name: 'Extension28486', - RoleArn: { 'Fn::GetAtt': ['Extension28486RoleFD36712B5D791', 'Arn'] }, - Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, + Uri: { 'Fn::GetAtt': ['MyFunc8A243A2C', 'Arn'] }, }, ], }, }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['Extension28486EB468E25', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['Extension28486EB468E25', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ @@ -122,9 +119,6 @@ describe('appconfig', () => { runtime: Runtime.PYTHON_3_7, code: Code.fromInline('# this is my code'), }); - Object.defineProperty(func, 'functionArn', { - value: 'arn:lambda:us-east-1:123456789012:function:my-function', - }); appconfig.preCreateHostedConfigurationVersion(new LambdaDestination(func), { description: 'This is my description', name: 'MyExtension', @@ -141,9 +135,9 @@ describe('appconfig', () => { Actions: { PRE_CREATE_HOSTED_CONFIGURATION_VERSION: [ { - Name: 'Extension8D9D7', - RoleArn: { 'Fn::GetAtt': ['Extension8D9D7RoleFD367F4FA01C5', 'Arn'] }, - Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionE4CCERole467D69791333F', 'Arn'] }, + Uri: { 'Fn::GetAtt': ['MyFunc8A243A2C', 'Arn'] }, }, ], }, @@ -153,10 +147,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['Extension8D9D75657615A', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionE4CCE34485313', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['Extension8D9D75657615A', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionE4CCE34485313', 'VersionNumber'], }, Parameters: { myparam: 'val', @@ -193,12 +187,12 @@ describe('appconfig', () => { appconfig.preStartDeployment(new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'Extension6253E', + Name: 'MyAppConfig-Extension', Actions: { PRE_START_DEPLOYMENT: [ { - Name: 'Extension6253E', - RoleArn: { 'Fn::GetAtt': ['Extension6253ERoleFD367F586E17D', 'Arn'] }, + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -206,10 +200,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['Extension6253ED4CE66CE', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['Extension6253ED4CE66CE', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ @@ -246,12 +240,12 @@ describe('appconfig', () => { appconfig.onDeploymentStart(new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'ExtensionB65DC', + Name: 'MyAppConfig-Extension', Actions: { ON_DEPLOYMENT_START: [ { - Name: 'ExtensionB65DC', - RoleArn: { 'Fn::GetAtt': ['ExtensionB65DCRoleFD3677AFA6FE0', 'Arn'] }, + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -259,10 +253,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['ExtensionB65DC00D22C6E', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['ExtensionB65DC00D22C6E', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ @@ -296,12 +290,12 @@ describe('appconfig', () => { appconfig.onDeploymentStep(new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'Extension28486', + Name: 'MyAppConfig-Extension', Actions: { ON_DEPLOYMENT_STEP: [ { - Name: 'Extension28486', - RoleArn: { 'Fn::GetAtt': ['Extension28486RoleFD36712B5D791', 'Arn'] }, + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -309,10 +303,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['Extension28486EB468E25', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['Extension28486EB468E25', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ @@ -346,12 +340,12 @@ describe('appconfig', () => { appconfig.onDeploymentComplete(new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'Extension32166', + Name: 'MyAppConfig-Extension', Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'Extension32166', - RoleArn: { 'Fn::GetAtt': ['Extension32166RoleFD367EE1FF117', 'Arn'] }, + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -359,10 +353,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['Extension32166E58405A0', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['Extension32166E58405A0', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ @@ -396,12 +390,12 @@ describe('appconfig', () => { appconfig.onDeploymentBaking(new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'Extension1CAD4', + Name: 'MyAppConfig-Extension', Actions: { ON_DEPLOYMENT_BAKING: [ { - Name: 'Extension1CAD4', - RoleArn: { 'Fn::GetAtt': ['Extension1CAD4RoleFD367FC09E8DE', 'Arn'] }, + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -409,10 +403,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['Extension1CAD47F07C609', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['Extension1CAD47F07C609', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ @@ -446,12 +440,12 @@ describe('appconfig', () => { appconfig.onDeploymentRolledBack(new LambdaDestination(func)); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { - Name: 'ExtensionC8347', + Name: 'MyAppConfig-Extension', Actions: { ON_DEPLOYMENT_ROLLED_BACK: [ { - Name: 'ExtensionC8347', - RoleArn: { 'Fn::GetAtt': ['ExtensionC8347RoleFD36716A1DE61', 'Arn'] }, + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -459,10 +453,10 @@ describe('appconfig', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { ExtensionIdentifier: { - 'Fn::GetAtt': ['ExtensionC83470CE85F6C', 'Id'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], }, ExtensionVersionNumber: { - 'Fn::GetAtt': ['ExtensionC83470CE85F6C', 'VersionNumber'], + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], }, ResourceIdentifier: { 'Fn::Join': [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts index 7be5ace16bc12..4bef613850bbf 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts @@ -28,9 +28,6 @@ describe('extension', () => { code: lambda.Code.fromInline('# dummy func'), handler: 'index.handler', }); - Object.defineProperty(func, 'functionArn', { - value: 'arn:lambda:us-east-1:123456789012:function:my-function', - }); new Extension(stack, 'MyExtension', { actions: [ new Action({ @@ -48,16 +45,16 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleFD367BEA2AE12', 'Arn'] }, - Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, + Uri: { 'Fn::GetAtt': ['MyFunction3BAA72D1', 'Arn'] }, }, ], ON_DEPLOYMENT_ROLLED_BACK: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleFD367BEA2AE12', 'Arn'] }, - Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, + Uri: { 'Fn::GetAtt': ['MyFunction3BAA72D1', 'Arn'] }, }, ], }, @@ -69,7 +66,7 @@ describe('extension', () => { Statement: [ { Effect: Effect.ALLOW, - Resource: 'arn:lambda:us-east-1:123456789012:function:my-function', + Resource: { 'Fn::GetAtt': ['MyFunction3BAA72D1', 'Arn'] }, Action: [ 'lambda:InvokeFunction', 'lambda:InvokeAsync', @@ -123,15 +120,15 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleFD367BEA2AE12', 'Arn'] }, + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], ON_DEPLOYMENT_ROLLED_BACK: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRole78071F4E7B10A', 'Arn'] }, + Name: 'MyExtension-1', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleBE614F182C70A', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-diff-function', }, ], @@ -214,8 +211,8 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleFD367BEA2AE12', 'Arn'] }, + Name: 'TestExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleCA98491716207', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -300,7 +297,7 @@ describe('extension', () => { { Description: 'This is my action description', Name: 'ActionTestName', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleC3C234A0DDBAB', 'Arn'] }, + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole76B022BC4F2BC', 'Arn'] }, Uri: 'arn:sqs:us-east-1:123456789012:my-queue', }, ], @@ -346,8 +343,8 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_BAKING: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRole600FCFE1621BF', 'Arn'] }, + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, Uri: 'arn:sns:us-east-1:123456789012:my-topic', }, ], @@ -393,7 +390,7 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_BAKING: [ { - Name: 'MyExtension', + Name: 'MyExtension-0', Uri: 'arn:aws:events:us-east-1:123456789012:event-bus/aws.partner/PartnerName/acct1/repo1', }, ], @@ -431,8 +428,8 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleFD367BEA2AE12', 'Arn'] }, + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -516,8 +513,8 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyExtensionRoleFD367BEA2AE12', 'Arn'] }, + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], @@ -582,6 +579,9 @@ describe('extension', () => { const role = new Role(stack, 'MyRole', { assumedBy: new ServicePrincipal('appconfig.amazonaws.com'), }); + Object.defineProperty(role, 'roleArn', { + value: 'arn:iam::123456789012:role/my-role', + }); new Extension(stack, 'MyExtension', { actions: [ new Action({ @@ -599,8 +599,8 @@ describe('extension', () => { Actions: { ON_DEPLOYMENT_COMPLETE: [ { - Name: 'MyExtension', - RoleArn: { 'Fn::GetAtt': ['MyRoleF48FFE04', 'Arn'] }, + Name: 'MyExtension-0', + RoleArn: 'arn:iam::123456789012:role/my-role', Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', }, ], diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json index 8336092ae5e5a..01f0d93290980 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json @@ -1,7 +1,7 @@ { - "version": "32.0.0", + "version": "35.0.0", "files": { - "1b3fd18c823d863a4f13c60e5b79b85a1c059750ecd97aef1f9ea43c85d23de0": { + "02bbe1ffe7441a077ae005cb5c2021e9fa0695eaf317fee128db4b28b2919512": { "source": { "path": "aws-appconfig-extension.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "1b3fd18c823d863a4f13c60e5b79b85a1c059750ecd97aef1f9ea43c85d23de0.json", + "objectKey": "02bbe1ffe7441a077ae005cb5c2021e9fa0695eaf317fee128db4b28b2919512.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json index 9da058b2463bc..b9f858767e182 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json @@ -50,52 +50,26 @@ "MyFunctionServiceRole3C357FF2" ] }, - "MyApplication5C63EC1D": { - "Type": "AWS::AppConfig::Application", - "Properties": { - "Name": "AppForExtensionTest" - } - }, - "MyApplicationMyEnv55DE3293": { - "Type": "AWS::AppConfig::Environment", + "MyFunctionAppConfigPermission673BEA35": { + "Type": "AWS::Lambda::Permission", "Properties": { - "ApplicationId": { - "Ref": "MyApplication5C63EC1D" + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] }, - "Name": "awsappconfigextension-MyApplication-MyEnv-0FA5092F" + "Principal": "appconfig.amazonaws.com" } }, - "MyLambdaExtensionAFA1476A": { - "Type": "AWS::AppConfig::Extension", + "MyApplication5C63EC1D": { + "Type": "AWS::AppConfig::Application", "Properties": { - "Actions": { - "PRE_CREATE_HOSTED_CONFIGURATION_VERSION": [ - { - "Name": "awsappconfigextension-MyLambdaExtension-68C15290", - "Uri": { - "Fn::GetAtt": [ - "MyFunction3BAA72D1", - "Arn" - ] - } - } - ], - "ON_DEPLOYMENT_START": [ - { - "Name": "awsappconfigextension-MyLambdaExtension-68C15290", - "Uri": { - "Fn::GetAtt": [ - "MyFunction3BAA72D1", - "Arn" - ] - } - } - ] - }, - "Name": "awsappconfigextension-MyLambdaExtension-68C15290" + "Name": "AppForExtensionTest" } }, - "AssociationResource3FA55": { + "MyApplicationAssociationResource3FA55E02ED1FB": { "Type": "AWS::AppConfig::ExtensionAssociation", "Properties": { "ExtensionIdentifier": { @@ -135,31 +109,7 @@ } } }, - "MyQueueE6CA6235": { - "Type": "AWS::SQS::Queue", - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "MyQueueExtension872C5D27": { - "Type": "AWS::AppConfig::Extension", - "Properties": { - "Actions": { - "ON_DEPLOYMENT_START": [ - { - "Name": "awsappconfigextension-MyQueueExtension-EF6112FA", - "Uri": { - "Fn::GetAtt": [ - "MyQueueE6CA6235", - "Arn" - ] - } - } - ] - }, - "Name": "awsappconfigextension-MyQueueExtension-EF6112FA" - } - }, - "AssociationResourceBAC86": { + "MyApplicationAssociationResourceBAC86D18B66DB": { "Type": "AWS::AppConfig::ExtensionAssociation", "Properties": { "ExtensionIdentifier": { @@ -199,40 +149,64 @@ } } }, - "MyTopic86869434": { - "Type": "AWS::SNS::Topic" - }, - "MyTopicExtension9B6DF691": { - "Type": "AWS::AppConfig::Extension", + "MyApplicationAssociationResource7F3E1F71FC034": { + "Type": "AWS::AppConfig::ExtensionAssociation", "Properties": { - "Actions": { - "ON_DEPLOYMENT_START": [ - { - "Name": "awsappconfigextension-MyTopicExtension-37440DA2", - "Uri": { - "Ref": "MyTopic86869434" - } - } + "ExtensionIdentifier": { + "Fn::GetAtt": [ + "MyTopicExtension9B6DF691", + "Id" ] }, - "Name": "awsappconfigextension-MyTopicExtension-37440DA2" + "ExtensionVersionNumber": { + "Fn::GetAtt": [ + "MyTopicExtension9B6DF691", + "VersionNumber" + ] + }, + "ResourceIdentifier": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":appconfig:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":application/", + { + "Ref": "MyApplication5C63EC1D" + } + ] + ] + } } }, - "AssociationResource7F3E1": { + "MyApplicationAssociationResource689DE159F9BFC": { "Type": "AWS::AppConfig::ExtensionAssociation", "Properties": { "ExtensionIdentifier": { "Fn::GetAtt": [ - "MyTopicExtension9B6DF691", + "MyEventBusExtensionADFE2273", "Id" ] }, "ExtensionVersionNumber": { "Fn::GetAtt": [ - "MyTopicExtension9B6DF691", + "MyEventBusExtensionADFE2273", "VersionNumber" ] }, + "Parameters": { + "testParam": "true" + }, "ResourceIdentifier": { "Fn::Join": [ "", @@ -258,6 +232,223 @@ } } }, + "MyApplicationMyEnv55DE3293": { + "Type": "AWS::AppConfig::Environment", + "Properties": { + "ApplicationId": { + "Ref": "MyApplication5C63EC1D" + }, + "Name": "awsappconfigextension-MyApplication-MyEnv-0FA5092F" + } + }, + "MyLambdaExtensionRoleBC958D3F13B04": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "lambda:InvokeAsync", + "lambda:InvokeFunction" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "AllowAppConfigInvokeExtensionEventSourcePolicy" + } + ] + } + }, + "MyLambdaExtensionAFA1476A": { + "Type": "AWS::AppConfig::Extension", + "Properties": { + "Actions": { + "PRE_CREATE_HOSTED_CONFIGURATION_VERSION": [ + { + "Name": "awsappconfigextension-MyLambdaExtension-68C15290-0", + "Uri": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyLambdaExtensionRoleBC958D3F13B04", + "Arn" + ] + } + } + ], + "ON_DEPLOYMENT_START": [ + { + "Name": "awsappconfigextension-MyLambdaExtension-68C15290-0", + "Uri": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyLambdaExtensionRoleBC958D3F13B04", + "Arn" + ] + } + } + ] + }, + "Name": "awsappconfigextension-MyLambdaExtension-68C15290" + } + }, + "MyQueueE6CA6235": { + "Type": "AWS::SQS::Queue", + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "MyQueueExtensionRole63F1970B4A7A6": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": "sqs:SendMessage", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "MyQueueE6CA6235", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "AllowAppConfigInvokeExtensionEventSourcePolicy" + } + ] + } + }, + "MyQueueExtension872C5D27": { + "Type": "AWS::AppConfig::Extension", + "Properties": { + "Actions": { + "ON_DEPLOYMENT_START": [ + { + "Name": "awsappconfigextension-MyQueueExtension-EF6112FA-0", + "Uri": { + "Fn::GetAtt": [ + "MyQueueE6CA6235", + "Arn" + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyQueueExtensionRole63F1970B4A7A6", + "Arn" + ] + } + } + ] + }, + "Name": "awsappconfigextension-MyQueueExtension-EF6112FA" + } + }, + "MyTopic86869434": { + "Type": "AWS::SNS::Topic" + }, + "MyTopicExtensionRole39BF2474FECA3": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": "sns:Publish", + "Effect": "Allow", + "Resource": { + "Ref": "MyTopic86869434" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "AllowAppConfigInvokeExtensionEventSourcePolicy" + } + ] + } + }, + "MyTopicExtension9B6DF691": { + "Type": "AWS::AppConfig::Extension", + "Properties": { + "Actions": { + "ON_DEPLOYMENT_START": [ + { + "Name": "awsappconfigextension-MyTopicExtension-37440DA2-0", + "Uri": { + "Ref": "MyTopic86869434" + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyTopicExtensionRole39BF2474FECA3", + "Arn" + ] + } + } + ] + }, + "Name": "awsappconfigextension-MyTopicExtension-37440DA2" + } + }, "MyEventBusExtensionADFE2273": { "Type": "AWS::AppConfig::Extension", "Properties": { @@ -300,49 +491,6 @@ } } }, - "AssociationResource689DE": { - "Type": "AWS::AppConfig::ExtensionAssociation", - "Properties": { - "ExtensionIdentifier": { - "Fn::GetAtt": [ - "MyEventBusExtensionADFE2273", - "Id" - ] - }, - "ExtensionVersionNumber": { - "Fn::GetAtt": [ - "MyEventBusExtensionADFE2273", - "VersionNumber" - ] - }, - "Parameters": { - "testParam": "true" - }, - "ResourceIdentifier": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":appconfig:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":application/", - { - "Ref": "MyApplication5C63EC1D" - } - ] - ] - } - } - }, "MyDeployStrategy062CAEA2": { "Type": "AWS::AppConfig::DeploymentStrategy", "Properties": { @@ -365,8 +513,11 @@ "DependsOn": [ "MyEventBusExtensionADFE2273", "MyLambdaExtensionAFA1476A", + "MyLambdaExtensionRoleBC958D3F13B04", "MyQueueExtension872C5D27", - "MyTopicExtension9B6DF691" + "MyQueueExtensionRole63F1970B4A7A6", + "MyTopicExtension9B6DF691", + "MyTopicExtensionRole39BF2474FECA3" ] }, "HostedConfiguration257746B4": { @@ -384,8 +535,11 @@ "DependsOn": [ "MyEventBusExtensionADFE2273", "MyLambdaExtensionAFA1476A", + "MyLambdaExtensionRoleBC958D3F13B04", "MyQueueExtension872C5D27", - "MyTopicExtension9B6DF691" + "MyQueueExtensionRole63F1970B4A7A6", + "MyTopicExtension9B6DF691", + "MyTopicExtensionRole39BF2474FECA3" ], "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" @@ -412,8 +566,11 @@ "DependsOn": [ "MyEventBusExtensionADFE2273", "MyLambdaExtensionAFA1476A", + "MyLambdaExtensionRoleBC958D3F13B04", "MyQueueExtension872C5D27", - "MyTopicExtension9B6DF691" + "MyQueueExtensionRole63F1970B4A7A6", + "MyTopicExtension9B6DF691", + "MyTopicExtensionRole39BF2474FECA3" ] } }, diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json index 635d1e188e6e3..d235322fb9ff1 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "35.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/cdk.out b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/cdk.out index f0b901e7c06e5..c5cb2e5de6344 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/integ.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/integ.json index f615688162cdc..c7a092c06e3cc 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "35.0.0", "testCases": { "aws-appconfig-extension/MyApplication/appconfig-extension/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/manifest.json index e5aeb013fdaa8..f259850222e03 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "35.0.0", "artifacts": { "awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets": { "type": "cdk:asset-manifest", @@ -14,6 +14,7 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.template.json", + "terminationProtection": false, "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", @@ -61,10 +62,11 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "aws-appconfig-extension.template.json", + "terminationProtection": false, "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/1b3fd18c823d863a4f13c60e5b79b85a1c059750ecd97aef1f9ea43c85d23de0.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/02bbe1ffe7441a077ae005cb5c2021e9fa0695eaf317fee128db4b28b2919512.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -92,28 +94,58 @@ "data": "MyFunction3BAA72D1" } ], + "/aws-appconfig-extension/MyFunction/AppConfigPermission": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunctionAppConfigPermission673BEA35" + } + ], "/aws-appconfig-extension/MyApplication/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyApplication5C63EC1D" } ], + "/aws-appconfig-extension/MyApplication/AssociationResource3FA55": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApplicationAssociationResource3FA55E02ED1FB" + } + ], + "/aws-appconfig-extension/MyApplication/AssociationResourceBAC86": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApplicationAssociationResourceBAC86D18B66DB" + } + ], + "/aws-appconfig-extension/MyApplication/AssociationResource7F3E1": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApplicationAssociationResource7F3E1F71FC034" + } + ], + "/aws-appconfig-extension/MyApplication/AssociationResource689DE": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApplicationAssociationResource689DE159F9BFC" + } + ], "/aws-appconfig-extension/MyApplication/MyEnv/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyApplicationMyEnv55DE3293" } ], - "/aws-appconfig-extension/MyLambdaExtension/Resource": [ + "/aws-appconfig-extension/MyLambdaExtension/RoleBC958/Resource": [ { "type": "aws:cdk:logicalId", - "data": "MyLambdaExtensionAFA1476A" + "data": "MyLambdaExtensionRoleBC958D3F13B04" } ], - "/aws-appconfig-extension/AssociationResource3FA55": [ + "/aws-appconfig-extension/MyLambdaExtension/Resource": [ { "type": "aws:cdk:logicalId", - "data": "AssociationResource3FA55" + "data": "MyLambdaExtensionAFA1476A" } ], "/aws-appconfig-extension/MyQueue/Resource": [ @@ -122,16 +154,16 @@ "data": "MyQueueE6CA6235" } ], - "/aws-appconfig-extension/MyQueueExtension/Resource": [ + "/aws-appconfig-extension/MyQueueExtension/Role63F19/Resource": [ { "type": "aws:cdk:logicalId", - "data": "MyQueueExtension872C5D27" + "data": "MyQueueExtensionRole63F1970B4A7A6" } ], - "/aws-appconfig-extension/AssociationResourceBAC86": [ + "/aws-appconfig-extension/MyQueueExtension/Resource": [ { "type": "aws:cdk:logicalId", - "data": "AssociationResourceBAC86" + "data": "MyQueueExtension872C5D27" } ], "/aws-appconfig-extension/MyTopic/Resource": [ @@ -140,16 +172,16 @@ "data": "MyTopic86869434" } ], - "/aws-appconfig-extension/MyTopicExtension/Resource": [ + "/aws-appconfig-extension/MyTopicExtension/Role39BF2/Resource": [ { "type": "aws:cdk:logicalId", - "data": "MyTopicExtension9B6DF691" + "data": "MyTopicExtensionRole39BF2474FECA3" } ], - "/aws-appconfig-extension/AssociationResource7F3E1": [ + "/aws-appconfig-extension/MyTopicExtension/Resource": [ { "type": "aws:cdk:logicalId", - "data": "AssociationResource7F3E1" + "data": "MyTopicExtension9B6DF691" } ], "/aws-appconfig-extension/MyEventBusExtension/Resource": [ @@ -158,12 +190,6 @@ "data": "MyEventBusExtensionADFE2273" } ], - "/aws-appconfig-extension/AssociationResource689DE": [ - { - "type": "aws:cdk:logicalId", - "data": "AssociationResource689DE" - } - ], "/aws-appconfig-extension/MyDeployStrategy/Resource": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/tree.json index 578580b4ce0e5..2e6b8c58a9c55 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/tree.json @@ -92,6 +92,27 @@ "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", "version": "0.0.0" } + }, + "AppConfigPermission": { + "id": "AppConfigPermission", + "path": "aws-appconfig-extension/MyFunction/AppConfigPermission", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Permission", + "aws:cdk:cloudformation:props": { + "action": "lambda:InvokeFunction", + "functionName": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + }, + "principal": "appconfig.amazonaws.com" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnPermission", + "version": "0.0.0" + } } }, "constructInfo": { @@ -117,6 +138,201 @@ "version": "0.0.0" } }, + "AssociationResource3FA55": { + "id": "AssociationResource3FA55", + "path": "aws-appconfig-extension/MyApplication/AssociationResource3FA55", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", + "aws:cdk:cloudformation:props": { + "extensionIdentifier": { + "Fn::GetAtt": [ + "MyLambdaExtensionAFA1476A", + "Id" + ] + }, + "extensionVersionNumber": { + "Fn::GetAtt": [ + "MyLambdaExtensionAFA1476A", + "VersionNumber" + ] + }, + "resourceIdentifier": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":appconfig:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":application/", + { + "Ref": "MyApplication5C63EC1D" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "version": "0.0.0" + } + }, + "AssociationResourceBAC86": { + "id": "AssociationResourceBAC86", + "path": "aws-appconfig-extension/MyApplication/AssociationResourceBAC86", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", + "aws:cdk:cloudformation:props": { + "extensionIdentifier": { + "Fn::GetAtt": [ + "MyQueueExtension872C5D27", + "Id" + ] + }, + "extensionVersionNumber": { + "Fn::GetAtt": [ + "MyQueueExtension872C5D27", + "VersionNumber" + ] + }, + "resourceIdentifier": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":appconfig:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":application/", + { + "Ref": "MyApplication5C63EC1D" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "version": "0.0.0" + } + }, + "AssociationResource7F3E1": { + "id": "AssociationResource7F3E1", + "path": "aws-appconfig-extension/MyApplication/AssociationResource7F3E1", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", + "aws:cdk:cloudformation:props": { + "extensionIdentifier": { + "Fn::GetAtt": [ + "MyTopicExtension9B6DF691", + "Id" + ] + }, + "extensionVersionNumber": { + "Fn::GetAtt": [ + "MyTopicExtension9B6DF691", + "VersionNumber" + ] + }, + "resourceIdentifier": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":appconfig:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":application/", + { + "Ref": "MyApplication5C63EC1D" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "version": "0.0.0" + } + }, + "AssociationResource689DE": { + "id": "AssociationResource689DE", + "path": "aws-appconfig-extension/MyApplication/AssociationResource689DE", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", + "aws:cdk:cloudformation:props": { + "extensionIdentifier": { + "Fn::GetAtt": [ + "MyEventBusExtensionADFE2273", + "Id" + ] + }, + "extensionVersionNumber": { + "Fn::GetAtt": [ + "MyEventBusExtensionADFE2273", + "VersionNumber" + ] + }, + "parameters": { + "testParam": "true" + }, + "resourceIdentifier": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":appconfig:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":application/", + { + "Ref": "MyApplication5C63EC1D" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "version": "0.0.0" + } + }, "MyEnv": { "id": "MyEnv", "path": "aws-appconfig-extension/MyApplication/MyEnv", @@ -140,7 +356,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -157,7 +373,7 @@ "path": "aws-appconfig-extension/MyApplication/appconfig-extension/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.3.0" } }, "DeployAssert": { @@ -200,7 +416,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Application", "version": "0.0.0" } }, @@ -208,6 +424,72 @@ "id": "MyLambdaExtension", "path": "aws-appconfig-extension/MyLambdaExtension", "children": { + "RoleBC958": { + "id": "RoleBC958", + "path": "aws-appconfig-extension/MyLambdaExtension/RoleBC958", + "children": { + "ImportRoleBC958": { + "id": "ImportRoleBC958", + "path": "aws-appconfig-extension/MyLambdaExtension/RoleBC958/ImportRoleBC958", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-appconfig-extension/MyLambdaExtension/RoleBC958/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "policies": [ + { + "policyName": "AllowAppConfigInvokeExtensionEventSourcePolicy", + "policyDocument": { + "Statement": [ + { + "Action": [ + "lambda:InvokeAsync", + "lambda:InvokeFunction" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + } + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "aws-appconfig-extension/MyLambdaExtension/Resource", @@ -217,23 +499,35 @@ "actions": { "PRE_CREATE_HOSTED_CONFIGURATION_VERSION": [ { - "Name": "awsappconfigextension-MyLambdaExtension-68C15290", + "Name": "awsappconfigextension-MyLambdaExtension-68C15290-0", "Uri": { "Fn::GetAtt": [ "MyFunction3BAA72D1", "Arn" ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyLambdaExtensionRoleBC958D3F13B04", + "Arn" + ] } } ], "ON_DEPLOYMENT_START": [ { - "Name": "awsappconfigextension-MyLambdaExtension-68C15290", + "Name": "awsappconfigextension-MyLambdaExtension-68C15290-0", "Uri": { "Fn::GetAtt": [ "MyFunction3BAA72D1", "Arn" ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyLambdaExtensionRoleBC958D3F13B04", + "Arn" + ] } } ] @@ -248,55 +542,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "AssociationResource3FA55": { - "id": "AssociationResource3FA55", - "path": "aws-appconfig-extension/AssociationResource3FA55", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", - "aws:cdk:cloudformation:props": { - "extensionIdentifier": { - "Fn::GetAtt": [ - "MyLambdaExtensionAFA1476A", - "Id" - ] - }, - "extensionVersionNumber": { - "Fn::GetAtt": [ - "MyLambdaExtensionAFA1476A", - "VersionNumber" - ] - }, - "resourceIdentifier": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":appconfig:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":application/", - { - "Ref": "MyApplication5C63EC1D" - } - ] - ] - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", "version": "0.0.0" } }, @@ -326,6 +572,69 @@ "id": "MyQueueExtension", "path": "aws-appconfig-extension/MyQueueExtension", "children": { + "Role63F19": { + "id": "Role63F19", + "path": "aws-appconfig-extension/MyQueueExtension/Role63F19", + "children": { + "ImportRole63F19": { + "id": "ImportRole63F19", + "path": "aws-appconfig-extension/MyQueueExtension/Role63F19/ImportRole63F19", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-appconfig-extension/MyQueueExtension/Role63F19/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "policies": [ + { + "policyName": "AllowAppConfigInvokeExtensionEventSourcePolicy", + "policyDocument": { + "Statement": [ + { + "Action": "sqs:SendMessage", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "MyQueueE6CA6235", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + } + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "aws-appconfig-extension/MyQueueExtension/Resource", @@ -335,12 +644,18 @@ "actions": { "ON_DEPLOYMENT_START": [ { - "Name": "awsappconfigextension-MyQueueExtension-EF6112FA", + "Name": "awsappconfigextension-MyQueueExtension-EF6112FA-0", "Uri": { "Fn::GetAtt": [ "MyQueueE6CA6235", "Arn" ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyQueueExtensionRole63F1970B4A7A6", + "Arn" + ] } } ] @@ -355,55 +670,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "AssociationResourceBAC86": { - "id": "AssociationResourceBAC86", - "path": "aws-appconfig-extension/AssociationResourceBAC86", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", - "aws:cdk:cloudformation:props": { - "extensionIdentifier": { - "Fn::GetAtt": [ - "MyQueueExtension872C5D27", - "Id" - ] - }, - "extensionVersionNumber": { - "Fn::GetAtt": [ - "MyQueueExtension872C5D27", - "VersionNumber" - ] - }, - "resourceIdentifier": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":appconfig:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":application/", - { - "Ref": "MyApplication5C63EC1D" - } - ] - ] - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", "version": "0.0.0" } }, @@ -433,6 +700,66 @@ "id": "MyTopicExtension", "path": "aws-appconfig-extension/MyTopicExtension", "children": { + "Role39BF2": { + "id": "Role39BF2", + "path": "aws-appconfig-extension/MyTopicExtension/Role39BF2", + "children": { + "ImportRole39BF2": { + "id": "ImportRole39BF2", + "path": "aws-appconfig-extension/MyTopicExtension/Role39BF2/ImportRole39BF2", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-appconfig-extension/MyTopicExtension/Role39BF2/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "policies": [ + { + "policyName": "AllowAppConfigInvokeExtensionEventSourcePolicy", + "policyDocument": { + "Statement": [ + { + "Action": "sns:Publish", + "Effect": "Allow", + "Resource": { + "Ref": "MyTopic86869434" + } + } + ], + "Version": "2012-10-17" + } + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "aws-appconfig-extension/MyTopicExtension/Resource", @@ -442,9 +769,15 @@ "actions": { "ON_DEPLOYMENT_START": [ { - "Name": "awsappconfigextension-MyTopicExtension-37440DA2", + "Name": "awsappconfigextension-MyTopicExtension-37440DA2-0", "Uri": { "Ref": "MyTopic86869434" + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyTopicExtensionRole39BF2474FECA3", + "Arn" + ] } } ] @@ -459,55 +792,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "AssociationResource7F3E1": { - "id": "AssociationResource7F3E1", - "path": "aws-appconfig-extension/AssociationResource7F3E1", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", - "aws:cdk:cloudformation:props": { - "extensionIdentifier": { - "Fn::GetAtt": [ - "MyTopicExtension9B6DF691", - "Id" - ] - }, - "extensionVersionNumber": { - "Fn::GetAtt": [ - "MyTopicExtension9B6DF691", - "VersionNumber" - ] - }, - "resourceIdentifier": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":appconfig:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":application/", - { - "Ref": "MyApplication5C63EC1D" - } - ] - ] - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", "version": "0.0.0" } }, @@ -575,58 +860,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "AssociationResource689DE": { - "id": "AssociationResource689DE", - "path": "aws-appconfig-extension/AssociationResource689DE", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::ExtensionAssociation", - "aws:cdk:cloudformation:props": { - "extensionIdentifier": { - "Fn::GetAtt": [ - "MyEventBusExtensionADFE2273", - "Id" - ] - }, - "extensionVersionNumber": { - "Fn::GetAtt": [ - "MyEventBusExtensionADFE2273", - "VersionNumber" - ] - }, - "parameters": { - "testParam": "true" - }, - "resourceIdentifier": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":appconfig:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":application/", - { - "Ref": "MyApplication5C63EC1D" - } - ] - ] - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnExtensionAssociation", + "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", "version": "0.0.0" } }, @@ -654,7 +888,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", "version": "0.0.0" } }, @@ -731,8 +965,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.HostedConfiguration", + "version": "0.0.0" } }, "BootstrapVersion": { @@ -762,7 +996,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.3.0" } } }, diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts index 7e6becd0d0e90..94b3c38897037 100755 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts @@ -41,7 +41,6 @@ const lambdaExtension = new Extension(stack, 'MyLambdaExtension', { ActionPoint.ON_DEPLOYMENT_START, ], eventDestination: new LambdaDestination(lambda), - invokeWithoutExecutionRole: true, }), ], }); @@ -56,7 +55,6 @@ const queueExtension = new Extension(stack, 'MyQueueExtension', { ActionPoint.ON_DEPLOYMENT_START, ], eventDestination: new SqsDestination(queue), - invokeWithoutExecutionRole: true, }), ], }); @@ -71,7 +69,6 @@ const topicExtension = new Extension(stack, 'MyTopicExtension', { ActionPoint.ON_DEPLOYMENT_START, ], eventDestination: new SnsDestination(topic), - invokeWithoutExecutionRole: true, }), ], }); @@ -88,7 +85,6 @@ const busExtension = new Extension(stack, 'MyEventBusExtension', { eventDestination: new EventBridgeDestination(bus), description: 'My event bus action', name: 'MyEventBusPreHostedConfigVersionAction', - invokeWithoutExecutionRole: true, }), ], parameters: [ From 951dc06750832b3d2db547cf2eac513619094449 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Thu, 7 Dec 2023 10:31:15 -0500 Subject: [PATCH 2/3] small refactors --- .../aws-appconfig-alpha/lib/extension.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts index 02baa27500d8c..c337cd091f66f 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts @@ -506,7 +506,7 @@ export class Extension extends Resource implements IExtension { this.parameters = props.parameters; const resource = new CfnExtension(this, 'Resource', { - actions: this.actions.reduce((acc: {[key: string]: {[key: string]: string}[]}, cur: Action, index) => { + actions: this.actions.reduce((acc: {[key: string]: {[key: string]: string}[]}, cur: Action, index: number) => { const extensionUri = cur.eventDestination.extensionUri; const sourceType = cur.eventDestination.type; this.executionRole = cur.executionRole; @@ -664,10 +664,7 @@ export class ExtensibleBase implements IExtensible { } private getExtensionForActionPoint(eventDestination: IEventDestination, actionPoint: ActionPoint, options?: ExtensionOptions) { - const name = options?.name || Names.uniqueResourceName(this.scope, { - maxLength: 54, - separator: '-', - }) + '-Extension'; + const name = options?.name || this.getExtensionDefaultName(); const versionNumber = options?.latestVersionNumber ? options?.latestVersionNumber + 1 : 1; const extension = new Extension(this.scope, `Extension${this.getExtensionHash(name, versionNumber)}`, { actions: [ @@ -688,7 +685,8 @@ export class ExtensibleBase implements IExtensible { private addExtensionAssociation(extension: IExtension, options?: ExtensionOptions) { const versionNumber = options?.latestVersionNumber ? options?.latestVersionNumber + 1 : 1; - new CfnExtensionAssociation(this.scope, `AssociationResource${this.getExtensionAssociationHash(extension.name!, versionNumber)}`, { + const name = extension.name ?? this.getExtensionDefaultName(); + new CfnExtensionAssociation(this.scope, `AssociationResource${this.getExtensionAssociationHash(name, versionNumber)}`, { extensionIdentifier: extension.extensionId, resourceIdentifier: this.resourceArn, extensionVersionNumber: extension.extensionVersionNumber, @@ -707,10 +705,17 @@ export class ExtensibleBase implements IExtensible { } private getExtensionAssociationHash(name: string, versionNumber: number) { - const resourceIdentifier = this.resourceName ? this.resourceName : this.resourceArn; + const resourceIdentifier = this.resourceName ?? this.resourceArn; const combinedString = stringifyObjects(resourceIdentifier, name, versionNumber); return getHash(combinedString); } + + private getExtensionDefaultName() { + return Names.uniqueResourceName(this.scope, { + maxLength: 54, + separator: '-', + }) + '-Extension'; + } } /** From 38da0b03d55520a8298585934cb4216d2844c3b0 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Thu, 7 Dec 2023 10:31:15 -0500 Subject: [PATCH 3/3] small refactors --- .../@aws-cdk/aws-appconfig-alpha/lib/extension.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts index c337cd091f66f..72f6d1bc9c739 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts @@ -658,9 +658,7 @@ export class ExtensibleBase implements IExtensible { } public addExtension(extension: IExtension) { - this.addExtensionAssociation(extension, { - parameters: extension.parameters, - }); + this.addExtensionAssociation(extension); } private getExtensionForActionPoint(eventDestination: IEventDestination, actionPoint: ActionPoint, options?: ExtensionOptions) { @@ -680,17 +678,17 @@ export class ExtensibleBase implements IExtensible { ...(options?.latestVersionNumber ? { latestVersionNumber: options.latestVersionNumber } : {}), ...(options?.parameters ? { parameters: options.parameters } : {}), }); - this.addExtensionAssociation(extension, options); + this.addExtensionAssociation(extension); } - private addExtensionAssociation(extension: IExtension, options?: ExtensionOptions) { - const versionNumber = options?.latestVersionNumber ? options?.latestVersionNumber + 1 : 1; + private addExtensionAssociation(extension: IExtension) { + const versionNumber = extension?.latestVersionNumber ? extension?.latestVersionNumber + 1 : 1; const name = extension.name ?? this.getExtensionDefaultName(); new CfnExtensionAssociation(this.scope, `AssociationResource${this.getExtensionAssociationHash(name, versionNumber)}`, { extensionIdentifier: extension.extensionId, resourceIdentifier: this.resourceArn, extensionVersionNumber: extension.extensionVersionNumber, - parameters: options?.parameters?.reduce((acc: {[key: string]: string}, cur: Parameter) => { + parameters: extension.parameters?.reduce((acc: {[key: string]: string}, cur: Parameter) => { if (cur.value) { acc[cur.name] = cur.value; }