-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(cloudformation): resolve dynamic references for all template values #3301
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -67,6 +67,34 @@ public String resolveDynamicReferences(String value, String region, boolean allo | |
| return sb.toString(); | ||
| } | ||
|
|
||
| /** | ||
| * Resolves dynamic references in a general (non-RDS-master-credential) template value, the | ||
| * same way {@link #resolveDynamicReferences} does, except a {@code ssm-secure} reference is | ||
| * left verbatim instead of rejected. {@code ssm-secure} is valid only for | ||
| * {@code MasterUsername}/{@code MasterUserPassword}, but this general stage runs on every | ||
| * property before the RDS provisioner gets its own turn at those two with | ||
| * {@code allowSsmSecure=true}; rejecting it here would reject a value RDS is about to accept. | ||
| */ | ||
| public String resolveGeneralPropertyDynamicReferences(String value, String region) { | ||
| if (value == null || !value.contains("{{resolve:")) { | ||
| return value; | ||
| } | ||
| Matcher m = DYNAMIC_REF.matcher(value); | ||
| StringBuilder sb = new StringBuilder(); | ||
| int previousEnd = 0; | ||
| while (m.find()) { | ||
| rejectUnclosedDynamicReference(value.substring(previousEnd, m.start())); | ||
| String replacement = "ssm-secure".equals(m.group(1)) | ||
| ? m.group(0) | ||
| : resolveDynamicRef(m.group(1), m.group(2), region, false); | ||
|
Comment on lines
+87
to
+89
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.
The general resolver leaves every Context Used: AGENTS.md (source) |
||
| m.appendReplacement(sb, Matcher.quoteReplacement(replacement)); | ||
| previousEnd = m.end(); | ||
| } | ||
| rejectUnclosedDynamicReference(value.substring(previousEnd)); | ||
| m.appendTail(sb); | ||
| return sb.toString(); | ||
| } | ||
|
|
||
| private String resolveDynamicRef(String service, String body, String region, boolean allowSsmSecure) { | ||
| if ("secretsmanager".equals(service)) { | ||
| // body = <secret-id-or-arn>:SecretString:<json-key>:<version-stage>:<version-id>. The | ||
|
|
||
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.
RDS
ssm-securecredentials now fail before reaching the RDS-specific resolver.resolveOptionalinvokesengine.resolve, whose new general resolver disallowsssm-secure. The later call withallowSsmSecure=trueis therefore never reached, so validMasterUserPasswordreferences for DB instances and clusters raiseValidationError.