Skip to content

feat(lambda): add LATEST to ParamsAndSecretsVersions #34367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

okasyun
Copy link

@okasyun okasyun commented May 6, 2025

Issue # (if applicable)

Closes #31772.

Reason for this change

calling

cdk.aws_lambda.ParamsAndSecretsLayerVersion.fromVersion(cdk.aws_lambda.ParamsAndSecretsVersions.V1_0_103)

will always return the lambda layer with a version of 4 for us-east-1. the CDK documentation states that this is the latest version, while the documentation in lambda shows that 16 is the latest in this region.

Not only us-east-1 but also other resions have the same problems.

Description of changes

add property latest to ParamsAndSecretsVersions.

Parameters and Secrets Lambda Extension ARN can be referenced by using this latest.

Description of how you validated changes

I created unit tests and integration tests.
Both were successful.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team May 6, 2025 11:06
@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. labels May 6, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review May 6, 2025 12:15

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 6, 2025
Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've just added some minor modification to approve.

You're defining the latest correspondence relationships in fact-tables.ts, but to keep it up-to-date, we need to continuously update this file, which seems like it could result in breaking changes. I'd like you to discuss with the maintainers whether this approach is acceptable or not.

},
},
});
expect(() => app.synth()).not.toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(() => app.synth()).not.toThrow();

},
},
});
expect(() => app.synth()).not.toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(() => app.synth()).not.toThrow();

Copy link
Author

@okasyun okasyun May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review.
I fixed the issues you pointed out in the following commit:
bc421c0

And, as you mentioned, fact-tables.ts will need to be continuously updated.
However, I couldn't come up with a better solution than this to add LATEST to ParamsAndSecretsVersions.
Although I'd like to discuss this with the maintainers, I'm not sure who they are.
If you know, could you let me know who I should reach out to?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the console UI, you can only select a fixed AWS-Parameters-and-Secrets-Lambda-Extension version of the layer — there's no option to choose something like "latest" to always fetch the newest version.
For that reason, I believe the CDK should align with this behavior. Since the concept of a dynamically updated latest version isn't supported in the Lambda console, implementing such behavior in CDK is also challenging.

Screenshot 2025-05-07 at 18 36 21

Copy link
Contributor

@badmintoncryer badmintoncryer May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't come up with a better solution

I also have no better idea!

If you know, could you let me know who I should reach out to?

I'm not sure too. After my approval, the needs-maintainer-review label would be attached and one of maintainers will be assigned. Therefore, please wait until that time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@badmintoncryer
I fix through this commit
050292a

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 7, 2025
@okasyun okasyun force-pushed the feature/add-latest-params-and-secrets-versions branch 2 times, most recently from ed1ab42 to bc421c0 Compare May 7, 2025 10:01
@badmintoncryer
Copy link
Contributor

@okasyun Could you please re-run your integ test?

@aws-cdk-testing/framework-integ: Snapshot Results: 
@aws-cdk-testing/framework-integ: Tests:    1 failed, 1186 total
@aws-cdk-testing/framework-integ: Failed: /codebuild/output/src1098740116/src/github.com/aws/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.params-and-secrets.js
@aws-cdk-testing/framework-integ: Error: Some tests failed!
@aws-cdk-testing/framework-integ: To re-run failed tests run: integ-runner --update-on-failed
@aws-cdk-testing/framework-integ:     at main (/codebuild/output/src1098740116/src/github.com/aws/aws-cdk/node_modules/@aws-cdk/integ-runner/lib/index.js:10279:13)
@aws-cdk-testing/framework-integ: Error: integ-runner exited with error code 1
@aws-cdk-testing/framework-integ: Tests failed. Total time (2m19.0s) | integ-runner (2m8.0s) | /codebuild/output/src1098740116/src/github.com/aws/aws-cdk/node_modules/jest/bin/jest.js (9.9s)
@aws-cdk-testing/framework-integ: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@badmintoncryer
Copy link
Contributor

@okasyun Could you please follow below steps?

  • Merge the newest origin/main
  • Run yarn at the repository root
  • Run npx lerna run build --scope=@aws-cdk-testing/framework-integ --skip-nx-cache
  • Delete the existing snapshot folder
  • Run the integ test

@okasyun okasyun force-pushed the feature/add-latest-params-and-secrets-versions branch from 8020755 to 4528bc8 Compare May 11, 2025 06:43
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 050292a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@scorbiere scorbiere self-assigned this May 16, 2025
Copy link
Contributor

@scorbiere scorbiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

I made a couple of suggestions (took some inspiration from #32783)

Comment on lines 30 to +35
V1_0_103 = '1.0.103',
/**
* latest version
*
*/
LATEST = 'latest',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
V1_0_103 = '1.0.103',
/**
* latest version
*
*/
LATEST = 'latest',
V1_0_103 = '1.0.103',
/**
* Version 1.0.104
*/
V1_0_104 = '1.0.104',
/**
* latest version
*/
LATEST = '1.0.104',

@@ -1243,6 +1243,84 @@ export const PARAMS_AND_SECRETS_LAMBDA_LAYER_ARNS: { [version: string]: { [arch:
'us-west-2': 'arn:aws:lambda:us-west-2:345057560386:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:4',
},
},
'latest': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to keep the version logic and to keep the new entry in 1st position:

Suggested change
'latest': {
'1.0.104': {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(lambda): ParamsAndSecretsVersions should return the latest, or new versions should be made available
4 participants