AWS Resource UpdateReplacePolicy - krdheeraj51/aws-labs GitHub Wiki

Overview

The UpdateReplacePolicy attribute specifies what happens to a resource when it is replaced during a stack update operation. This attribute is particularly useful for managing resources that need to be preserved or backed up when they are replaced.

Key Points about UpdateReplacePolicy:

Purpose:

The UpdateReplacePolicy attribute is used to retain, create a snapshot, or delete the existing physical instance of a resource when it is replaced during a stack update.

Options:

  • Retain: Keeps the old resource without deleting it. This is useful for resources that contain important data you want to preserve.

  • Snapshot: Creates a snapshot of the resource before deleting it. This is applicable to resources that support snapshots, such as RDS databases and EBS volumes.

  • Delete: Deletes the old resource. This is the default behavior if no UpdateReplacePolicy is specified.

When It Applies:

The UpdateReplacePolicy attribute is only executed if you update a resource property that requires replacement. For example, changing the Engine property of an AWS::RDS::DBInstance resource type will trigger a replacement.

Differences from DeletionPolicy:

  • DeletionPolicy: Specifies what happens to a resource when the stack is deleted or when the resource definition is removed from the template.
  • UpdateReplacePolicy: Specifies what happens to a resource when it is replaced during a stack update.