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

resource/aws_autoscaling_group: Fix issue preventing the removal of load_balancers when switching to target_group_arns #9478

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

nywilken
Copy link
Contributor

@nywilken nywilken commented Jul 24, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes: #5197

Release note for CHANGELOG:

* resource/aws_autoscaling_group: Fix issue preventing the removal of `load_balancers` when switching to `target_group_arns`

Upon configuring an ASG with load_balancers, it was found that swapping the load_balancers argument with a list of target_group_arns would result in no diff for the load_balancers despite them being removed.This issue being the computed property on load_balancers, which refreshes the configuration at plan time resulting in load_balancers being added back to the configuration as they are still part of the referenced infrastructure. This change removes the Computed property on both load_balancers and target_group_arns to ensure Terraform always honors the arguments within a provided configuration.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSAutoScalingGroup_WithLoadBalancer'
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer (390.68s)
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer_ToTargetGroup (468.74s)

@nywilken nywilken requested a review from a team July 24, 2019 14:44
@ghost ghost added size/L Managed by automation to categorize the size of a PR. service/autoscaling Issues and PRs that pertain to the autoscaling service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jul 24, 2019
@nywilken nywilken changed the title resource/aws_autoscaling_group: Fix load_balancers to target_group_arns issue resource/aws_autoscaling_group: Fix issue preventing the remove of load_balancers when switching to target_group_arns Jul 24, 2019
@@ -78,6 +78,7 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
"version": {
Type: schema.TypeString,
Optional: true,
Default: "$$Default",
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 this fix should be the in test configuration and not in the resource. 😉 If I recall its a difference in Terraform 0.12's configuration handling regarding $ escaping.

Copy link
Contributor Author

@nywilken nywilken Jul 24, 2019

Choose a reason for hiding this comment

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

I see so within the testing configuration we should not escape $ and instead render the configuration such as Version: "$Latest". Is that correct. I see that the mixed_instance_policy.launch_template.version has an attribute of Default: "$$Deault" should that be removed at some point? Not within this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke this into a separate PR #9488

@nywilken nywilken force-pushed the b-aws_autoscaling_group-lingering-loadbalancers branch 2 times, most recently from f3467cb to 43669b4 Compare July 24, 2019 20:40
@nywilken nywilken changed the title resource/aws_autoscaling_group: Fix issue preventing the remove of load_balancers when switching to target_group_arns resource/aws_autoscaling_group: Fix issue preventing the removal of load_balancers when switching to target_group_arns Jul 25, 2019
@nywilken nywilken added the bug Addresses a defect in current functionality. label Jul 25, 2019
@bflad bflad self-assigned this Jul 25, 2019
…ns issue

Closes: #5197

Upon configuring an ASG with load_balancers, it was found that swapping the load_balancers argument with a list of target_group_arns would result in no diff for the load_balancers despite them being removed.
This issue being the computed property on `load_balancers`, which refreshes the configuration at plan time resulting in `load_balancers` being added back to the configuration as they are still part of the referenced infrastructure.
This change fixes that be removing the `Computed` property on both `load_balancers` and `target_group_arns` to ensure Terraform always honors the arguments within a provided configuration.

```
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer (390.68s)
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer_ToTargetGroup (468.74s)
```
@nywilken nywilken force-pushed the b-aws_autoscaling_group-lingering-loadbalancers branch from 43669b4 to c40d455 Compare July 25, 2019 19:41
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.

LGTM! 🚀

Test failure below unrelated:

--- PASS: TestAccAWSAutoScalingGroup_autoGeneratedName (54.94s)
--- PASS: TestAccAWSAutoScalingGroup_classicVpcZoneIdentifier (71.28s)
--- PASS: TestAccAWSAutoScalingGroup_namePrefix (76.66s)
--- PASS: TestAccAWSAutoScalingGroup_launchTemplate (80.73s)
--- PASS: TestAccAWSAutoScalingGroup_VpcUpdates (84.41s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy (46.57s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDemandAllocationStrategy (43.83s)
--- PASS: TestAccAWSAutoScalingGroup_withMetrics (123.25s)
--- PASS: TestAccAWSAutoScalingGroup_ALB_TargetGroups (128.02s)
--- PASS: TestAccAWSAutoScalingGroup_serviceLinkedRoleARN (133.93s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotAllocationStrategy (51.99s)
--- PASS: TestAccAWSAutoScalingGroup_LaunchTemplate_IAMInstanceProfile (117.82s)
--- PASS: TestAccAWSAutoScalingGroup_launchTemplate_update (175.06s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDemandPercentageAboveBaseCapacity (93.12s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_LaunchTemplateSpecification_Version (44.75s)
--- PASS: TestAccAWSAutoScalingGroup_withPlacementGroup (179.74s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDemandBaseCapacity (106.10s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotInstancePools (75.88s)
--- PASS: TestAccAWSAutoScalingGroup_terminationPolicies (198.96s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_LaunchTemplateSpecification_LaunchTemplateName (72.22s)
--- PASS: TestAccAWSAutoScalingGroup_initialLifecycleHook (201.72s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotMaxPrice (80.84s)
--- FAIL: TestAccAWSAutoScalingGroup_emptyAvailabilityZones (205.95s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_Override_InstanceType (41.77s)
--- PASS: TestAccAWSAutoScalingGroup_suspendingProcesses (262.62s)
--- PASS: TestAccAWSAutoScalingGroup_enablingMetrics (272.32s)
--- PASS: TestAccAWSAutoScalingGroup_basic (277.33s)
--- PASS: TestAccAWSAutoScalingGroup_tags (308.56s)
--- PASS: TestAccAWSAutoScalingGroup_ALB_TargetGroups_ELBCapacity (437.15s)
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer_ToTargetGroup (473.15s)
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer (504.07s)

@nywilken nywilken merged commit 9137af3 into master Jul 25, 2019
@nywilken nywilken deleted the b-aws_autoscaling_group-lingering-loadbalancers branch July 25, 2019 21:41
@nywilken nywilken added this to the v2.21.0 milestone Jul 25, 2019
@bflad
Copy link
Contributor

bflad commented Jul 26, 2019

Please see #9513 for the unexpected behavior change with this pull request. I'm going to lock this pull request only to encourage following the new issue and consolidating any discussions/efforts there.

@hashicorp hashicorp locked and limited conversation to collaborators Jul 26, 2019
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/autoscaling Issues and PRs that pertain to the autoscaling service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After import aws_autoscaling_group terraform plan doesn't show load_balancers diff
2 participants