-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(secretsmanager): allow templated string creation #2010
Changes from 1 commit
35d9600
2608bca
c04beda
280af79
ac12ecf
92b87ff
41f15a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ export interface SecretProps { | |
* @default 32 characters with upper-case letters, lower-case letters, punctuation and numbers (at least one from each | ||
* category), per the default values of ``SecretStringGenerator``. | ||
*/ | ||
generateSecretString?: SecretStringGenerator; | ||
generateSecretString?: SecretStringGenerator | TemplatedSecretStringGenerator; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unions do not translate very nicely across programming languages since some languages don't support them, so we forbid unions at the L2 layer. The solution is usually to define an abstract class with a bunch of static factory methods for the various options. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An easy solution here could be to integrate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't work: new secretsmanager.Secret(this, 'Secret', {
generateSecretString: {
secretStringTemplate: JSON.stringify({ username: 'username' }),
generateStringKey: 'password',
excludeCharacters: '"@/\\'
}
})
You mean like this? new secretsmanager.Secret(this, 'Resource', {
generateSecretString: ({
secretStringTemplate: JSON.stringify({ username: 'username' }),
generateStringKey: 'password',
excludeCharacters: '"@/\\'
}) as secretsmanager.TemplatedSecretStringGenerator
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RomainMuller it's not a comfortable interface for value-typed interfaces. TSC is not going to search the whole type space for a type that matches your literal object AND happens to be assignable to a It's actually good that it doesn't because I'm not sure the semantics would be preserved when using it via JSII. We can either make 2 arguments at the top-level: secretStringGenerator?: SecretStringGenerator;
templatedSecretStringGenerator?: TemplatedSecretStringGenerator; OR Fold the 2 structures together and do some run-time analysis OR Define an interface and 2 classes and some factory functions. Preferences? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If nobody expresses a preference by Monday I'm going to pick something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I have a preference for this solution... |
||
|
||
/** | ||
* A name for the secret. Note that deleting secrets from SecretsManager does not happen immediately, but after a 7 to | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why rid of the semicolon?