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

provider/aws: Stop aws_instance source_dest_check triggering an API call on each terraform run #8450

Merged
merged 1 commit into from
Aug 25, 2016

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Aug 24, 2016

Fixes #3550

The simple fix here was to check if the Resource was new (to set the
value the first time) then check it has changed each time

I was able to see from the TF log the following:

Config

resource "aws_vpc" "foo" {
    cidr_block = "10.10.0.0/16"
}

resource "aws_subnet" "foo" {
    cidr_block = "10.10.1.0/24"
    vpc_id = "${aws_vpc.foo.id}"
}

resource "aws_instance" "foo" {
    ami = "ami-4fccb37f"
    instance_type = "m1.small"
    subnet_id = "${aws_subnet.foo.id}"
    source_dest_check = false
        disable_api_termination = true
}

No longer caused any Modifying source_dest_check entries in the LOG

I'd like to leave this out of 0.7.2 so that we get a couple of acceptance test runs on this change!

…PI call on each

terraform run

Fixes #3550

The simple fix here was to check if the Resource was new (to set the
value the first time) then check it has changed each time

I was able to see from the TF log the following:

```
Config

resource "aws_vpc" "foo" {
	cidr_block = "10.10.0.0/16"
}

resource "aws_subnet" "foo" {
	cidr_block = "10.10.1.0/24"
	vpc_id = "${aws_vpc.foo.id}"
}

resource "aws_instance" "foo" {
	ami = "ami-4fccb37f"
	instance_type = "m1.small"
	subnet_id = "${aws_subnet.foo.id}"
	source_dest_check = false
        disable_api_termination = true
}
```

No longer caused any Modifying source_dest_check entries in the LOG
@stack72
Copy link
Contributor Author

stack72 commented Aug 24, 2016

Initial config gave this:

[stacko@Pauls-MacBook-Pro:~/Code/terraform-recreations/3550]
% TF_LOG=1 terraform apply 2>~/tf.log
aws_vpc.foo: Creating...
  cidr_block:                "" => "10.10.0.0/16"
  default_network_acl_id:    "" => "<computed>"
  default_security_group_id: "" => "<computed>"
  dhcp_options_id:           "" => "<computed>"
  enable_classiclink:        "" => "<computed>"
  enable_dns_hostnames:      "" => "<computed>"
  enable_dns_support:        "" => "<computed>"
  instance_tenancy:          "" => "<computed>"
  main_route_table_id:       "" => "<computed>"
aws_vpc.foo: Still creating... (10s elapsed)
aws_vpc.foo: Creation complete
aws_subnet.foo: Creating...
  availability_zone:       "" => "<computed>"
  cidr_block:              "" => "10.10.1.0/24"
  map_public_ip_on_launch: "" => "false"
  vpc_id:                  "" => "vpc-ccfacea8"
aws_subnet.foo: Creation complete
aws_instance.foo: Creating...
  ami:                      "" => "ami-4fccb37f"
  availability_zone:        "" => "<computed>"
  ebs_block_device.#:       "" => "<computed>"
  ephemeral_block_device.#: "" => "<computed>"
  instance_state:           "" => "<computed>"
  instance_type:            "" => "m1.small"
  key_name:                 "" => "<computed>"
  network_interface_id:     "" => "<computed>"
  placement_group:          "" => "<computed>"
  private_dns:              "" => "<computed>"
  private_ip:               "" => "<computed>"
  public_dns:               "" => "<computed>"
  public_ip:                "" => "<computed>"
  root_block_device.#:      "" => "<computed>"
  security_groups.#:        "" => "<computed>"
  source_dest_check:        "" => "false"
  subnet_id:                "" => "subnet-cade6c92"
  tenancy:                  "" => "<computed>"
  vpc_security_group_ids.#: "" => "<computed>"
aws_instance.foo: Still creating... (10s elapsed)
aws_instance.foo: Still creating... (20s elapsed)
aws_instance.foo: Still creating... (30s elapsed)
aws_instance.foo: Still creating... (40s elapsed)
aws_instance.foo: Creation complete

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Adding disable_api_termination = true would trigger an update and the old code would show that source_dest_check would be modified:

[stacko@Pauls-MacBook-Pro:~/Code/terraform-recreations/3550]
% TF_LOG=1 terraform apply 2>~/tf.log                                                                                                                                                                   
aws_vpc.foo: Refreshing state... (ID: vpc-ccfacea8)
aws_subnet.foo: Refreshing state... (ID: subnet-cade6c92)
aws_instance.foo: Refreshing state... (ID: i-b8e3bb65)
aws_instance.foo: Modifying...
  disable_api_termination: "false" => "true"
aws_instance.foo: Modifications complete

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

@mitchellh
Copy link
Contributor

Oh well done. LGTM.

@stack72 stack72 merged commit 338aab9 into master Aug 25, 2016
@stack72 stack72 deleted the aws-instance-modifying-call branch August 25, 2016 21:11
richardbowden pushed a commit to richardbowden/terraform that referenced this pull request Aug 27, 2016
…PI call on each (hashicorp#8450)

terraform run

Fixes hashicorp#3550

The simple fix here was to check if the Resource was new (to set the
value the first time) then check it has changed each time

I was able to see from the TF log the following:

```
Config

resource "aws_vpc" "foo" {
	cidr_block = "10.10.0.0/16"
}

resource "aws_subnet" "foo" {
	cidr_block = "10.10.1.0/24"
	vpc_id = "${aws_vpc.foo.id}"
}

resource "aws_instance" "foo" {
	ami = "ami-4fccb37f"
	instance_type = "m1.small"
	subnet_id = "${aws_subnet.foo.id}"
	source_dest_check = false
        disable_api_termination = true
}
```

No longer caused any Modifying source_dest_check entries in the LOG
@ghost
Copy link

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

Successfully merging this pull request may close these issues.

provider/aws: source_dest_check is causes ModifyInstanceAttribute every run
2 participants