Terraform scaning missing resource

Hi everyone,
how can i validate any missing resource during the plan or validating the terraform file?
suppose i want to check security group must be created via terraform, but somehow i get skip how can i enforce its creation during validation or plan?
please help to sort out this issue

If a plan doesn’t show changes for a particular resource (for example a security group) it means there are no changes to make as the code matches the settings seen in reality.

Having said that you can use terraform taint to “taint” a resource, which will cause it to be destroyed & recreated.

1 Like

Want to show an error like security group resource is missing in the terraform file/configuration

Terraform will typically not return an error if it learns that something has been deleted outside of Terraform, but modern Terraform (since one of the v0.15 minor releases, or all of the v1.0.x releases) will report that it detected changes outside of Terraform as part of describing the plan:

Note: Objects have changed outside of Terraform

However, this only applies to objects that the current Terraform configuration is managing. “Managing” means either that this Terraform configuration was the one that originally created the object, or that you used terraform import to make this configuration responsible for some existing object created outside of Terraform.

There is no way to make Terraform report on objects that it isn’t managing, because Terraform intentionally considers those objects out of scope, assuming that they are managed by some other system – either a separate Terraform configuration or some other non-Terraform system.