From 569925a922baeb312b9d3a3f5d77d48b3367b723 Mon Sep 17 00:00:00 2001 From: Cole Paluch Date: Thu, 5 Dec 2024 09:52:10 -0500 Subject: [PATCH] feat(appconfig): add atDeploymentTick extension action point to L2 Constructs --- .../aws-appconfig-extension.assets.json | 6 +- .../aws-appconfig-extension.template.json | 17 +++++ ...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 | 13 +--- .../integ.extension.js.snapshot/tree.json | 37 +++++++--- .../aws-appconfig/test/integ.extension.ts | 1 + packages/aws-cdk-lib/aws-appconfig/README.md | 15 +++- .../aws-appconfig/lib/application.ts | 20 ++++++ .../aws-appconfig/lib/configuration.ts | 11 +++ .../aws-appconfig/lib/environment.ts | 13 ++++ .../aws-appconfig/lib/extension.ts | 14 ++++ .../aws-appconfig/test/application.test.ts | 68 ++++++++++++++++--- .../aws-appconfig/test/extension.test.ts | 8 +++ packages/aws-cdk-lib/awslint.json | 1 + 16 files changed, 193 insertions(+), 37 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json index dac0e858ae772..4824c0ae1c4fe 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json @@ -1,7 +1,7 @@ { - "version": "36.0.0", + "version": "38.0.1", "files": { - "a4f22807b445e94aa9052ebdd44c6cfce2d3479cdede016c64f821562394d574": { + "3574584bf944d4e30e634c91b869f9f3917189e3043011290a52b1c28415d328": { "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": "a4f22807b445e94aa9052ebdd44c6cfce2d3479cdede016c64f821562394d574.json", + "objectKey": "3574584bf944d4e30e634c91b869f9f3917189e3043011290a52b1c28415d328.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json index 0c4e85df30557..8006e3c937f28 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/aws-appconfig-extension.template.json @@ -318,6 +318,23 @@ ] } } + ], + "AT_DEPLOYMENT_TICK": [ + { + "Name": "awsappconfigextension-MyLambdaExtension-68C15290-0", + "Uri": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyLambdaExtensionRoleBC958D3F13B04", + "Arn" + ] + } + } ] }, "Name": "awsappconfigextension-MyLambdaExtension-68C15290" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json index 2ff5b1321ea06..d0b4d2365c841 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets.json @@ -1,5 +1,5 @@ { - "version": "36.0.0", + "version": "38.0.1", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/cdk.out index 1f0068d32659a..c6e612584e352 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"36.0.0"} \ No newline at end of file +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/integ.json index d86521a772834..e91140aa2d0e6 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "36.0.0", + "version": "38.0.1", "testCases": { "aws-appconfig-extension/MyApplication/appconfig-extension/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/manifest.json index cfc53f9a90ce6..c8f0dd201099a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "36.0.0", + "version": "38.0.1", "artifacts": { "awsappconfigextensionMyApplicationappconfigextensionDefaultTestDeployAssert64BA6C4E.assets": { "type": "cdk:asset-manifest", @@ -66,7 +66,7 @@ "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}/a4f22807b445e94aa9052ebdd44c6cfce2d3479cdede016c64f821562394d574.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3574584bf944d4e30e634c91b869f9f3917189e3043011290a52b1c28415d328.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -225,15 +225,6 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } - ], - "HostedConfigurationDeploymentawsappconfigextensionMyApplicationMyEnv0FA5092F8D4EFA96": [ - { - "type": "aws:cdk:logicalId", - "data": "HostedConfigurationDeploymentawsappconfigextensionMyApplicationMyEnv0FA5092F8D4EFA96", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } ] }, "displayName": "aws-appconfig-extension" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/tree.json index 8dc4a4901b811..b17cdc88db986 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.js.snapshot/tree.json @@ -356,7 +356,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", + "fqn": "aws-cdk-lib.aws_appconfig.Environment", "version": "0.0.0" } }, @@ -373,7 +373,7 @@ "path": "aws-appconfig-extension/MyApplication/appconfig-extension/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.3.0" + "version": "10.4.2" } }, "DeployAssert": { @@ -416,7 +416,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.Application", + "fqn": "aws-cdk-lib.aws_appconfig.Application", "version": "0.0.0" } }, @@ -530,6 +530,23 @@ ] } } + ], + "AT_DEPLOYMENT_TICK": [ + { + "Name": "awsappconfigextension-MyLambdaExtension-68C15290-0", + "Uri": { + "Fn::GetAtt": [ + "MyFunction3BAA72D1", + "Arn" + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "MyLambdaExtensionRoleBC958D3F13B04", + "Arn" + ] + } + } ] }, "name": "awsappconfigextension-MyLambdaExtension-68C15290" @@ -542,7 +559,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", + "fqn": "aws-cdk-lib.aws_appconfig.Extension", "version": "0.0.0" } }, @@ -670,7 +687,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", + "fqn": "aws-cdk-lib.aws_appconfig.Extension", "version": "0.0.0" } }, @@ -792,7 +809,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", + "fqn": "aws-cdk-lib.aws_appconfig.Extension", "version": "0.0.0" } }, @@ -860,7 +877,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.Extension", + "fqn": "aws-cdk-lib.aws_appconfig.Extension", "version": "0.0.0" } }, @@ -888,7 +905,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", + "fqn": "aws-cdk-lib.aws_appconfig.DeploymentStrategy", "version": "0.0.0" } }, @@ -965,7 +982,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.HostedConfiguration", + "fqn": "aws-cdk-lib.aws_appconfig.HostedConfiguration", "version": "0.0.0" } }, @@ -996,7 +1013,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.3.0" + "version": "10.4.2" } } }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.ts index 70f033b8e791b..f9683e7c1ec90 100755 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appconfig/test/integ.extension.ts @@ -39,6 +39,7 @@ const lambdaExtension = new Extension(stack, 'MyLambdaExtension', { actionPoints: [ ActionPoint.PRE_CREATE_HOSTED_CONFIGURATION_VERSION, ActionPoint.ON_DEPLOYMENT_START, + ActionPoint.AT_DEPLOYMENT_TICK, ], eventDestination: new LambdaDestination(lambda), }), diff --git a/packages/aws-cdk-lib/aws-appconfig/README.md b/packages/aws-cdk-lib/aws-appconfig/README.md index 4fb20a41ab0aa..66c7034db0c23 100644 --- a/packages/aws-cdk-lib/aws-appconfig/README.md +++ b/packages/aws-cdk-lib/aws-appconfig/README.md @@ -536,9 +536,22 @@ new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', { ## Extension An extension augments your ability to inject logic or behavior at different points during the AWS AppConfig workflow of -creating or deploying a configuration. +creating or deploying a configuration. You can associate these types of tasks with AWS AppConfig applications, environments, and configuration profiles. See: https://docs.aws.amazon.com/appconfig/latest/userguide/working-with-appconfig-extensions.html +An extension defines one or more actions, that it performs during an AWS AppConfig workflow. Each action is invoked either when you interact with AWS AppConfig or when AWS AppConfig is performing a process on your behalf. These invocation points are called action points. AWS AppConfig extensions support the following action points: + +* PRE_START_DEPLOYMENT +* PRE_CREATE_HOSTED_CONFIGURATION_VERSION +* ON_DEPLOYMENT_START +* ON_DEPLOYMENT_STEP +* ON_DEPLOYMENT_BAKING +* ON_DEPLOYMENT_COMPLETE +* ON_DEPLOYMENT_ROLLED_BACK +* AT_DEPLOYMENT_TICK + +See: https://docs.aws.amazon.com/appconfig/latest/userguide/working-with-appconfig-extensions-about.html + ### AWS Lambda destination Use an AWS Lambda as the event destination for an extension. diff --git a/packages/aws-cdk-lib/aws-appconfig/lib/application.ts b/packages/aws-cdk-lib/aws-appconfig/lib/application.ts index 3a1dfdc366a4b..b84ef3e131803 100644 --- a/packages/aws-cdk-lib/aws-appconfig/lib/application.ts +++ b/packages/aws-cdk-lib/aws-appconfig/lib/application.ts @@ -146,6 +146,15 @@ export interface IApplication extends cdk.IResource { */ onDeploymentRolledBack(eventDestination: IEventDestination, options?: ExtensionOptions): void; + /** + * Adds an AT_DEPLOYMENT_TICK extension with the provided event destination and + * also creates an extension association to an application. + * + * @param eventDestination The event that occurs during the extension + * @param options Options for the extension + */ + atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions): void; + /** * Adds an extension association to the application. * @@ -297,6 +306,17 @@ abstract class ApplicationBase extends cdk.Resource implements IApplication, IEx this.extensible.onDeploymentRolledBack(eventDestination, options); } + /** + * Adds an AT_DEPLOYMENT_TICK extension with the provided event destination and + * also creates an extension association to an application. + * + * @param eventDestination The event that occurs during the extension + * @param options Options for the extension + */ + public atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions) { + this.extensible.atDeploymentTick(eventDestination, options); + } + /** * Adds an extension association to the application. * diff --git a/packages/aws-cdk-lib/aws-appconfig/lib/configuration.ts b/packages/aws-cdk-lib/aws-appconfig/lib/configuration.ts index 72c94cb9ad5ab..73546b2c64929 100644 --- a/packages/aws-cdk-lib/aws-appconfig/lib/configuration.ts +++ b/packages/aws-cdk-lib/aws-appconfig/lib/configuration.ts @@ -295,6 +295,17 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE this.extensible.onDeploymentRolledBack(eventDestination, options); } + /** + * Adds an AT_DEPLOYMENT_TICK extension with the provided event destination and + * also creates an extension association to an application. + * + * @param eventDestination The event that occurs during the extension + * @param options Options for the extension + */ + public atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions) { + this.extensible.atDeploymentTick(eventDestination, options); + } + /** * Adds an extension association to the configuration profile. * diff --git a/packages/aws-cdk-lib/aws-appconfig/lib/environment.ts b/packages/aws-cdk-lib/aws-appconfig/lib/environment.ts index ba0110d276718..705cc9c2144cc 100644 --- a/packages/aws-cdk-lib/aws-appconfig/lib/environment.ts +++ b/packages/aws-cdk-lib/aws-appconfig/lib/environment.ts @@ -113,6 +113,10 @@ abstract class EnvironmentBase extends Resource implements IEnvironment, IExtens this.extensible.onDeploymentRolledBack(eventDestination, options); } + public atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions) { + this.extensible.atDeploymentTick(eventDestination, options); + } + public addExtension(extension: IExtension) { this.extensible.addExtension(extension); } @@ -556,6 +560,15 @@ export interface IEnvironment extends IResource { */ onDeploymentRolledBack(eventDestination: IEventDestination, options?: ExtensionOptions): void; + /** + * Adds an AT_DEPLOYMENT_TICK extension with the provided event destination and + * also creates an extension association to an application. + * + * @param eventDestination The event that occurs during the extension + * @param options Options for the extension + */ + atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions): void; + /** * Adds an extension association to the environment. * diff --git a/packages/aws-cdk-lib/aws-appconfig/lib/extension.ts b/packages/aws-cdk-lib/aws-appconfig/lib/extension.ts index a39fd2980c85b..f0b63a17527dc 100644 --- a/packages/aws-cdk-lib/aws-appconfig/lib/extension.ts +++ b/packages/aws-cdk-lib/aws-appconfig/lib/extension.ts @@ -21,6 +21,7 @@ export enum ActionPoint { ON_DEPLOYMENT_BAKING = 'ON_DEPLOYMENT_BAKING', ON_DEPLOYMENT_COMPLETE = 'ON_DEPLOYMENT_COMPLETE', ON_DEPLOYMENT_ROLLED_BACK = 'ON_DEPLOYMENT_ROLLED_BACK', + AT_DEPLOYMENT_TICK = 'AT_DEPLOYMENT_TICK', } /** @@ -657,6 +658,10 @@ export class ExtensibleBase implements IExtensible { this.getExtensionForActionPoint(eventDestination, ActionPoint.ON_DEPLOYMENT_ROLLED_BACK, options); } + public atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions) { + this.getExtensionForActionPoint(eventDestination, ActionPoint.AT_DEPLOYMENT_TICK, options); + } + public addExtension(extension: IExtension) { this.addExtensionAssociation(extension); } @@ -793,6 +798,15 @@ export interface IExtensible { */ onDeploymentRolledBack(eventDestination: IEventDestination, options?: ExtensionOptions): void; + /** + * Adds an AT_DEPLOYMENT_TICK extension with the provided event destination and + * also creates an extension association to the derived resource. + * + * @param eventDestination The event that occurs during the extension + * @param options Options for the extension + */ + atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions): void; + /** * Adds an extension association to the derived resource. * diff --git a/packages/aws-cdk-lib/aws-appconfig/test/application.test.ts b/packages/aws-cdk-lib/aws-appconfig/test/application.test.ts index 0b97dd70c36d8..8892653e82e70 100644 --- a/packages/aws-cdk-lib/aws-appconfig/test/application.test.ts +++ b/packages/aws-cdk-lib/aws-appconfig/test/application.test.ts @@ -69,7 +69,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); appconfig.on(ActionPoint.ON_DEPLOYMENT_STEP, new LambdaDestination(func)); @@ -116,7 +116,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); appconfig.preCreateHostedConfigurationVersion(new LambdaDestination(func), { @@ -178,7 +178,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { @@ -231,7 +231,7 @@ describe('appconfig', () => { }); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { @@ -281,7 +281,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { @@ -331,7 +331,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { @@ -381,7 +381,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { @@ -431,7 +431,7 @@ describe('appconfig', () => { const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { @@ -476,12 +476,62 @@ describe('appconfig', () => { }); }); + test('at deployment tick', () => { + const stack = new cdk.Stack(); + const appconfig = new Application(stack, 'MyAppConfig'); + const func = new Function(stack, 'MyFunc', { + handler: 'index.handler', + runtime: Runtime.PYTHON_3_9, + code: Code.fromInline('# this is my code'), + }); + Object.defineProperty(func, 'functionArn', { + value: 'arn:lambda:us-east-1:123456789012:function:my-function', + }); + appconfig.atDeploymentTick(new LambdaDestination(func)); + + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Extension', { + Name: 'MyAppConfig-Extension', + Actions: { + AT_DEPLOYMENT_TICK: [ + { + Name: 'MyAppConfig-Extension-0', + RoleArn: { 'Fn::GetAtt': ['MyAppConfigExtensionF845ERole0D30970E5A7E5', 'Arn'] }, + Uri: 'arn:lambda:us-east-1:123456789012:function:my-function', + }, + ], + }, + }); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ExtensionAssociation', { + ExtensionIdentifier: { + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'Id'], + }, + ExtensionVersionNumber: { + 'Fn::GetAtt': ['MyAppConfigExtensionF845EC11D4079', 'VersionNumber'], + }, + ResourceIdentifier: { + 'Fn::Join': [ + '', + [ + 'arn:', + { Ref: 'AWS::Partition' }, + ':appconfig:', + { Ref: 'AWS::Region' }, + ':', + { Ref: 'AWS::AccountId' }, + ':application/', + { Ref: 'MyAppConfigB4B63E75' }, + ], + ], + }, + }); + }); + test('create same extension twice', () => { const stack = new cdk.Stack(); const appconfig = new Application(stack, 'MyAppConfig'); const func = new Function(stack, 'MyFunc', { handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, + runtime: Runtime.PYTHON_3_9, code: Code.fromInline('# this is my code'), }); Object.defineProperty(func, 'functionArn', { diff --git a/packages/aws-cdk-lib/aws-appconfig/test/extension.test.ts b/packages/aws-cdk-lib/aws-appconfig/test/extension.test.ts index 05a178fd2e481..52dd954bab977 100644 --- a/packages/aws-cdk-lib/aws-appconfig/test/extension.test.ts +++ b/packages/aws-cdk-lib/aws-appconfig/test/extension.test.ts @@ -33,6 +33,7 @@ describe('extension', () => { actionPoints: [ ActionPoint.ON_DEPLOYMENT_COMPLETE, ActionPoint.ON_DEPLOYMENT_ROLLED_BACK, + ActionPoint.AT_DEPLOYMENT_TICK, ], eventDestination: new LambdaDestination(func), }), @@ -56,6 +57,13 @@ describe('extension', () => { Uri: { 'Fn::GetAtt': ['MyFunction3BAA72D1', 'Arn'] }, }, ], + AT_DEPLOYMENT_TICK: [ + { + Name: 'MyExtension-0', + RoleArn: { 'Fn::GetAtt': ['MyExtensionRole467D6FCDEEFA5', 'Arn'] }, + Uri: { 'Fn::GetAtt': ['MyFunction3BAA72D1', 'Arn'] }, + }, + ], }, }); Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { diff --git a/packages/aws-cdk-lib/awslint.json b/packages/aws-cdk-lib/awslint.json index 528f143682a16..30b6c88028a64 100644 --- a/packages/aws-cdk-lib/awslint.json +++ b/packages/aws-cdk-lib/awslint.json @@ -958,6 +958,7 @@ "docs-public-apis:aws-cdk-lib.aws_appconfig.ActionPoint.ON_DEPLOYMENT_BAKING", "docs-public-apis:aws-cdk-lib.aws_appconfig.ActionPoint.ON_DEPLOYMENT_COMPLETE", "docs-public-apis:aws-cdk-lib.aws_appconfig.ActionPoint.ON_DEPLOYMENT_ROLLED_BACK", + "docs-public-apis:aws-cdk-lib.aws_appconfig.ActionPoint.AT_DEPLOYMENT_TICK", "docs-public-apis:aws-cdk-lib.aws_appconfig.IValidator", "docs-public-apis:aws-cdk-lib.aws_appconfig.IExtension", "docs-public-apis:aws-cdk-lib.aws_appconfig.IEnvironment",