Skip to content

(aws-lambda): specifying insightsVersion generates invalid CloudFormation #18789

@wolverian

Description

@wolverian

What is the problem?

If I specify insightsVersion as so:

const l = new lambda.Function(this, 'CdkTsLambda', {
  code: lambda.AssetCode.fromAsset('../out/logger'),
  handler: 'bootstrap',
  runtime: lambda.Runtime.PROVIDED_AL2,
  insightsVersion: lambda.LambdaInsightsVersion.VERSION_1_0_119_0,
});

I get this error:

 ❌  CdkTsStack failed: Error [ValidationError]: Template format error: Mappings attribute name '1_0_119_0_x86_64' must contain only alphanumeric characters.

Reproduction Steps

https://github.com/wolverian/cdk-lambda-insights-issue/blob/main/lib/cdk-lambda-insights-issue-stack.ts#L18

This repo should reproduce the issue.

What did you expect to happen?

The generated CloudFormation is valid.

What actually happened?

The generated CloudFormation uses invalid keys in the Mapping section:

    "CloudwatchlambdainsightsversionMap": {
      "af-south-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:af-south-1:012438385374:layer:LambdaInsightsExtension:9"
      },
      "ap-east-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ap-east-1:519774774795:layer:LambdaInsightsExtension:9"
      },
      "ap-northeast-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ap-northeast-1:580247275435:layer:LambdaInsightsExtension:23"
      },
      "ap-northeast-2": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ap-northeast-2:580247275435:layer:LambdaInsightsExtension:16"
      },
      "ap-south-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ap-south-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "ap-southeast-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ap-southeast-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "ap-southeast-2": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ap-southeast-2:580247275435:layer:LambdaInsightsExtension:16"
      },
      "ca-central-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:ca-central-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "cn-north-1": {
        "1_0_119_0_x86_64": "arn:aws-cn:lambda:cn-north-1:488211338238:layer:LambdaInsightsExtension:9"
      },
      "cn-northwest-1": {
        "1_0_119_0_x86_64": "arn:aws-cn:lambda:cn-northwest-1:488211338238:layer:LambdaInsightsExtension:9"
      },
      "eu-central-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:eu-central-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "eu-north-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:eu-north-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "eu-south-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:eu-south-1:339249233099:layer:LambdaInsightsExtension:9"
      },
      "eu-west-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:eu-west-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "eu-west-2": {
        "1_0_119_0_x86_64": "arn:aws:lambda:eu-west-2:580247275435:layer:LambdaInsightsExtension:16"
      },
      "eu-west-3": {
        "1_0_119_0_x86_64": "arn:aws:lambda:eu-west-3:580247275435:layer:LambdaInsightsExtension:16"
      },
      "me-south-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:me-south-1:285320876703:layer:LambdaInsightsExtension:9"
      },
      "sa-east-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:sa-east-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "us-east-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:us-east-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "us-east-2": {
        "1_0_119_0_x86_64": "arn:aws:lambda:us-east-2:580247275435:layer:LambdaInsightsExtension:16"
      },
      "us-west-1": {
        "1_0_119_0_x86_64": "arn:aws:lambda:us-west-1:580247275435:layer:LambdaInsightsExtension:16"
      },
      "us-west-2": {
        "1_0_119_0_x86_64": "arn:aws:lambda:us-west-2:580247275435:layer:LambdaInsightsExtension:16"
      }
    }

CDK CLI Version

2.10.0 (build e5b301f)

Framework Version

No response

Node.js Version

v16.13.2

OS

macOS Monterey 12.2 (21D49)

Language

Typescript, Go

Language Version

TypeScript 3.9.7 | go version go1.18beta1 darwin/arm64

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-lambdaRelated to AWS LambdabugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions