Describe the bug
When removing an EFS Mount point from a CDK deployment (say by defining fewer subnets than what are previously deployed), CDK will remove the correct mount point but will use the old unique Id for the deleted one if that subnet is in the middle of the subnet list. This will cause CloudFormation to fail as it tries to make a new Mount Point for the same EFS File System in the same AZ, which it can't do.
Expected Behavior
If I have a CDK construct
const fileSystem = new FileSystem(this, "EfsFileSystem", {
vpc,
vpcSubnets: {
subnets: [subnetA, subnetB, subnetC]
}
})
This will synth 3 Mount points, eg.
EfsFileSystemEfsMountTarget01:
Properties:
SubnetId: subnetA
EfsFileSystemEfsMountTarget02:
Properties:
SubnetId: subnetB
EfsFileSystemEfsMountTarget03:
Properties:
SubnetId: subnetC
When I remove one of the subnets, i.e. remove subnet B
const fileSystem = new FileSystem(this, "EfsFileSystem", {
vpc,
vpcSubnets: {
subnets: [subnetA, subnetC]
}
})
CDK synth will create 2 mount points with correct Ids
EfsFileSystemEfsMountTarget01:
Properties:
SubnetId: subnetA
EfsFileSystemEfsMountTarget03:
Properties:
SubnetId: subnetC
Current Behavior
If I have a CDK construct
const fileSystem = new FileSystem(this, "EfsFileSystem", {
vpc,
vpcSubnets: {
subnets: [subnetA, subnetB, subnetC]
}
})
This will synth 3 Mount points, eg.
EfsFileSystemEfsMountTarget01:
Properties:
SubnetId: subnetA
EfsFileSystemEfsMountTarget02:
Properties:
SubnetId: subnetB
EfsFileSystemEfsMountTarget03:
Properties:
SubnetId: subnetC
When I remove one of the subnets, i.e. remove subnet B
const fileSystem = new FileSystem(this, "EfsFileSystem", {
vpc,
vpcSubnets: {
subnets: [subnetA, subnetC]
}
})
CDK synth will create 2 mount points with an incorrect Id
EfsFileSystemEfsMountTarget01:
Properties:
SubnetId: subnetA
EfsFileSystemEfsMountTarget02:
Properties:
SubnetId: subnetC
Note the subnet names and unique Ids have changed for one of the mount targets.
Which is technically correct, but now CloudFormation will fail with this error:
mount target already exists in this AZ
This is because since the uniqueid of the mount target in subnetC has changed it's trying to create a new one.
Reproduction Steps
Create a CDK construct with an EFS attached to 3 subnets.
const fileSystem = new FileSystem(this, "EfsFileSystem", {
vpc,
vpcSubnets: {
subnets: [subnetA, subnetB, subnetC]
}
})
now delete subnetB.
Possible Solution
CDK needs to keep track of the subnets and mount target unique IDs somehow
Additional Information/Context
No response
CDK CLI Version
2.67.0
Framework Version
No response
Node.js Version
18.12.1
OS
Windows
Language
Typescript
Language Version
No response
Other information
No response
Describe the bug
When removing an EFS Mount point from a CDK deployment (say by defining fewer subnets than what are previously deployed), CDK will remove the correct mount point but will use the old unique Id for the deleted one if that subnet is in the middle of the subnet list. This will cause CloudFormation to fail as it tries to make a new Mount Point for the same EFS File System in the same AZ, which it can't do.
Expected Behavior
If I have a CDK construct
This will synth 3 Mount points, eg.
When I remove one of the subnets, i.e. remove subnet B
CDK synth will create 2 mount points with correct Ids
Current Behavior
If I have a CDK construct
This will synth 3 Mount points, eg.
When I remove one of the subnets, i.e. remove subnet B
CDK synth will create 2 mount points with an incorrect Id
Which is technically correct, but now CloudFormation will fail with this error:
This is because since the uniqueid of the mount target in subnetC has changed it's trying to create a new one.
Reproduction Steps
Create a CDK construct with an EFS attached to 3 subnets.
now delete subnetB.
Possible Solution
CDK needs to keep track of the subnets and mount target unique IDs somehow
Additional Information/Context
No response
CDK CLI Version
2.67.0
Framework Version
No response
Node.js Version
18.12.1
OS
Windows
Language
Typescript
Language Version
No response
Other information
No response