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

aws_instance diff mismatch when tags drift #1752

Closed
jeevanullas opened this issue Apr 30, 2015 · 7 comments · Fixed by #4749
Closed

aws_instance diff mismatch when tags drift #1752

jeevanullas opened this issue Apr 30, 2015 · 7 comments · Fixed by #4749
Assignees

Comments

@jeevanullas
Copy link

Hi guys,

Great stuff. We got terraform going on Eucalyptus. Tried to change a plan by changing the EMI (AMI) ID and applying it. Found a problem. Logs at

https://gist.github.com/jeevanullas/e15beaa8c4879acc7e6e

If I apply the plan again now, it does create a new instance with the new EMI ID. Thanks for looking at it.

Cheers,
Deependra

@phinze
Copy link
Contributor

phinze commented Apr 30, 2015

Hi there - great to hear that TF is up and running on Eucalyptus!

Here's the relevant bit:

2015/04/30 12:55:17 [ERROR] aws_instance.example: diffs didn't match
2015/04/30 12:55:17 [ERROR] aws_instance.example: reason: attribute mismatch: tags.#
2015/04/30 12:55:17 [ERROR] aws_instance.example: diff one: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"public_dns":*terraform.ResourceAttrDiff{Old:"euca-109-104-120-42.eucalyptus.emea.eucalyptus.com", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "public_ip":*terraform.ResourceAttrDiff{Old:"109.104.120.42", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "private_dns":*terraform.ResourceAttrDiff{Old:"euca-10-30-2-16.eucalyptus.internal", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "placement_group":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "private_ip":*terraform.ResourceAttrDiff{Old:"10.30.2.16", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "root_block_device.#":*terraform.ResourceAttrDiff{Old:"0", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "vpc_security_group_ids.#":*terraform.ResourceAttrDiff{Old:"0", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "availability_zone":*terraform.ResourceAttrDiff{Old:"emea-az-01", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ephemeral_block_device.#":*terraform.ResourceAttrDiff{Old:"0", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "key_name":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "tags.euca:node":*terraform.ResourceAttrDiff{Old:"10.30.0.219", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "ami":*terraform.ResourceAttrDiff{Old:"emi-d1a30feb", New:"emi-a702b3b6", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ebs_block_device.#":*terraform.ResourceAttrDiff{Old:"0", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "tenancy":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "instance_type":*terraform.ResourceAttrDiff{Old:"m1.large", New:"m1.large", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "security_groups.#":*terraform.ResourceAttrDiff{Old:"1", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "tags.#":*terraform.ResourceAttrDiff{Old:"1", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
2015/04/30 12:55:17 [ERROR] aws_instance.example: diff two: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"ami":*terraform.ResourceAttrDiff{Old:"", New:"emi-a702b3b6", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "public_dns":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "private_ip":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "root_block_device.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "availability_zone":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ebs_block_device.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "key_name":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "ephemeral_block_device.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "public_ip":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "private_dns":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "placement_group":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "vpc_security_group_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "security_groups.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "instance_type":*terraform.ResourceAttrDiff{Old:"", New:"m1.large", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "tenancy":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}}, Destroy:false, DestroyTainted:false}

Looks like something to do with tags. Does the config you're using for this instance set any tags? If you change whether it sets tags does that change the problem?

If you can include a config snippet that generates the error that would be helpful.

@jeevanullas
Copy link
Author

Thanks for quick response. The config is below:

provider "aws" {
    access_key = ""
    secret_key = ""
    region = "eucalyptus"
}

resource "aws_instance" "example" {
    ami = "emi-a702b3b6"
    instance_type = "m1.large"
}

@phinze
Copy link
Contributor

phinze commented Apr 30, 2015

@jeevanullas I'm curious - if you add tags to the instance declaration - do you get the same error?

Also, are you using 0.4.2 here? Do you have the ability to try out a build from master? https://github.com/hashicorp/terraform/blob/master/CONTRIBUTING.md#setting-up-go-to-work-on-terraform

@phinze phinze added bug waiting-response An issue/pull request is waiting for a response from the community core labels Apr 30, 2015
@jeevanullas
Copy link
Author

Hi @phinze apologies for the delay. I tried with a custom tag in my declaration and it worked like a charm. This was my config:

provider "aws" {
    access_key = ""
    secret_key = ""
    region = "eucalyptus"
}

resource "aws_instance" "example" {
    ami = "emi-d1a30feb"
    instance_type = "m1.large"
    tags {
        Name = "myinstance"
    }
}
$ terraform version
Terraform v0.5.0-dev (68df1e6e4dc2bafe8e80c134b3c39c8ee7d116a1+CHANGES)

I saw that in the case of failure I had a tag on the instance , this was the output of terraform show after I modified the config:

tags.#:                   "1" => "0"
tags.euca:node:    "10.30.0.219" => ""

I wonder if this creates problem? Note that on Eucalyptus when you launch an instance the system creates a tag and and assign a value to it. The tag 'euca:node' has a value set to the IP address of the machine running the instance.

In case of the successful the plan was

tags.#:                   "2" => "1"
tags.Name:            "myinstance" => "myinstance"
tags.euca:node:     "10.30.0.215" => ""

Looks like we cannot have tags.# = 0? Please let me know if you have any further questions. Thanks again for all your assistance.

Cheers,
Deependra

@phinze phinze removed the waiting-response An issue/pull request is waiting for a response from the community label May 4, 2015
@phinze
Copy link
Contributor

phinze commented May 4, 2015

Yup this was my hunch - it seems like Eucalyptus creates an implicit tag (euca:node) when you create an instance. I believe we should be able to get this sorted out within the AWS instance provider.

@phinze phinze added provider/aws and removed core labels May 4, 2015
@phinze phinze changed the title change in a plan result in failure Using aws_instance with Eucalyptus, implicit tag on create results in diff mismatch May 4, 2015
@catsby
Copy link
Contributor

catsby commented May 4, 2015

I've reproduced this on AWS as well.
Steps:

  1. apply this:
provider "aws" {
  region="us-west-2"
}

resource "aws_instance" "nat" {
  ami = "ami-21f78e11"
  instance_type = "t1.micro"
}
  1. Go to https://console.aws.amazon.com , find the instance, and apply a Tag

  2. Change config to this:

provider "aws" {
  region="us-west-2"
}

resource "aws_instance" "nat" {
  ami = "ami-dfc39aef"
  instance_type = "t2.micro"
}
  1. plan:
$ plan
Refreshing Terraform state prior to plan...

aws_instance.nat: Refreshing state... (ID: i-1dc318ea)

The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Your plan was also saved to the path below. Call the "apply" subcommand
with this plan file and Terraform will exactly execute this execution
plan.

Path: create.tfplan

-/+ aws_instance.nat
    ami:                      "ami-21f78e11" => "ami-dfc39aef" (forces new resource)
    availability_zone:        "us-west-2b" => "<computed>"
    ebs_block_device.#:       "0" => "<computed>"
    ephemeral_block_device.#: "0" => "<computed>"
    instance_type:            "t1.micro" => "t2.micro" (forces new resource)
    key_name:                 "" => "<computed>"
    placement_group:          "" => "<computed>"
    private_dns:              "ip-172-31-30-19.us-west-2.compute.internal" => "<computed>"
    private_ip:               "172.31.30.19" => "<computed>"
    public_dns:               "ec2-52-24-125-143.us-west-2.compute.amazonaws.com" => "<computed>"
    public_ip:                "52.24.125.143" => "<computed>"
    root_block_device.#:      "1" => "<computed>"
    security_groups.#:        "0" => "<computed>"
    subnet_id:                "subnet-b4b122d1" => "<computed>"
    tags.#:                   "1" => "0"
    tags.nerg:                "dorb" => ""
    tenancy:                  "default" => "<computed>"
    vpc_security_group_ids.#: "1" => "<computed>"
  1. `apply:
* 1 error(s) occurred:

* aws_instance.nat: diffs didn't match during apply. This is a bug with Terraform and should be reported.

@catsby catsby added core and removed provider/aws labels May 6, 2015
@phinze phinze changed the title Using aws_instance with Eucalyptus, implicit tag on create results in diff mismatch aws_instance diff mismatch when tags drift May 6, 2015
@phinze phinze self-assigned this May 6, 2015
phinze added a commit that referenced this issue Jan 19, 2016
fixes #1752

Includes AccTest reproducing example from the issue as well as a bunch
of explanatory comments in the tests and impls.
phinze added a commit that referenced this issue Jan 19, 2016
fixes #1752

Includes AccTest reproducing example from the issue as well as a bunch
of explanatory comments in the tests and impls.
bigkraig pushed a commit to bigkraig/terraform that referenced this issue Mar 1, 2016
fixes hashicorp#1752

Includes AccTest reproducing example from the issue as well as a bunch
of explanatory comments in the tests and impls.
@ghost
Copy link

ghost commented Apr 28, 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 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants