---
title: "CloudFormation custom-named resource replacement: read the change set | Proofline"
description: "If an update fails on a resource whose template sets its name, check whether the change replaces that resource."
url: https://proofline.sh/learn/cloudformation-custom-named-resource-replacement/
---

[Learning center](/learn/)

# CloudFormation custom-named resource replacement: read the change set

If an update fails on a resource whose template sets its name, check whether the change replaces that resource. A change set's Replacement field and the property that forces it separate this failure from a name already taken and from an in-place update the service rejected.

Deployment failures The Proofline team November 22, 2026 6 min read

## Why a fixed name blocks replacement

CloudFormation updates a resource in one of three ways, depending on which property changed: without interruption, with some interruption, or by replacement. A replacement gets a new physical ID. CloudFormation usually creates the replacement first, points dependent resources at it, and then deletes the old resource. [Update behaviors of stack resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html)

That order needs two resources to exist at once. When the template sets the resource's name, the replacement would need the name the old resource still holds. AWS documents the limit: you can't perform an update that causes a custom-named resource to be replaced, and if you must replace it, specify a new name. Each resource type's template reference marks the properties whose change requires replacement. For `AWS::DynamoDB::Table`, a change to `KeySchema` requires replacement, and `TableName` sets a custom name. [Custom resource names](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-name.html) · [AWS::DynamoDB::Table](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-dynamodb-table.html)

Three update failures can look alike in the stack events because each names a resource that has a custom name:

-   **A replacement collides with the name.** The resource is modified, the change requires replacement, and the reason says CloudFormation cannot update a stack when a custom-named resource requires replacing.
-   **The name is already taken by something outside the stack.** The resource is being added, under a new logical ID or with a new name, and the service reports that a resource with that name exists.
-   **An in-place update failed.** No replacement was involved, and the reason carries the service's own error about the property.

## Read the change set

The status reason tells you which resource failed. The change set tells you why CloudFormation chose to replace it. Use a read-only profile and replace the uppercase placeholders. Start with the failure itself. [Stack events](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-stack-events.html)

```
aws cloudformation describe-stack-events \
  --profile PROFILE --region REGION --stack-name STACK --max-items 300 \
  --query 'reverse(StackEvents[?ResourceType==`"AWS::CloudFormation::Stack"` || ends_with(ResourceStatus, `"FAILED"`)])[].[Timestamp,LogicalResourceId,ResourceType,ResourceStatus,ResourceStatusReason]' \
  --output json --no-cli-pager
```

If the update ran from a change set, describe that change set. If it ran directly from a template, create a change set from the same template and parameters. Creating one changes no resource; CloudFormation makes no changes until a change set is executed. Delete it afterwards if you don't execute it. [CreateChangeSet](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html) · [create-change-set](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-change-set.html)

```
# Creates a change set object only; no resource changes until it is executed.
aws cloudformation create-change-set \
  --profile PROFILE --region REGION --stack-name STACK \
  --change-set-name replacement-check --change-set-type UPDATE \
  --template-body file://TEMPLATE_FILE --parameters file://PARAMETERS_FILE \
  --no-cli-pager
```

Add `--capabilities` if the template needs them. Then read what the change would do to the failing resource. `--include-property-values` adds the values before and after the change. [describe-change-set](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-change-set.html) · [ResourceChange fields](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ResourceChange.html)

```
aws cloudformation describe-change-set \
  --profile PROFILE --region REGION --stack-name STACK --change-set-name replacement-check \
  --include-property-values \
  --query 'Changes[?ResourceChange.LogicalResourceId==`"LOGICAL_ID"`].ResourceChange.{action:Action,physical:PhysicalResourceId,replacement:Replacement,policy:PolicyAction,details:Details[].{property:Target.Name,path:Target.Path,recreation:Target.RequiresRecreation,evaluation:Evaluation,source:ChangeSource,cause:CausingEntity,before:Target.BeforeValue,after:Target.AfterValue}}' \
  --output json --no-cli-pager
```

## What the fields mean

`Replacement` applies to a `Modify` action. It is `True` when a changed property has `RequiresRecreation` of `Always` and CloudFormation knows the new value (`Evaluation` is `Static`). It is `Conditional` when the property's recreation is conditional, or when the new value depends on an intrinsic function that CloudFormation resolves only during the update (`Evaluation` is `Dynamic`). With several changes, the one with the most impact decides. [ResourceTargetDefinition](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ResourceTargetDefinition.html) · [ResourceChangeDetail](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ResourceChangeDetail.html)

| Change set shows | Template | Most likely cause |
| --- | --- | --- |
| `Modify`, `Replacement` `True`, a detail with `RequiresRecreation` `Always` | Sets the resource's name | The replacement collides with the name |
| `Modify`, `Replacement` `Conditional`, `ChangeSource` `ResourceReference` or `ResourceAttribute` | Sets the resource's name | A resource this one references is being replaced, and this one may follow |
| `Add` | Sets a name that exists outside the stack | The name is already taken |
| `Modify`, `Replacement` `False` | Either | An in-place update failed; read the service's error in the reason |

The detail's `property` and `cause` say what forced the replacement. `DirectModification` means the template changed that property itself. `ParameterReference` names the parameter whose new value changed it, which is easy to miss when the template file did not change. `policy` shows what happens to the old resource if the replacement goes through: `ReplaceAndDelete`, `ReplaceAndRetain` or `ReplaceAndSnapshot`.

## Two illustrative updates

This fixture is fictional. Stack `orders-prod` holds `OrdersTable`, an `AWS::DynamoDB::Table` with `TableName: orders`.

In the first update, a pull request changes the table's `KeySchema` to add a sort key. The change set shows `Modify`, `Replacement` `True`, and a detail for `KeySchema` with `RequiresRecreation` `Always` and `ChangeSource` `DirectModification`. CloudFormation would need a second table named `orders` while the first exists, so the update fails on `OrdersTable`.

In the second update, the pull request moves the table to a new logical ID, `OrdersTableV2`, and keeps `TableName: orders`. The change set shows `Add` for `OrdersTableV2` and `Remove` for `OrdersTable`. CloudFormation deletes resources a template drops only in the cleanup phase, `UPDATE_COMPLETE_CLEANUP_IN_PROGRESS`, after the update's new resources exist. The add fails because the name is taken, and the reason carries DynamoDB's error. Renaming the logical ID did not avoid a collision; it caused a different one.

## What to change

Pick the change that keeps the data you need. Each option is a template edit reviewed in a pull request.

-   **Give the replacement a new name.** AWS's documented fix. CloudFormation creates a new resource under the new name and then handles the old one as `policy` shows. For a table or a bucket, a replacement starts empty; moving data is your job.
-   **Remove the name property.** CloudFormation then generates a unique physical ID for the replacement. Anything that finds the resource by its old name must read the new one from the stack's outputs instead.
-   **Avoid the replacing change.** Some changes have an in-place equivalent on the same resource type, or belong on a new resource beside the old one.

Before you execute, set `UpdateReplacePolicy` to `Retain` or `Snapshot` where the type supports it, if the old resource holds data you may need. Confirm on the next change set that `Replacement` and `policy` show what you intend, then on the stack events that the resource reached `UPDATE_COMPLETE` under its new physical ID. Compare with other deploy records in the [signature table](/learn/aws-deployment-failure-signatures/).

## Where this read misleads

A change set describes the template and parameters you give it now, against the stack as CloudFormation records it. If someone changed the resource outside CloudFormation, the record and the live resource differ. Only a drift-aware change set reports that, in `ResourceDriftStatus`; an ordinary one does not. A stack left in that state after a skipped rollback has the same problem: [skipped resources no longer match the template](/learn/cloudformation-update-rollback-failed/).

`Conditional` is not an answer. It means CloudFormation decides during the update, often because a referenced resource is itself replaced. Follow `cause` to that resource and check whether its own change is `True`.

## Questions

### Why can't CloudFormation replace a resource with a custom name?

CloudFormation usually creates the replacement before deleting the old resource, so both would need the same name at once. AWS's guidance is to give the resource a new name when it must be replaced.

### How do I know whether a stack update will replace a resource?

Create a change set and read `ResourceChange.Replacement` for the resource. `True` means replacement, `Conditional` means CloudFormation decides during the update, and each detail's `RequiresRecreation` names the property responsible.

### Does removing the name property from the template avoid data loss?

No. It lets the replacement succeed under a generated name, but the replacement is still a new resource. Set `UpdateReplacePolicy` and plan the data move before you execute it.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [UPDATE\_ROLLBACK\_FAILED in CloudFormation: find what can't roll back](/learn/cloudformation-update-rollback-failed/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
    
-   ### [CloudFormation ECS service did not stabilize: find the real failure](/learn/cloudformation-ecs-service-did-not-stabilize/)
    
    Deployment failures The Proofline team November 22, 2026 7 min read
