0
votes

I created a subnet with name private-subnet in AWS using terraform with Terraform cloud as backend state store.

Then I changed the name of subnet to private-subnet1 at AWS using AWS console (UI). Also, I make the same changes on my terraform module too.

But now, when I try to deploy other modules, I am getting an error:

Error: error deleting subnet (subnet-xxxxxxxxxxxxxxxxx): timeout while waiting for state to become 'destroyed' (last state: 'pending', timeout: 20m0s)

Error: error creating subnet: InvalidSubnet.Conflict: The CIDR '192.168.1.0/24' conflicts with another subnet

I tried destroying the whole deployment, but that also not worked. Any suggestions?

1

1 Answers

1
votes

The proper way to rename a resource is through state mv:

This can be used for simple resource renaming, moving items to and from a module, moving entire modules, and more.

Thus you can try to rename your old subnet in resource into the new one as shown in the link documentation.

Similarly you can try removing the resource using state rm. So you could remove your previous subnet resource, and the import new one as created in console.