mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
fix(cloudformation): a dropped Properties block replaces a resource with a create-only value (#8438)
A template update that drops a resource's whole Properties block now counts as removing every property in it, so a create-only value that was there means Replacement: True and a replaced resource, as removing that property alone already does. The change set said no replacement, so a provisioner that follows the engine kept the resource under its old name. PropertyChanges reads a dropped block the same way when it has no engine answer. Part of #6606
This commit is contained in:
1 parent
0de78cafb1
commit
9c1e5c1163
4 files changed
+20
-4
No files matched your search
@@ -1681,9 +1681,16 @@ public class CloudFormationService implements ResourceProvider {
|
||||
|
||||
private boolean requiresReplacement(String resourceType, JsonNode oldProps, JsonNode newProps,
|
||||
Set<String> changedParams, Set<String> changedConditions) {
|
||||
if (oldProps == null || newProps == null || oldProps.isMissingNode() || newProps.isMissingNode()) {
|
||||
if (oldProps == null || oldProps.isMissingNode()) {
|
||||
return false;
|
||||
}
|
||||
if (newProps == null || newProps.isMissingNode()) {
|
||||
// A dropped Properties block removes every property in it, as removing them one by one does.
|
||||
if (!oldProps.isObject()) {
|
||||
return false;
|
||||
}
|
||||
newProps = objectMapper.createObjectNode();
|
||||
}
|
||||
if (CfnCreateOnlyProperties.hasSchema(resourceType)) {
|
||||
// The registry table names the exact pointers; only a value at one of them replaces.
|
||||
if (CfnCreateOnlyProperties.createOnlyValueChanged(resourceType, oldProps, newProps)) {
|
||||
|
||||
+5
-3
@@ -1,6 +1,7 @@
|
||||
package io.floci.aws.services.cloudformation.provisioners;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import io.floci.aws.services.cloudformation.CfnCreateOnlyProperties;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -75,13 +76,14 @@ public record PropertyChanges(Map<String, PropertyChange> byName, boolean requir
|
||||
JsonNode priorProperties, JsonNode properties,
|
||||
JsonNode comparedPrior, JsonNode comparedCurrent,
|
||||
Boolean engineReplacement) {
|
||||
boolean currentIsObject = properties != null && properties.isObject();
|
||||
// A dropped Properties block removes every property in it, as the engine reads it.
|
||||
boolean replaces = engineReplacement != null
|
||||
? engineReplacement
|
||||
: update && resourceType != null && priorProperties != null && priorProperties.isObject()
|
||||
&& properties != null && properties.isObject()
|
||||
&& CfnCreateOnlyProperties.createOnlyValueChanged(resourceType, priorProperties, properties);
|
||||
&& CfnCreateOnlyProperties.createOnlyValueChanged(resourceType, priorProperties,
|
||||
currentIsObject ? properties : JsonNodeFactory.instance.objectNode());
|
||||
Map<String, PropertyChange> changes = new LinkedHashMap<>();
|
||||
boolean currentIsObject = properties != null && properties.isObject();
|
||||
if (!update || priorProperties == null || !priorProperties.isObject()) {
|
||||
if (currentIsObject) {
|
||||
properties.fieldNames().forEachRemaining(name -> changes.put(name,
|
||||
|
||||
Reference in new issue
Block a user