in packages/@aws-cdk/toolkit-lib/lib/api/hotswap/hotswap-deployments.ts [434:495]
function isCandidateForHotswapping(
logicalId: string,
change: cfn_diff.ResourceDifference,
evaluateCfnTemplate: EvaluateCloudFormationTemplate,
): RejectedChange | ResourceChange {
// a resource has been removed OR a resource has been added; we can't short-circuit that change
if (!change.oldValue) {
return {
hotswappable: false,
change: {
reason: NonHotswappableReason.RESOURCE_CREATION,
description: `resource '${logicalId}' was created by this deployment`,
subject: {
type: 'Resource',
logicalId,
resourceType: change.newValue!.Type,
metadata: evaluateCfnTemplate.metadataFor(logicalId),
},
},
};
} else if (!change.newValue) {
return {
hotswappable: false,
logicalId,
change: {
reason: NonHotswappableReason.RESOURCE_DELETION,
description: `resource '${logicalId}' was destroyed by this deployment`,
subject: {
type: 'Resource',
logicalId,
resourceType: change.oldValue.Type,
metadata: evaluateCfnTemplate.metadataFor(logicalId),
},
},
};
}
// a resource has had its type changed
if (change.newValue.Type !== change.oldValue.Type) {
return {
hotswappable: false,
change: {
reason: NonHotswappableReason.RESOURCE_TYPE_CHANGED,
description: `resource '${logicalId}' had its type changed from '${change.oldValue?.Type}' to '${change.newValue?.Type}'`,
subject: {
type: 'Resource',
logicalId,
resourceType: change.newValue.Type,
metadata: evaluateCfnTemplate.metadataFor(logicalId),
},
},
};
}
return {
logicalId,
oldValue: change.oldValue,
newValue: change.newValue,
propertyUpdates: change.propertyUpdates,
metadata: evaluateCfnTemplate.metadataFor(logicalId),
};
}