spikeheap
spikeheap

Reputation: 3887

How can I merge Terraform state drift back into configuration files?

I have a Terraform script which provisions AWS infrastructure with (among other things) a set of security groups.

Over time, these security groups have had a bunch of extra IP ranges added through the AWS console, so there's a drift between the .tf files and the real-world state.

Running terraform plan shows these differences, and wants to roll back to Terraform's configured state.

What I'd like to achieve is to (programmatically) update the .tf files' security group definition to reflect these additional IP ranges, bringing Terraform up-to-date and (hopefully) increasing the chances it'll be used to manage state changes in future.

Upvotes: 0

Views: 894

Answers (1)

Ignacio Millán
Ignacio Millán

Reputation: 8026

That is a pending feature in Terraform: https://github.com/hashicorp/terraform/issues/15608

In that issue there are linked two projects that can help:

https://github.com/dtan4/terraforming

https://gitlab.com/Nowaker/terraform-import-as-hcl

Upvotes: 1

Related Questions