From ced7a46b45aeee335264d91cf8287da4837dbab8 Mon Sep 17 00:00:00 2001 From: Pahud Hsieh Date: Mon, 29 Apr 2024 18:18:33 -0400 Subject: [PATCH 1/5] revert: "fix(lambda): version.fromVersionArn creates invalid Version object" (#30003) ### Issue # (if applicable) Revert https://github.com/aws/aws-cdk/pull/29820 Closes https://github.com/aws/aws-cdk/issues/30002 ### Reason for this change ### Description of changes ### Description of how you validated changes ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cdk-lib/aws-lambda/lib/function.ts | 13 +--------- .../aws-lambda/test/function.test.ts | 24 ------------------- .../aws-lambda/test/lambda-version.test.ts | 3 --- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/packages/aws-cdk-lib/aws-lambda/lib/function.ts b/packages/aws-cdk-lib/aws-lambda/lib/function.ts index 3f784a5ccc247..dba046f447513 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/function.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/function.ts @@ -671,18 +671,7 @@ export class Function extends FunctionBase { * in the same account and region as the stack you are importing it into. */ public static fromFunctionArn(scope: Construct, id: string, functionArn: string): IFunction { - /** - * If the functionArn has a trailing version or alias (more than 7 parts when split by ":", - * we trim off the trailing version/alias to retrieve the real functionArn. - * See lambda resource ARN format here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-api-permissions-ref.html - */ - const parts = functionArn.split(':'); - if (parts.length > 7) { - const _functionArn = parts.slice(0, 7).join(':'); - return Function.fromFunctionAttributes(scope, id, { functionArn: _functionArn }); - } else { - return Function.fromFunctionAttributes(scope, id, { functionArn }); - } + return Function.fromFunctionAttributes(scope, id, { functionArn }); } /** diff --git a/packages/aws-cdk-lib/aws-lambda/test/function.test.ts b/packages/aws-cdk-lib/aws-lambda/test/function.test.ts index 7711c3ff0fed3..f4c5382707641 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/function.test.ts @@ -397,30 +397,6 @@ describe('function', () => { expect(imported.functionName).toEqual('ProcessKinesisRecords'); }); - test('fromFunctionArn with verionArn as the input', () => { - // GIVEN - const stack2 = new cdk.Stack(); - - // WHEN - const imported = lambda.Function.fromFunctionArn(stack2, 'Imported', 'arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords:1'); - - // THEN - expect(imported.functionArn).toEqual('arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords'); - expect(imported.functionName).toEqual('ProcessKinesisRecords'); - }); - - test('fromFunctionArn with trailing alias as the input', () => { - // GIVEN - const stack2 = new cdk.Stack(); - - // WHEN - const imported = lambda.Function.fromFunctionArn(stack2, 'Imported', 'arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords:TEST'); - - // THEN - expect(imported.functionArn).toEqual('arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords'); - expect(imported.functionName).toEqual('ProcessKinesisRecords'); - }); - test('Function.fromFunctionName', () => { // GIVEN const stack = new cdk.Stack(); diff --git a/packages/aws-cdk-lib/aws-lambda/test/lambda-version.test.ts b/packages/aws-cdk-lib/aws-lambda/test/lambda-version.test.ts index 3356fa2dbf400..6236a92df5dae 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/lambda-version.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/lambda-version.test.ts @@ -15,9 +15,6 @@ describe('lambda version', () => { // WHEN const version = lambda.Version.fromVersionArn(stack, 'Version', 'arn:aws:lambda:region:account-id:function:function-name:version'); - expect(version.version).toStrictEqual('version'); - expect(version.lambda.functionArn).toStrictEqual('arn:aws:lambda:region:account-id:function:function-name'); - new cdk.CfnOutput(stack, 'ARN', { value: version.functionArn }); new cdk.CfnOutput(stack, 'Name', { value: version.functionName }); From ac23a6631375b88c49bb5d1750bb558e0892a977 Mon Sep 17 00:00:00 2001 From: Mohamed ElAsmar Date: Mon, 29 Apr 2024 16:09:29 -0700 Subject: [PATCH 2/5] chore(release): 2.139.1 --- CHANGELOG.v2.alpha.md | 2 ++ CHANGELOG.v2.md | 7 +++++++ version.v2.json | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index fd13953bc012b..89f82ebfcbb73 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.139.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.139.0-alpha.0...v2.139.1-alpha.0) (2024-04-29) + ## [2.139.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.138.0-alpha.0...v2.139.0-alpha.0) (2024-04-24) ## [2.138.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.137.0-alpha.0...v2.138.0-alpha.0) (2024-04-18) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 75407514eb4b9..91b9e76217b4c 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.139.1](https://github.com/aws/aws-cdk/compare/v2.139.0...v2.139.1) (2024-04-29) + + +### Reverts + +* "fix(lambda): version.fromVersionArn creates invalid Version object" ([#30003](https://github.com/aws/aws-cdk/issues/30003)) ([ced7a46](https://github.com/aws/aws-cdk/commit/ced7a46b45aeee335264d91cf8287da4837dbab8)) + ## [2.139.0](https://github.com/aws/aws-cdk/compare/v2.138.0...v2.139.0) (2024-04-24) diff --git a/version.v2.json b/version.v2.json index 1d8a8f9f6a616..bb0dc4a9d8284 100644 --- a/version.v2.json +++ b/version.v2.json @@ -1,4 +1,4 @@ { - "version": "2.139.0", - "alphaVersion": "2.139.0-alpha.0" + "version": "2.139.1", + "alphaVersion": "2.139.1-alpha.0" } \ No newline at end of file From c7669356587763d8d686b0998ad803923be8ab63 Mon Sep 17 00:00:00 2001 From: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:24:22 -0700 Subject: [PATCH 3/5] Update CHANGELOG.v2.md --- CHANGELOG.v2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 91b9e76217b4c..1844480867afb 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [2.139.1](https://github.com/aws/aws-cdk/compare/v2.139.0...v2.139.1) (2024-04-29) +## [2.139.1](https://github.com/aws/aws-cdk/compare/v2.139.0...v2.139.1) (2024-04-29) ### Reverts From 48bcfe62f0765d15de9c1693ad3e699628e2661b Mon Sep 17 00:00:00 2001 From: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:26:43 -0700 Subject: [PATCH 4/5] Update CHANGELOG.v2.alpha.md --- CHANGELOG.v2.alpha.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index 89f82ebfcbb73..e0aca758001d1 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [2.139.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.139.0-alpha.0...v2.139.1-alpha.0) (2024-04-29) +## [2.139.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.139.0-alpha.0...v2.139.1-alpha.0) (2024-04-29) ## [2.139.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.138.0-alpha.0...v2.139.0-alpha.0) (2024-04-24) From 3ff013b4d0239179a8a178349eebdfecf59df47b Mon Sep 17 00:00:00 2001 From: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:06:36 -0700 Subject: [PATCH 5/5] fix changelog --- CHANGELOG.v2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 1844480867afb..0b5a78029ca11 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. See [standa ### Reverts -* "fix(lambda): version.fromVersionArn creates invalid Version object" ([#30003](https://github.com/aws/aws-cdk/issues/30003)) ([ced7a46](https://github.com/aws/aws-cdk/commit/ced7a46b45aeee335264d91cf8287da4837dbab8)) +* fix(lambda): version.fromVersionArn creates invalid Version object ([#30003](https://github.com/aws/aws-cdk/issues/30003)) ([ced7a46](https://github.com/aws/aws-cdk/commit/ced7a46b45aeee335264d91cf8287da4837dbab8)) ## [2.139.0](https://github.com/aws/aws-cdk/compare/v2.138.0...v2.139.0) (2024-04-24)