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

r/aws_eip: Do not disassociate on tags-only update #2975

Merged
merged 2 commits into from
Jan 16, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 12, 2018

Fixes #2968

make testacc TEST=./aws TESTARGS='-run=TestAccAWSEIP'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSEIP -timeout 120m
=== RUN   TestAccAWSEIPAssociation_basic
--- PASS: TestAccAWSEIPAssociation_basic (129.19s)
=== RUN   TestAccAWSEIPAssociation_ec2Classic
--- SKIP: TestAccAWSEIPAssociation_ec2Classic (1.24s)
	provider_test.go:69: This test can only run in EC2 Classic, platforms available in us-east-1: ["VPC"]
=== RUN   TestAccAWSEIPAssociation_disappears
--- PASS: TestAccAWSEIPAssociation_disappears (119.98s)
=== RUN   TestAccAWSEIP_importEc2Classic
--- SKIP: TestAccAWSEIP_importEc2Classic (1.02s)
	provider_test.go:69: This test can only run in EC2 Classic, platforms available in us-east-1: ["VPC"]
=== RUN   TestAccAWSEIP_importVpc
--- PASS: TestAccAWSEIP_importVpc (42.70s)
=== RUN   TestAccAWSEIP_basic
--- PASS: TestAccAWSEIP_basic (11.04s)
=== RUN   TestAccAWSEIP_instance
--- PASS: TestAccAWSEIP_instance (283.45s)
=== RUN   TestAccAWSEIP_network_interface
--- PASS: TestAccAWSEIP_network_interface (43.12s)
=== RUN   TestAccAWSEIP_twoEIPsOneNetworkInterface
--- PASS: TestAccAWSEIP_twoEIPsOneNetworkInterface (44.22s)
=== RUN   TestAccAWSEIP_associated_user_private_ip
--- PASS: TestAccAWSEIP_associated_user_private_ip (148.83s)
=== RUN   TestAccAWSEIP_classic_disassociate
--- SKIP: TestAccAWSEIP_classic_disassociate (1.35s)
	provider_test.go:69: This test can only run in EC2 Classic, platforms available in us-west-2: ["VPC"]
=== RUN   TestAccAWSEIP_disappears
--- PASS: TestAccAWSEIP_disappears (8.40s)
=== RUN   TestAccAWSEIPAssociate_not_associated
--- PASS: TestAccAWSEIPAssociate_not_associated (144.82s)
=== RUN   TestAccAWSEIP_tags
--- PASS: TestAccAWSEIP_tags (19.69s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	999.115s

@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. service/ec2-classic labels Jan 12, 2018
@bflad bflad added this to the v1.7.1 milestone Jan 12, 2018
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nitpicks left about readability of the code, otherwise LGTM.

if (d.Get("instance").(string) != "" || d.Get("association_id").(string) != "") && !d.IsNewResource() {
disassociate := false
if !d.IsNewResource() {
if (d.Get("instance").(string) != "") && d.HasChange("instance") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks: The brackets here are unnecessary + I think it would make a bit more sense (when trying to read the code) if it was reversed, i.e.

if d.HasChange("instance") && d.Get("instance").(string) != "" {

if !d.IsNewResource() {
if (d.Get("instance").(string) != "") && d.HasChange("instance") {
disassociate = true
} else if (d.Get("association_id").(string) != "") && (d.HasChange("network_interface") || d.HasChange("associate_with_private_ip")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks: As above - I'd omit the brackets and reverse ordering of HasChange and Get.

associate := false
if ok_instance && d.HasChange("instance") {
associate = true
} else if ok_interface && (d.HasChange("network_interface") || d.HasChange("associate_with_private_ip")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks: In addition to what I already mentioned above would you mind moving the two variable definitions closer to where they're being actually used (meaning ok_instance & ok_interface in this context).

* Adjust ordering of disassociate/associate boolean logic for readability
* Remove extraneous boolean parenthesis
@bflad bflad merged commit fef70ca into master Jan 16, 2018
@bflad bflad deleted the b-aws_eip-no-tags-disassociation branch January 16, 2018 12:16
bflad added a commit that referenced this pull request Jan 16, 2018
@bflad
Copy link
Contributor Author

bflad commented Jan 22, 2018

This has been released in terraform-provider-aws version 1.7.1. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

drewsonne pushed a commit to drewsonne/terraform-provider-aws that referenced this pull request Mar 3, 2018
* Adjust ordering of disassociate/associate boolean logic for readability
* Remove extraneous boolean parenthesis
drewsonne pushed a commit to drewsonne/terraform-provider-aws that referenced this pull request Mar 3, 2018
@ghost
Copy link

ghost commented Apr 8, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disassociating EIP when adding tags
2 participants