(EFS): EFS Mount Targets fail if subnets change positions within the vpc_subnets
property
#27397
Labels
@aws-cdk/aws-efs
Related to Amazon Elastic File System
bug
This issue is a bug.
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
needs-cfn
This issue is waiting on changes to CloudFormation before it can be addressed.
p2
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Describe the bug
When changing the
vpc_subnets
property of an EFSFileSystem
construct, the order of existing subnets is required to stay the same or else an error will occur on update stating that a mount target already exists for a certain AZ.Expected Behavior
Expected behavior is that the subnets can be changed for
vpc_subnets
without any failure to update. In theory, any subnets that remain during any update should retain the exact same logical ID and property definitions for the created mount target.Current Behavior
Currently, the order of subnets within
vpc_subnets
is required to be unchanging between stack updates.Example:
Assume there are 3 subnets defined
And assume that a stack with an EFS FileSystem is created with the following
vpc_subnets
:If
subnet2
is removed as follows,then the generated MountTarget created for
subnet3
will be deleted, and the MountTarget forsubnet2
will have it'sSubnetId
value changed tosubnet3
This causes a failure since the existing mount target will try to update to use
subnet3
when the MountTarget originally created forsubnet3
still exists.Secondary example:
With the same subnets defined as above, assume a stack with an EFS FileSystem is created with the following
vpc_subnets
:Now is
subnet1
andsubnet2
swap indexes like this,This will also cause the failure because the generated MountTarget resources remain consistent and match their value for the
SubnetId
property to the matching index value defined forvpc_subnets
.Reproduction Steps
Define 2 subnets
Create an EFS FileSystem as follows:
Then swap the positions of
subnet1
andsubnet2
The update will trigger the error reliably.
Possible Solution
CDK seems to need some way to maintain a direct connection between the generated MountTarget resources and their respective subnets.
Currently the MountTarget resources are matched to the subnets based on their index value with
vpc_subnets
which is prone to error and requires any subnets to maintain the exact same position in the array during updates.Additional Information/Context
This issue has been noted before here: #25099
Ultimately this issue was closed with a fix that maps the logical ID of the EFS MountTarget resources to index values: #26155
However, the issue appears to persist still, and the fix did not address the main issue where subnet IDs are assigned to different MountTarget IDs based on their index number.
One possible solution would be to map the MountTarget logical IDs to be suffixed with the subnet ID instead of indexes. In theory this should allow the same MountTarget logical IDs to be generated no matter where the subnet is within the index of
vpc_subnets
.CDK CLI Version
2.99.1
Framework Version
No response
Node.js Version
18.18.0
OS
Windows 10
Language
Python
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: