Why TF will destroy VPC?

We are using the following module to maintain VPCs:
Recently “something” has been changed in the code and now terraform apply is going to delete and recreate it - this is the message:

# module.vpc.aws_vpc.this[0] will be destroyed
- resource "aws_vpc" "this" {
- arn                              = "arn:aws:ec2:eu-west-1:xxx:vpc/vpc-yyy" -> null
- assign_generated_ipv6_cidr_block = false -> null
- cidr_block                       = "" -> null
- default_network_acl_id           = "acl-..." -> null
- default_route_table_id           = "rtb-..." -> null
- default_security_group_id        = "sg-..." -> null
- dhcp_options_id                  = "dopt-..." -> null
- enable_classiclink               = false -> null
- enable_classiclink_dns_support   = false -> null
- enable_dns_hostnames             = true -> null
- enable_dns_support               = true -> null
- id                               = "vpc-..." -> null
- instance_tenancy                 = "default" -> null
- main_route_table_id              = "rtb-..." -> null
- owner_id                         = "..." -> null

Is there any way I can investigate why it is going to be deleted ?

Hi @przemolb,

The only reason why Terraform would propose to destroy an object like this is if that object is no longer declared in the configuration.

There several ways that could be true, such as:

  • The resource "aws_vpc" "this" block is no longer in the configuration of that module.
  • The resource block is still present but either its count argument is now set to zero or it doesn’t have count set at all, and therefore there’s no longer a [0] element declared for that resource.
  • There’s no longer a module "vpc" block in the root module, and so all of the objects previously declared by that module must now be destroyed.

Thanks @apparentlymart for your response.
I really miss more clear information from TF why particular resources is going to be destroyed.