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/launch_template: exclude associate_public_ip_address when not set #5314

Merged
merged 2 commits into from
Jul 26, 2018

Conversation

kl4w
Copy link
Contributor

@kl4w kl4w commented Jul 24, 2018

Fixes #5293

Changes proposed in this pull request:

  • exclude associate_public_ip_address when not set

Output from acceptance testing:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSLaunchTemplate_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSLaunchTemplate_ -timeout 120m
=== RUN   TestAccAWSLaunchTemplate_importBasic
--- PASS: TestAccAWSLaunchTemplate_importBasic (14.91s)
=== RUN   TestAccAWSLaunchTemplate_importData
--- PASS: TestAccAWSLaunchTemplate_importData (13.61s)
=== RUN   TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (11.87s)
=== RUN   TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (15.51s)
=== RUN   TestAccAWSLaunchTemplate_data
--- PASS: TestAccAWSLaunchTemplate_data (10.97s)
=== RUN   TestAccAWSLaunchTemplate_update
--- PASS: TestAccAWSLaunchTemplate_update (22.20s)
=== RUN   TestAccAWSLaunchTemplate_tags
--- PASS: TestAccAWSLaunchTemplate_tags (22.98s)
=== RUN   TestAccAWSLaunchTemplate_nonBurstable
--- PASS: TestAccAWSLaunchTemplate_nonBurstable (11.16s)
=== RUN   TestAccAWSLaunchTemplate_networkInterface
--- PASS: TestAccAWSLaunchTemplate_networkInterface (29.52s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	152.755s

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jul 24, 2018
@kl4w
Copy link
Contributor Author

kl4w commented Jul 24, 2018

during some manual testing, found that associate_public_ip_address conflicts with network_interface_id. Is there any to put a ConflictsWith here given that you can have multiple network interfaces? Is that worth it?

@kl4w kl4w changed the title exclude associate_public_ip_address when not set r/launch_template: exclude associate_public_ip_address when not set Jul 24, 2018
@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jul 25, 2018
@bflad
Copy link
Contributor

bflad commented Jul 25, 2018

Is there any to put a ConflictsWith here given that you can have multiple network interfaces?

The current implementation of Schema.ConflictsWith is limited to static attribute keys from the root of the resource, which would not help in this case or be very readable. 🙁

// ConflictsWith is a set of schema keys that conflict with this schema.
// This will only check that they're set in the config. This will not
// raise an error for a malfunctioning resource that sets a conflicting
// key.
ConflictsWith []string

In the upcoming Terraform 0.12 release, we will however support null arguments.

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this @kl4w! 👍 As noted below, I think this restricting functionality we should support. We can use conditional logic to nil out erroneous API parameters if necessary.

DeleteOnTermination: aws.Bool(ni["delete_on_termination"].(bool)),
networkInterface := &ec2.LaunchTemplateInstanceNetworkInterfaceSpecificationRequest{}

if v, ok := ni["associate_public_ip_address"]; ok && v.(bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe setting false should be a valid value (at least it is in the EC2 console from the options of don't set / disable / enable) -- I think we need to cover both cases of ignoring this attribute when network_interface_id is set, as well as allowing false.

networkInterface.AssociatePublicIpAddress = aws.Bool(v.(bool))
}

if v, ok := ni["delete_on_termination"]; ok && v.(bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here -- I believe setting false should be a valid value (at least it is in the EC2 console from the options of don't set / off / on).

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jul 25, 2018
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jul 26, 2018
@kl4w
Copy link
Contributor Author

kl4w commented Jul 26, 2018

@bflad made changes as requested, output of tests:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSLaunchTemplate_'
gofmt -w $(find . -name '*.go' |grep -v vendor)
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSLaunchTemplate_ -timeout 120m
=== RUN   TestAccAWSLaunchTemplate_importBasic
--- PASS: TestAccAWSLaunchTemplate_importBasic (14.69s)
=== RUN   TestAccAWSLaunchTemplate_importData
--- PASS: TestAccAWSLaunchTemplate_importData (13.00s)
=== RUN   TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (12.40s)
=== RUN   TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (15.28s)
=== RUN   TestAccAWSLaunchTemplate_data
--- PASS: TestAccAWSLaunchTemplate_data (11.15s)
=== RUN   TestAccAWSLaunchTemplate_update
--- PASS: TestAccAWSLaunchTemplate_update (21.79s)
=== RUN   TestAccAWSLaunchTemplate_tags
--- PASS: TestAccAWSLaunchTemplate_tags (23.41s)
=== RUN   TestAccAWSLaunchTemplate_nonBurstable
--- PASS: TestAccAWSLaunchTemplate_nonBurstable (11.11s)
=== RUN   TestAccAWSLaunchTemplate_networkInterface
--- PASS: TestAccAWSLaunchTemplate_networkInterface (36.63s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	159.516s

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 26, 2018
@bflad bflad added this to the v1.30.0 milestone Jul 26, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @kl4w! 🚀

9 tests passed (all tests)
=== RUN   TestAccAWSLaunchTemplate_data
--- PASS: TestAccAWSLaunchTemplate_data (7.01s)
=== RUN   TestAccAWSLaunchTemplate_nonBurstable
--- PASS: TestAccAWSLaunchTemplate_nonBurstable (7.19s)
=== RUN   TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (7.85s)
=== RUN   TestAccAWSLaunchTemplate_importData
--- PASS: TestAccAWSLaunchTemplate_importData (8.19s)
=== RUN   TestAccAWSLaunchTemplate_importBasic
--- PASS: TestAccAWSLaunchTemplate_importBasic (8.51s)
=== RUN   TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (9.07s)
=== RUN   TestAccAWSLaunchTemplate_networkInterface
--- PASS: TestAccAWSLaunchTemplate_networkInterface (10.13s)
=== RUN   TestAccAWSLaunchTemplate_update
--- PASS: TestAccAWSLaunchTemplate_update (12.31s)
=== RUN   TestAccAWSLaunchTemplate_tags
--- PASS: TestAccAWSLaunchTemplate_tags (13.15s)

@bflad bflad merged commit 00145b2 into hashicorp:master Jul 26, 2018
bflad added a commit that referenced this pull request Jul 26, 2018
@kl4w kl4w deleted the lt-network-interface-public-ip branch July 26, 2018 20:59
@bflad
Copy link
Contributor

bflad commented Aug 2, 2018

This has been released in version 1.30.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 4, 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 4, 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. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No ability to exclude associate_public_ip_address from launch_template
2 participants