chore(cloudformation): reuse the launch configuration replacement decision (#8664)

Use the shared replacement decision for launch configurations, removing the duplicate ADDED guard now that #8471 makes an added create-only value require replacement for every resource type. The unit fixture derives that decision instead of forcing the obsolete false result.

Also make the negative card-validation fixture deterministic: it generates the valid value and changes its first digit, instead of a fixed 999 that could match the CVV for the randomly generated key.
This commit is contained in:
Jackson Price authored and GitHub committed 2026-11-16 19:48:37 -04:00
1 parent 47466ca6a8
commit bab6428f78
3 files changed
+20 -27

No files matched your search

@@ -211,7 +211,7 @@ public class AutoScalingGroupCfnProvisioner implements CfnResourceProvisioner {
n -> requireLaunchConfiguration(region, n));
if (ctx.isUpdate()) {
ReplacementCleanup.endRollbackRetry(r);
if (!launchConfigurationRequiresReplacement(props, ctx)
if (!ctx.changes(LAUNCH_CONFIGURATION, props).requiresReplacement()
&& ctx.reusesPriorEntity(name) && prior != null) {
return;
}
@@ -236,19 +236,6 @@ public class AutoScalingGroupCfnProvisioner implements CfnResourceProvisioner {
ReplacementCleanup.record(r, ctx, before);
}
private static boolean launchConfigurationRequiresReplacement(JsonNode props, ProvisionContext ctx) {
PropertyChanges changes = ctx.changes(LAUNCH_CONFIGURATION, props);
if (changes.requiresReplacement()) {
return true;
}
if (ctx.priorProperties() == null) {
return false;
}
// The shared replacement flag currently omits newly added create-only properties.
return changes.byName().values().stream()
.anyMatch(change -> change.createOnly() && change.kind() == PropertyChanges.Kind.ADDED);
}
@Override
public boolean hasReplacementUpdate(StackResource resource) {
return LAUNCH_CONFIGURATION.equals(resource.getResourceType()) && ReplacementCleanup.hasReplacement(resource);