cdklabs/aws-delivlib

AWS::CodeStarNotifications::NotificationRule - Member must have length less than or equal to 64

vkruglov opened this issue · 3 comments

Hi,

I'm trying to add a Slack notification to a pipeline with a code from the samples. The deployment fails with a validation error (see below).

According to the AWS docs the name of NotificationRule has max length of 64.

I tracked the issue down to this class.
The hardcoded part of the generated name takes 65 symbols, plus the pipeline name.


The code I use:

        const teamChannel = new SlackChannelConfiguration(this, 'AG', {
            slackWorkspaceId: 'XXXX',
            slackChannelConfigurationName: 'XXXX',
            slackChannelId: 'XXXX',
        });
        pipeline.notifyOnFailure(PipelineNotification.slack({
            channels: [teamChannel]
        }));

cdk deploy command fails with

2:54:12 PM | CREATE_FAILED        | AWS::CodeStarNotifications::NotificationRule | ApiGatewayPipeline...b9935a9bc31faa14b7
1 validation error detected: Value at 'name' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: CodeStarNotificat
ions; Status Code: 400; Error Code: ValidationException; Request ID: 0dff41c2-e553-4746-a6f1-c8b8a9f66ac6; Proxy: null)
2:54:13 PM | UPDATE_ROLLBACK_IN_P | AWS::CloudFormation::Stack                   | ApiGatewayStack
The following resource(s) failed to create: [ApiGatewayPipelinePipelineNotificationSlack450ff5fad7c113b9935a9bc31faa14b722B8992B].

CDK version is 1.89.0 (build df7253c), aws-delivlib version is 11.0.1.

Okay, I've managed to find the actual root cause.

The part of CloudFormation template that was responsible for the issue is this:

"AGPipelineNotificationSlackbf25d59aca9da7fa541849143d36312928636729": {
      "Type": "AWS::CodeStarNotifications::NotificationRule",
      "Properties": {
        "DetailType": "BASIC",
        "EventTypeIds": [
          "codepipeline-pipeline-action-execution-failed"
        ],
        "Name": {
          "Fn::Join": [
            "",
            [
              {
                "Ref": "AGBuildPipelineD08E53AD"
              },
              "-bf25d59aca9da7fa541849143d363129"
            ]
          ]
        },
...

The pipeline name was a long string, thus the validation failed. I solved the issue by providing explicit pipeline name in the code:

const pipeline = new delivlib.Pipeline(this, 'AG', {
            pipelineName: 'AGP',
...

It might be useful to take a substring of the pipeline name for the NotificationRule in here. The pipeline name can be up to 100 symbols which is more than maximum length for the NotificationRule name.

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.

Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen.