Terraform plan/apply wants to destroy my instances

1,446 views
Skip to first unread message

Bastien Kim

unread,
May 27, 2016, 7:44:08 PM5/27/16
to Terraform
Hello,

I used terraform to deploy a vpc on aws, everything went well. Now I am trying to add a new instance, so I added it in a new configuration file. But now according to terraform plan, all my old instance will be destroyed and replaced by new ones. I didn't change anything in my config, except adding a new file for a new instance. The only thing that differs on terraform plan is the user data id, and it says "(forces new resource)"
Does anyone have an idea of the issue? What am I doing wrong?

Thank you!

David Maze

unread,
May 31, 2016, 6:59:50 AM5/31/16
to Terraform
On Friday, May 27, 2016 at 7:44:08 PM UTC-4, Bastien Kim wrote:
The only thing that differs on terraform plan is the user data id, and it says "(forces new resource)"

Before, you had told Terraform, "I want an instance to exist, and its user data field should contain 'foo'".  Now you're telling Terraform, "I want an instance to exist, and its user data field should contain 'bar'".  Terraform says, "I can't change the user data after the instance has been created, so I need to destroy and recreate it".

"terraform plan" should tell you what's actually changed, and if you pick its output apart in a text editor, you can set it back.

The best thing to do long-term is to set up your provisioners so that, after Terraform runs to completion, the system is fully functional.  Then you (mostly, usually) don't care whether Terraform wants to destroy and recreate things.

But this is something Terraform likes to do from time to time and it's good to plan for it. 
Reply all
Reply to author
Forward
0 new messages