How to update terraform state file

I have created a nat gateway using terraform . As nat gateway costs more , I have written a python script to delete the nat gateway every night and create it every morning.

Now when I give terraform plan , the state file will be containing the nat gateway which was deleted right , So it is showing that , a new nat gateway will be created.

I dont want to create a new nat gateway , coz every morning a nat gateway will be created using the python script .

How to handle this issue ? Can I update the state file after creating the new nat gateway ?

It sounds like Terraform isn’t actually managing the NAT gateway any more, as you’ve moved the control to your Python script. Therefore I’d remove it totally from Terraform as you should only have things that are completely managed only using Terraform in the code.