Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diffs didn't match during apply with aws_iam_instance_profile and aws_security_group #5200

Closed
brikis98 opened this issue Feb 18, 2016 · 14 comments

Comments

@brikis98
Copy link
Contributor

When I run terraform apply, I get the following two errors:

* aws_iam_instance_profile.instance_profile: diffs didn't match during apply. This is a bug with Terraform and should be reported.
* aws_security_group.asg_security_group_stg: diffs didn't match during apply. This is a bug with Terraform and should be reported.

If I re-run terraform apply, everything works fine. It looks a bit like #529, but I don't have any self = true entries in my security group, plus I have the extra error about the instance_profile, so just in case, I filed a separate bug.

My templates are fairly large, so I'm trying to extract just the relevant pieces:

resource "aws_iam_instance_profile" "instance_profile" {
  name = "lc-instance-profile-${var.app_name}-${var.vpc_name}"
  roles = ["${aws_iam_role.instance_role.name}"]

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_iam_role" "instance_role" {
  name = "lc-instance-role-${var.app_name}-${var.vpc_name}"
  assume_role_policy = <<EOF
{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
EOF

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_launch_configuration" "launch_configuration" {
  name_prefix = "lc-${var.app_name}-${var.vpc_name}-"
  image_id = "${var.ami}"
  instance_type = "${var.instance_type}"
  key_name = "${var.key_pair_name}"
  iam_instance_profile = "${aws_iam_instance_profile.instance_profile.name}"
  security_groups = ["${aws_security_group.asg_security_group_stg.id}"]
  user_data = "${var.user_data}"

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_autoscaling_group" "autoscaling_group" {
  name = "asg-${aws_launch_configuration.launch_configuration.name}"
  launch_configuration = "${aws_launch_configuration.launch_configuration.name}"

  min_size = "${var.min_size}"
  max_size = "${var.max_size}"
  desired_capacity = "${var.desired_capacity}"
  wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"
  min_elb_capacity = "${var.min_elb_capacity}"

  vpc_zone_identifier = ["${split(",", var.vpc_subnet_ids)}"]
  load_balancers = ["${aws_security_group.elb_security_group_stg.id}"]
  health_check_type = "ELB"
  health_check_grace_period = "${var.health_check_grace_period}"

  tag {
    key = "Name"
    value = "asg-${var.app_name}-${var.vpc_name}"
    propagate_at_launch = true
  }

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_security_group" "asg_security_group_stg" {
  name = "sg_asg_${var.app_name}_${var.vpc_name}"
  vpc_id = "${var.vpc_id}"

  egress {
    from_port = 0
    to_port = 0
    protocol = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }

  ingress {
    from_port = 8080
    to_port = 8080
    protocol = "tcp"
    security_groups = ["${aws_security_group.elb_security_group_stg.id}"]
  }

  ingress {
    from_port = 22
    to_port = 22
    protocol = "tcp"
    cidr_blocks = ["${var.mgmt_cidr_block}"]
  }

  ingress {
    from_port = -1
    to_port = -1
    protocol = "icmp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  lifecycle {
    create_before_destroy = true
  }
}

The reason for all the create_before_destroy = true entries is to get rolling deployment as described here.

@brikis98
Copy link
Contributor Author

BTW, occasionally when I run terraform apply, instead of getting both errors, I only get the one about the aws_iam_instance_profile. Seems like some sort of timing issue.

@plombardi89
Copy link

+1 running into this issue right now too. In a crunch but i'll try and get my templates posted tonight.

@phinze phinze added the bug label Feb 19, 2016
@phinze
Copy link
Contributor

phinze commented Feb 19, 2016

Hey folks, sorry for the trouble here - when you hit these there's some valuable information that's dropped into the debug log. If you set TF_LOG=trace and TF_LOG_PATH=tfdebug.log, trigger the error, and search through the log for "diffs didn't match" there's a set of lines that output:

reason: ...
diff one: ...
diff two: ...

These will point us to exactly what's happening.

@brikis98
Copy link
Contributor Author

@phinze OK, here's the (hopefully) relevant TF_LOG=trace output:

2016/02/19 14:37:21 [ERROR] aws_iam_instance_profile.instance_profile: diffs didn't match
2016/02/19 14:37:21 [ERROR] aws_iam_instance_profile.instance_profile: reason: attribute mismatch: roles.2877750799
2016/02/19 14:37:21 [ERROR] aws_iam_instance_profile.instance_profile: diff one: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"name":*terraform.ResourceAttrDiff{Old:"", New:"lc-instance-profile-${var.app_name}-${var.vpc_name}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "path":*terraform.ResourceAttrDiff{Old:"", New:"/", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "roles.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "roles.2877750799":*terraform.ResourceAttrDiff{Old:"", New:"lc-instance-role-${var.app_name}-${var.vpc_name}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "arn":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "create_date":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "unique_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
2016/02/19 14:37:21 [ERROR] aws_iam_instance_profile.instance_profile: diff two: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"arn":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "create_date":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "unique_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"lc-instance-profile-asg-example-app-stg", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "path":*terraform.ResourceAttrDiff{Old:"", New:"/", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "roles.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "roles.4293975883":*terraform.ResourceAttrDiff{Old:"", New:"lc-instance-role-asg-example-app-stg", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
2016/02/19 14:37:21 [ERROR] root.asg_stg: eval: *terraform.EvalCompareDiff, err: aws_iam_instance_profile.instance_profile: diffs didn't match during apply. This is a bug with Terraform and should be reported.
2016/02/19 14:37:21 [ERROR] root.asg_stg: eval: *terraform.EvalSequence, err: aws_iam_instance_profile.instance_profile: diffs didn't match during apply. This is a bug with Terraform and should be reported.
2016/02/19 14:37:21 [ERROR] root.asg_stg: eval: *terraform.EvalOpFilter, err: aws_iam_instance_profile.instance_profile: diffs didn't match during apply. This is a bug with Terraform and should be reported.
2016/02/19 14:37:21 [ERROR] root.asg_stg: eval: *terraform.EvalSequence, err: aws_iam_instance_profile.instance_profile: diffs didn't match during apply. This is a bug with Terraform and should be reported.

Note that I only got the aws_iam_instance_profile version of the error this time. If I get the aws_security_group version in the future, I'll post that too.

@brikis98
Copy link
Contributor Author

And here's the TF_LOG output when I get the aws_security_group error as well:

2016/02/19 15:49:26 [ERROR] aws_security_group.asg_security_group_stg: diff one: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"ingress.1799340084.to_port":*terraform.ResourceAttrDiff{Old:"", New:"-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "vpc_id":*terraform.ResourceAttrDiff{Old:"", New:"${terraform_remote_state.vpc.output.stg_vpc_id}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ingress.~3457728489.to_port":*terraform.ResourceAttrDiff{Old:"", New:"22", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.cidr_blocks.0":*terraform.ResourceAttrDiff{Old:"", New:"0.0.0.0/0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "description":*terraform.ResourceAttrDiff{Old:"", New:"Security group for the ${var.app_name} ASG in VPC ${terraform_remote_state.vpc.output.stg_vpc_name}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ingress.~720993836.from_port":*terraform.ResourceAttrDiff{Old:"", New:"8080", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.from_port":*terraform.ResourceAttrDiff{Old:"", New:"-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.cidr_blocks.0":*terraform.ResourceAttrDiff{Old:"", New:"0.0.0.0/0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~720993836.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~720993836.protocol":*terraform.ResourceAttrDiff{Old:"", New:"tcp", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.protocol":*terraform.ResourceAttrDiff{Old:"", New:"-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~3457728489.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.from_port":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"sg_asg_${var.app_name}_${terraform_remote_state.vpc.output.stg_vpc_name}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ingress.1799340084.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~720993836.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.#":*terraform.ResourceAttrDiff{Old:"", New:"3", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.protocol":*terraform.ResourceAttrDiff{Old:"", New:"icmp", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~720993836.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~720993836.to_port":*terraform.ResourceAttrDiff{Old:"", New:"8080", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~3457728489.protocol":*terraform.ResourceAttrDiff{Old:"", New:"tcp", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.to_port":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "owner_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~3457728489.from_port":*terraform.ResourceAttrDiff{Old:"", New:"22", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~3457728489.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.~3457728489.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
2016/02/19 15:49:26 [ERROR] aws_security_group.asg_security_group_stg: diff two: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"ingress.3476451213.security_groups.3044394841":*terraform.ResourceAttrDiff{Old:"", New:"sg-8c824bf4", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "description":*terraform.ResourceAttrDiff{Old:"", New:"Security group for the asg-example-app ASG in VPC stg", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ingress.2821672638.cidr_blocks.0":*terraform.ResourceAttrDiff{Old:"", New:"10.200.0.0/18", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.3476451213.protocol":*terraform.ResourceAttrDiff{Old:"", New:"tcp", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.from_port":*terraform.ResourceAttrDiff{Old:"", New:"-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.protocol":*terraform.ResourceAttrDiff{Old:"", New:"-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.3476451213.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.2821672638.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.3476451213.from_port":*terraform.ResourceAttrDiff{Old:"", New:"8080", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.2821672638.protocol":*terraform.ResourceAttrDiff{Old:"", New:"tcp", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "vpc_id":*terraform.ResourceAttrDiff{Old:"", New:"vpc-b5cf91d1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "owner_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.to_port":*terraform.ResourceAttrDiff{Old:"", New:"-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.to_port":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"sg_asg_asg-example-app_stg", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "egress.482069346.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.cidr_blocks.0":*terraform.ResourceAttrDiff{Old:"", New:"0.0.0.0/0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.2821672638.self":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.3476451213.to_port":*terraform.ResourceAttrDiff{Old:"", New:"8080", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.3476451213.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.#":*terraform.ResourceAttrDiff{Old:"", New:"3", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.cidr_blocks.0":*terraform.ResourceAttrDiff{Old:"", New:"0.0.0.0/0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.2821672638.from_port":*terraform.ResourceAttrDiff{Old:"", New:"22", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.2821672638.to_port":*terraform.ResourceAttrDiff{Old:"", New:"22", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.3476451213.security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.2821672638.cidr_blocks.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ingress.1799340084.protocol":*terraform.ResourceAttrDiff{Old:"", New:"icmp", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.482069346.from_port":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "egress.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}

@brikis98
Copy link
Contributor Author

Any updates on this? I love Terraform, but it's frustrating always seeing diffs didn't match errors and having to re-run apply.

@brikis98
Copy link
Contributor Author

brikis98 commented Mar 5, 2016

An update: it seems like this issue might be tied to the ASG setting create_before_destroy to true. As per this comment, I recently refactored my code so the ASG was created using CloudFormation, while leaving everything else the same. In the last few runs, I have not seen the diffs didn't match error.

@zapman449
Copy link

I just stumbled across this issue. In my case, it's related to attempting to use template strings as names (I believe). I did the debug logging, and found this discrepancy in the diffs:

diff one (leaving out most of the detail):

  "roles.1763060403":*terraform.ResourceAttrDiff{
    Old:"",
    New:"${template_file.data_access_policy.rendered}",
    NewComputed:false,
    NewRemoved:false,
    NewExtra:interface {}(nil),
    RequiresNew:false,
    Type:0x0
  }

diff 2:

  "roles.2680970327":*terraform.ResourceAttrDiff{
    Old:"",
    New:"tf_prod_US_data_access_policy",
    NewComputed:false,
    NewRemoved:false,
    NewExtra:interface {}(nil),
    RequiresNew:false,
    Type:0x0
  },

@zapman449
Copy link

Note the 'roles.######' is different as well, but I hope that's not the problem...

@catsby catsby added core and removed provider/aws labels Mar 15, 2016
@brikis98
Copy link
Contributor Author

I'm not sure what changed, but I'm getting this error again now. I tried updating to 0.6.14, but that hasn't helped.

@brikis98
Copy link
Contributor Author

@zapman449, I think you might be on to something. I'm not using template strings as names, but I am using variables, and that pops up as the only difference between "Diff One" and "Diff Two" in the error message:

Diff 1: ... New:"${var.name}" ...
Diff 2: ... New:"ExampleApp" ...

@brikis98
Copy link
Contributor Author

Oh, and for completeness, this is what the aws_instance_profile looks like now:

resource "aws_iam_instance_profile" "instance_profile" {
  name = "${var.name}"
  roles = ["${aws_iam_role.instance_role.name}"]

  lifecycle {
    create_before_destroy = true
  }
}

@mitchellh
Copy link
Contributor

We fixed a lot of these issues a number of months back, but since this issue was buried in others we didn't see this. Given the lack of responses I'm going to close this but if it still happens please open an issue again. Very sorry!

tomzo pushed a commit to kudulab/docker-terraform-dojo that referenced this issue Apr 21, 2019
Terraform 0.7.13; inputrc file

* Terraform 0.7.13, because maybe it fixes hashicorp/terraform#5200
* add inputrc file so that shortcuts like ctrl+left work

See merge request !2
@ghost
Copy link

ghost commented Apr 21, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants