feat(rds): add urlSafePassword option to DatabaseSecret for URL parser compatibility#35211
Open
feat(rds): add urlSafePassword option to DatabaseSecret for URL parser compatibility#35211
Conversation
…arser compatibility Add optional urlSafePassword property to DatabaseSecret and related credential interfaces to generate passwords compatible with URL parsers by excluding problematic characters. - Add urlSafePassword option to DatabaseSecretProps, CredentialsBaseOptions, Credentials, and SnapshotCredentials - Create URL_SAFE_PASSWORD_EXCLUDE_CHARS constant that excludes caret (^) character - Implement conditional exclusion logic in DatabaseSecret constructor - Ensure explicit excludeCharacters takes precedence over urlSafePasswor
aws-cdk-automation
requested changes
Aug 11, 2025
Collaborator
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Features must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
Contributor
Author
|
Exemption Request Integration tests: Verified existing integration tests continue to pass. No new integration tests required as the feature follows established patterns and existing tests validate the password generation pipeline. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
Closes #35175.
Reason for this change
Go applications using
net/urlparser fail when parsing database connection URLs containing RDS-generated passwords with caret (^) characters. The errornet/url: invalid userinfoprevents Go developers from using CDK-generated RDS passwords in connection URLs, forcing them to manually generate passwords or work around the issue.This change adds an optional
urlSafePasswordproperty toDatabaseSecretand related credential interfaces, allowing developers to generate passwords that are compatible with URL parsers by excluding characters that cause parsing issues.Description of changes
This implementation adds URL-safe password generation capability to the AWS RDS module:
urlSafePasswordproperty: Added optional boolean property toDatabaseSecretProps,CredentialsBaseOptions,CredentialsFromUsernameOptions,SnapshotCredentialsFromGeneratedPasswordOptions,Credentials, andSnapshotCredentialsinterfacesURL_SAFE_PASSWORD_EXCLUDE_CHARSconstant that extends the default exclusion set with the caret (^) characterDatabaseSecretconstructor andSnapshotCredentials.fromGeneratedSecret()method to use URL-safe exclusions whenurlSafePassword: trueexcludeCharactersparameter takes precedence overurlSafePasswordoption for maximum user controlurlSafePasswordin logical ID hash calculation for proper secret replacement whenreplaceOnPasswordCriteriaChanges: truerenderCredentials()andrenderSnapshotCredentials()functions to propagate the option through all credential creation pathsSnapshotCredentials.fromGeneratedSecret()to properly handleurlSafePasswordoption by implementing the same exclusion logic asDatabaseSecretDesign decisions made:
^) to maintain password entropy while solving the specific URL parsing issueDatabaseSecretandSnapshotCredentialsfor unified behaviorAlternatives considered and rejected:
Describe any new or updated permissions being added
N/A - This change only affects password generation character exclusions and does not require any new IAM permissions or resource access patterns.
Description of how you validated changes
Unit tests: Added 7 comprehensive unit tests covering all functionality:
DatabaseSecretSnapshotCredentials.fromGeneratedSecret()withurlSafePasswordfor database instances from snapshotsSnapshotCredentials.fromGeneratedSecret()withurlSafePasswordfor database clusters from snapshotsIntegration tests: Verified existing integration tests continue to pass. No new integration tests required as the feature follows established patterns and existing tests validate the password generation pipeline.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license