aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

[AWS::EC2::SubnetRouteTableAssociation] - [Enhancement] - CFN to not delete the route table association with the old subnet during an update to the subnet with UpdateReplacePolicy: Retain.

Open
#2,166 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::EC2::SubnetRouteTableAssociation

### Resource name

_No response_

### Description

It is understood that UpdateReplacePolicy: Retain keeps the physical instance of a resource when it's replaced during a stack update.

Currently it is seen that when updating the Subnet resource that the AWS::EC2::SubnetRouteTableAssociation resource is associated with, and specifying UpdateReplacePolicy: Retain for both resources, CFN disassociates the route table association with the old subnet and replaces both resources during the update.

Would like to request that CFN doesn't delete the route table association with the old subnet when updating the SubnetId of AWS::EC2::SubnetRouteTableAssociation resource with UpdateReplacePolicy: Retain.

Behaviour can be replicated using sample template below:
....
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.16.0.0/16

PrivateRouteTable:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId:
Ref: "VPC"

PrivateSubnet:
Type: "AWS::EC2::Subnet"
UpdateReplacePolicy: Retain
Properties:
VpcId: !Ref VPC
AvailabilityZone:
CidrBlock: 10.16.0.0/24

PrivateSubnetRouteTableAssociation:
Type: "AWS::EC2::SubnetRouteTableAssociation"
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
SubnetId: !Ref PrivateSubnet
RouteTableId: !Ref PrivateRouteTable
....

Let's say the subnet ID is subnet-abc and the Route Table Association ID is rtbassoc-123.

Next when performing an update to the subnet resource, for example changing the CidrBlock from 10.16.0.0/24 to 10.16.1.0/24, the update will require replacement on the Route Table Association resource as expected. Meaning the new subnet ID is subnet-def and the Route Table Association ID is rtbassoc-456, albeit subnet-abc still remains in the account.

Hoping to have the old route table association with the old subnet not be deleted as currently it makes it complicated when deploying using Lamdba, etc.

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the sample CloudFormation template and reproduce the subnet replacement using UpdateReplacePolicy: Retain on both resources. Compare the resulting old and new subnet route-table associations; done means the association with subnet-abc remains after the update while the new association is created for subnet-def.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.