-
Notifications
You must be signed in to change notification settings - Fork 4k
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
docdb.DatabaseSecret: Secret generated with invalid characters #15732
Comments
@skinny85 I feel like the ideal scenario would be to go with both. The default should be updated as it's technically not a reasonable default to begin with (allowing invalid connection URLs in environments where you cannot encode it), but the option to be able to specify your own |
Fair enough @Voyen! Any chance you could open us a Pull Request implementing this? Here's out "Contributing" guide: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md. Thanks, |
I just submitted a PR which adds property @skinny85 Before changing the default Which option do you prefer?
Thanks. |
@jumic I'd love to see the default changed (under a feature flag, I guess, but hey, I'm on CDKv2, so... whatever). |
Hey @skinny85, I tried to implement the new default exclude characters under a feature flag. Unfortunately, there is one thing I can't solve at the moment. The feature flag has to be evaluated in the constructer of DatabaseSecret. Accessing const cfnSecret = this.node.defaultChild as CfnSecret;
cfnSecret.generateSecretString = {
passwordLength: 41,
secretStringTemplate: JSON.stringify({
username: props.username,
masterarn: props.masterSecret?.secretArn,
}),
generateStringKey: 'password',
excludeCharacters: props.excludeCharacters ?? '"@/', // FeatureFlags.of(this)...
}; Do you have any hints how to solve it? Thanks. |
I think you can safely use |
export class DatabaseSecret extends Secret {
constructor(scope: Construct, id: string, props: DatabaseSecretProps) {
FeatureFlags.of(scope)
super(scope, id, { Error message:
I tried the same on branch
Maybe it's the best to postpone this change until v2 is released. |
Yeah, I see the problem 😕. If you've got the stomach for it, you can work around it: export class DatabaseSecret extends Secret {
constructor(scope: Construct, id: string, props: DatabaseSecretProps) {
const featureConstruct = scope.tryFindChild('@SomeRandomid') as CoreConstruct;
if (!featureConstruct) {
featureConstruct = new CoreConstruct(scope, '@SomeRandomId');
}
FeatureFlags.of(featureConstruct) // now this should work
super(scope, id, {
// ... |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
docdb.DatabaseSecret by default calls aws_secretsmanager.Secret specifying exclusion characters of '"', '@', and '/'.
However since many databases use a 'proto://user:password@host.....' connection URL, a colon should be included in this exclusions list.
I'm currently trying to spin up a mongo-express container in my ECS environment but can't get it to connect because the secret that was generated contains a colon and so the connection URL is invalid.
Reproduction Steps
What did you expect to happen?
A valid secret is generated that can be used in a connection URL
What actually happened?
Secret generated with a ':' in it which makes connection URLs invalid
Environment
Other
Note that while using this within your own applications is controllable (my Spring Boot application builds the connection string and url-encodes the password), providing this to out of the box images as environment secrets is impossible
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: