Articles → AWS → UpdateReplacePolicy Attribute In AWS CloudFormation

UpdateReplacePolicy Attribute In AWS CloudFormation






Purpose




ValueDescription
Retain The existing resource is preserved instead of being deleted when replaced.
Delete The existing resource is deleted when replaced (default behaviour).
Snapshot A snapshot of the resource is taken before deletion.



Create An S3 Bucket




AWSTemplateFormatVersion: "2010-09-09"
Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: updatereplacepolicygyansangrah1


Picture showing the bucket updatereplacepolicygyansangrah1 is created using CloudFormation template




AWSTemplateFormatVersion: "2010-09-09"
Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: updatereplacepolicygyansangrah2


Picture showing the bucket updatereplacepolicygyansangrah2 is created using CloudFormation template





Updatereplacepolicy Attribute Comes Into Picture




AWSTemplateFormatVersion: "2010-09-09"
Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: updatereplacepolicygyansangrah1
    UpdateReplacePolicy: Retain




AWSTemplateFormatVersion: "2010-09-09"
Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: updatereplacepolicygyansangrah2
    UpdateReplacePolicy: Retain



Output


Picture showing the bucket updatereplacepolicygyansangrah1 is retained UpdateReplacePolicy equal to retain



Posted By  -  Karan Gupta
 
Posted On  -  Sunday, March 16, 2025

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250