Skip to content

(aws-lambda): function with alias can generate too long (>140) arn #18795

@mikaelstaldal

Description

@mikaelstaldal

What is the problem?

When you create a lambda function with a long id, a version and an alias, you get this error:

1 validation error detected: Value 'arn:aws:lambda:us-east-1:603241479242:function:TrcaServiceStack-dev-TrcaLeaderboardReportHandlerd-AggdQu2Fyr5C:TrcaLeaderboardReportHandlerAlias-dev' at 'functionName' failed to satisfy constraint: Member must have length less than or equal to 140 (Service: AWSLambda; Status Code: 400; Error Code: ValidationException; Request ID: d1cb4f89-12c7-4bcf-ae5a-c5f0ce20b0c7; Proxy: null)

Reproduction Steps

        Function function = Function.Builder.create(this, "TrcaLeaderboardReportHandler-dev")
                .runtime(...)
                .code(...)
                .handler(...)
                .build();

        Version version = Version.Builder.create(this, "TrcaLeaderboardReportHandlerVersion-dev")
                .lambda(function)
                .build();

        return Alias.Builder.create(this, "TrcaLeaderboardReportHandlerAlias-dev")
                .aliasName("TrcaLeaderboardReportHandlerAlias-dev")
                .version(version)
                .build();

What did you expect to happen?

CDK generate an arn not longer than 140 characters.

What actually happened?

CDK generated an arn longer than 140 characters, which is not allowed, and the creation failed.

CDK CLI Version

2.8.0 (build 8a5eb49)

Framework Version

No response

Node.js Version

v16.13.0

OS

Linux

Language

Java

Language Version

11

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