-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the bug
The version object created by Version.fromVersionArn is created with a lambda property that still contains the version qualifier in its function url. Which can cause CloudFormation deployment errors. For example when you create a lambda alias from it and then try to use that alias fro a lambda function url.
Expected Behavior
I expect Version.fromVersionArn to create the equivalent object as Version.fromVersionAttributes when referencing the same version.
The following test when using Version.fromVersionAttributes succeeds:
import {
Stack,
aws_lambda as lambda,
} from 'aws-cdk-lib';
test('lambda.Version.fromVersionAttributes generates Version with correct lambda property', () => {
const stack = new Stack();
const version = lambda.Version.fromVersionAttributes(stack, 'ExampleVersion', {
lambda: lambda.Function.fromFunctionArn(stack, 'Examplelambda', 'arn:aws:lambda:eu-central-1:123456789012:function:ExampleLambda'),
version: '13',
});
expect(version.version).toStrictEqual('13') // Ok
expect(version.lambda.functionArn).toStrictEqual('arn:aws:lambda:eu-central-1:123456789012:function:ExampleLambda') // Ok
})
Current Behavior
However the following test when using Version.fromVersionArn fails because the version qualifier is not stripped from the arn:
import {
Stack,
aws_lambda as lambda,
} from 'aws-cdk-lib';
test('lambda.Version.fromVersionArn generates Version with correct lambda property', () => {
const stack = new Stack();
const version = lambda.Version.fromVersionArn(stack, 'ExampleVersion', 'arn:aws:lambda:eu-central-1:123456789012:function:ExampleLambda:13');
expect(version.version).toStrictEqual('13') // Ok
expect(version.lambda.functionArn).toStrictEqual('arn:aws:lambda:eu-central-1:123456789012:function:ExampleLambda') // Not Ok
})
Reproduction Steps
Run the above tests
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.137.0
Framework Version
No response
Node.js Version
v20.11.0
OS
macOS Sonoma 14.4.1
Language
TypeScript
Language Version
Typescript (5.4.5)
Other information
No response