From 2470b8ff5d1635308f652ecb8f374dd410508fa0 Mon Sep 17 00:00:00 2001 From: Kristian Rekstad Date: Fri, 15 Jul 2022 15:47:39 +0200 Subject: [PATCH] feat(cdk-pipelines): allow uuid on SlackNotification to be overridden This lets users create multiple stacks of this type. This is needed because of the singleton lambda. It is unknown why we use a singleton lambda in the first place. --- src/cdk-pipelines/slack-notification.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cdk-pipelines/slack-notification.ts b/src/cdk-pipelines/slack-notification.ts index 7cf7ff28..5823f364 100644 --- a/src/cdk-pipelines/slack-notification.ts +++ b/src/cdk-pipelines/slack-notification.ts @@ -31,6 +31,17 @@ export interface SlackNotificationProps { * @default false */ alwaysShowSucceeded?: boolean + + /** + * Used to control that only one lambda is created in the account. + * + * Specify a value here when you manually create a {@link SlackNotification} for a pipeline + * without using {@link LifligCdkPipeline.addSlackNotification}. + * For example: `"65f7a9e0-d0a4-4ba7-ad1f-6dec853bbdb8"`. + * + * @default "55954fc8-182e-497e-bd60-7af1496dc222" + */ + singletonLambdaUuid?: string } /** @@ -60,7 +71,7 @@ export class SlackNotification extends constructs.Construct { } const reportFunction = new lambda.SingletonFunction(this, "Function", { - uuid: "55954fc8-182e-497e-bd60-7af1496dc222", + uuid: props.singletonLambdaUuid ?? "55954fc8-182e-497e-bd60-7af1496dc222", code: lambda.Code.fromAsset( path.join(__dirname, "../../assets/pipeline-slack-notification-lambda"), ),