aws / aws/aws-cdk

aws-cdk-lib(aws-secretsmanager): Update the SecretsManagerRDSMySQLRotationMultiUser rotation Lambda function so it can be deployed with the latest code

Open
#32,181 3 comments 0 reactions 0 assignees View on GitHub
aws-cdk-lib effort/small feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

### Summary
Using AWS CDK, I want to deploy the secret manager SecretsManagerRDSMySQLRotationMultiUser rotation Lambda function with the following latest GitHub code content.
https://github.com/aws-samples/aws-secrets-manager-rotation-lambdas/blob/master/SecretsManagerRDSMySQLRotationMultiUser/lambda_function.py

However, I confirmed that currently, when deployed via AWS CDK, the rotation Lambda function is deployed with the following old code content.
https://github.com/aws-samples/aws-secrets-manager-rotation-lambdas/blob/13a7a467dfa7643438d9a6e61eb185695fe2229d/SecretsManagerRDSMySQLRotationMultiUser/lambda_function.py

### About the cause
It seems that the issue is caused by the semantic version of the AWS SAM Managed application SecretsManagerRDSMySQLRotationMultiUser used in CDK is old.

CDK is hard coded to be 1.1.367, but the latest one appears to be newer than 1.1.500.

https://github.com/aws/aws-cdk/blob/01f2dcd6fb892905afae735c791ddbb3e6adbcb1/packages/aws-cdk-lib/aws-secretsmanager/lib/secret-rotation.ts#L44-L46

(I am not exactly sure about the latest version)

### Use Case

In the latest code content of SecretsManagerRDSMySQLRotationMultiUser, we can set the username character limit with environment variables.

https://github.com/aws-samples/aws-secrets-manager-rotation-lambdas/blob/92f00b3e3b32df58a8a7c230773335f5846c74fd/SecretsManagerRDSMySQLRotationMultiUser/lambda_function.py#L120-L121

```
# Get username character limit from environment variable
username_limit = int(os.environ.get('USERNAME_CHARACTER_LIMIT', '16'))
```

On the other hand, the old code does not allow arbitrary character limits for the username.

### Proposed Solution

Update version 1.1.367 to newer than 1.1.500.

https://github.com/aws/aws-cdk/blob/01f2dcd6fb892905afae735c791ddbb3e6adbcb1/packages/aws-cdk-lib/aws-secretsmanager/lib/secret-rotation.ts#L44-L46

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.167.1 (build d681b12)

### Environment details (OS name and version, etc.)

All

Contributor guide

Open the contributing guide

Research direction

Start in packages/aws-cdk-lib/aws-secretsmanager/lib/secret-rotation.ts at the managed application version referenced around lines 44-46. Confirm the current SecretsManagerRDSMySQLRotationMultiUser version against the linked AWS SAM rotation-lambdas content, then update the version reference and verify that CDK deployments use the newer rotation Lambda code.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.