feat(rds): add urlSafePassword option to DatabaseSecret for URL parser compatibility #35211
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/url
parser fail when parsing database connection URLs containing RDS-generated passwords with caret (^
) characters. The errornet/url: invalid userinfo
prevents 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
urlSafePassword
property toDatabaseSecret
and 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:
urlSafePassword
property: Added optional boolean property toDatabaseSecretProps
,CredentialsBaseOptions
,CredentialsFromUsernameOptions
,SnapshotCredentialsFromGeneratedPasswordOptions
,Credentials
, andSnapshotCredentials
interfacesURL_SAFE_PASSWORD_EXCLUDE_CHARS
constant that extends the default exclusion set with the caret (^
) characterDatabaseSecret
constructor andSnapshotCredentials.fromGeneratedSecret()
method to use URL-safe exclusions whenurlSafePassword: true
excludeCharacters
parameter takes precedence overurlSafePassword
option for maximum user controlurlSafePassword
in logical ID hash calculation for proper secret replacement whenreplaceOnPasswordCriteriaChanges: true
renderCredentials()
andrenderSnapshotCredentials()
functions to propagate the option through all credential creation pathsSnapshotCredentials.fromGeneratedSecret()
to properly handleurlSafePassword
option by implementing the same exclusion logic asDatabaseSecret
Design decisions made:
^
) to maintain password entropy while solving the specific URL parsing issueDatabaseSecret
andSnapshotCredentials
for 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:
DatabaseSecret
SnapshotCredentials.fromGeneratedSecret()
withurlSafePassword
for database instances from snapshotsSnapshotCredentials.fromGeneratedSecret()
withurlSafePassword
for 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