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/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