Why terraform wants to set the wrong flag on EBS volume and recreate instance?

215 views
Skip to first unread message

egul...@gmail.com

unread,
May 17, 2018, 2:31:49 PM5/17/18
to Terraform
Hello,

I have the following code for Terraform 0.11.5:

resource "aws_instance" "worker2_ec2" {
  instance_type          = "r4.2xlarge"
  subnet_id              = "${element(split(",", module.public_subnet.subnet_ids), 0)}"
  ami                    = "${lookup(var.worker_ami, var.region)}"
  count                  = 1
  key_name               = "${var.key_name}"
  vpc_security_group_ids = ["${module.sg.sg_id}"]
  root_block_device = {
    volume_type           = "gp2"
    volume_size           = "${lookup(var.c_drive_size, var.region)}"
    delete_on_termination = true
  }
  ebs_block_device {
    device_name           = "xvdb"
    volume_size           = "${lookup(var.d_drive_size, var.region)}"
    volume_type           = "gp2"
    delete_on_termination = true
  }
  tags = {
    created_by  = "${var.name}-Terraform"
    Name        = "${var.name}-Worker2-EC2"
    Application = "app1"
    Environment = "Production"
  }
}

and yesterday instance was created but today when I run terraform plan I have a problem.
Then problem is that TF shows this:


      ebs_block_device.3133358816.delete_on_termination: "" => "true" (forces new resource)
      ebs_block_device.3133358816.device_name:           "" => "xvdb" (forces new resource)
      ebs_block_device.3133358816.encrypted:             "" => <computed> (forces new resource)
      ebs_block_device.3133358816.snapshot_id:           "" => <computed> (forces new resource)
      ebs_block_device.3133358816.volume_id:             "" => <computed>
      ebs_block_device.3133358816.volume_size:           "" => "100" (forces new resource)
      ebs_block_device.3133358816.volume_type:           "" => "gp2" (forces new resource)
      ebs_block_device.3536824065.delete_on_termination: "true" => "false" (forces new resource)
      ebs_block_device.3536824065.device_name:           "xvdb" => "" (forces new resource)
 
Why it's trying to do that? It also doesn't see values for all ebs options.
TF state has correct information but somehow my local stuff doesn't see it.

I did terraform state pull > state.txt and compared with actual stuff in AWS and all looks good.

Can someone explain to me what is happening here?

Thanks,

Clint Shryock

unread,
May 25, 2018, 6:02:54 PM5/25/18
to terrafo...@googlegroups.com
Hey! It's hard to say with this information, is that all the diff? Can you verify in the console that `delete_on_termination` is not set (as the diff is suggesting)?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/59bfa42b-69e7-4ac1-8606-b16f7fb326b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

egul...@gmail.com

unread,
Jun 27, 2018, 12:41:27 PM6/27/18
to Terraform
The issue was because the AMI I used already had xvdb in it, so in the end I didn't have to specify it.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages