refactor(cloudformation): one dynamic reference marker for the template engine and the compared template (#8280)

* refactor(cloudformation): one dynamic reference marker for the template engine and the compared template
This commit is contained in:
Oleksandr Nikolaichuk authored and GitHub committed 2026-11-16 14:50:03 -04:00
1 parent 39f2426ba2
commit 95fa805590
2 files changed
+5 -3

No files matched your search

@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.node.TextNode;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.AwsRegions;
import io.floci.aws.services.cloudformation.provisioners.CfnDynamicReferences;
import org.jboss.logging.Logger;
import java.util.ArrayList;
@@ -441,7 +442,7 @@ public class CloudFormationTemplateEngine {
*/
private TextNode resolveDynamicReferences(String value) {
if (dynamicReferenceResolver == null || dynamicReferencesSuspended > 0 || value == null
|| !value.contains("{{resolve:")) {
|| !CfnDynamicReferences.holdsDynamicReference(value)) {
return TextNode.valueOf(value);
}
return TextNode.valueOf(dynamicReferenceResolver.apply(value));
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import io.floci.aws.services.cloudformation.provisioners.CfnDynamicReferences;
import java.util.HashSet;
import java.util.List;
@@ -33,7 +34,6 @@ final class ComparedTemplate {
"Type", "Properties", "Metadata", "DeletionPolicy", "UpdateReplacePolicy", "UpdatePolicy");
private static final List<String> OUTPUT_KEYS = List.of("Value", "Description", "Export");
private static final Pattern SUB_VARIABLE = Pattern.compile("\\$\\{([^}]*)}");
private static final String DYNAMIC_REFERENCE = "{{resolve:";
private final ObjectMapper objectMapper;
private final CloudFormationTemplateEngine engine;
@@ -233,7 +233,8 @@ final class ComparedTemplate {
private JsonNode dynamicReferencesIn(JsonNode node) {
if (node.isTextual()) {
String text = node.asText();
return text.contains(DYNAMIC_REFERENCE) ? TextNode.valueOf(dynamicReferenceValue.apply(text)) : node;
return CfnDynamicReferences.holdsDynamicReference(text)
? TextNode.valueOf(dynamicReferenceValue.apply(text)) : node;
}
if (node.isArray()) {
ArrayNode array = objectMapper.createArrayNode();