Understanding Removal of the Resources
When working in a declarative configuration model, you do not explicitly mark objects for deletion. Instead, if an object is absent from the data model, it is removed from the deployed configuration.
Terraform not only creates and updates resources—it also handles safe and predictable removal of resources no longer defined in configuration. This behavior is a core part of Infrastructure as Code and ensures the deployed environment reflects the desired state.
Terraform tracks every managed resource in the state file. During a terraform plan, it compares:
- What is currently deployed (from the state),
- What should exist (from your configuration files). If a resource exists in the state file but no longer appears in your configuration, Terraform marks it for deletion.
Let’s review one example. You do not need to follow along; this is for educational context.
In our configuration, assume SNMP is defined:
... snmp: access: users users: - username: ${snmp_username} passphrase: !env secret_passwordIf we decide we no longer want SNMP configured, we remove this configuration from the YAML file.
When re-running terraform plan, Terraform identifies that the resource will be destroyed:
# module.meraki.meraki_network_snmp.networks_snmp["US/Unified Branch Learning Org/Unified Branch"] will be destroyed # (because key ["US/Unified Branch Learning Org/Unified Branch"] is not in for_each map) - resource "meraki_network_snmp" "networks_snmp" { - access = "users" -> null - id = "L_3859584880656524698" -> null - network_id = "L_3859584880656524698" -> null - users = [ - { - passphrase = "C1sco12345!!66" -> null - username = "snmpuser" -> null }, ] -> null }Always review the plan carefully before applying to understand the impact, especially when deletions are involved.