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: Batch ELB attachments and detachments by 10 to prevent API and rate limiting errors #10445

Merged

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Oct 10, 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

Reference: #256 (being closed by #10435)
Reference: #10435
Reference: https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_AttachLoadBalancers.html
Reference: https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DetachLoadBalancers.html

Release note for CHANGELOG:

* resource/aws_autoscaling_group: Batch ELB attachments and detachments by 10 to prevent API and rate limiting errors

This change is complementary to the target group batching in #10435. The AutoScaling API for AttachLoadBalancers and DetachLoadBalancers only allow 10 elements at a time. In addition to the batching to split the API requests, we must wait for the batch to fully complete before moving onto the next batch, otherwise the API returns a rate limiting error:

--- FAIL: TestAccAWSAutoScalingGroup_LoadBalancers (360.22s)
    testing.go:569: Step 2 error: errors during apply:

        Error: Error updating Load Balancers for AutoScaling Group (tf-asg-2019101000090127270000000d), error: ValidationError: Trying to update too many Load Balancers/Target Groups at once. The limit is 10

Output from acceptance testing:

--- PASS: TestAccAWSAutoScalingGroup_LoadBalancers (443.84s)

… by 10 to prevent API and rate limiting errors

Reference: #256
Reference: #10435
Reference: https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_AttachLoadBalancers.html
Reference: https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DetachLoadBalancers.html

This change is complementary to the target group batching. The AutoScaling API for `AttachLoadBalancers` and `DetachLoadBalancers` only allow 10 elements at a time. In addition to the batching to split the API requests, we must wait for the batch to fully complete before moving onto the next batch, otherwise the API returns a rate limiting error:

```
--- FAIL: TestAccAWSAutoScalingGroup_LoadBalancers (360.22s)
    testing.go:569: Step 2 error: errors during apply:

        Error: Error updating Load Balancers for AutoScaling Group (tf-asg-2019101000090127270000000d), error: ValidationError: Trying to update too many Load Balancers/Target Groups at once. The limit is 10
```

Output from acceptance testing:

```
--- PASS: TestAccAWSAutoScalingGroup_LoadBalancers (443.84s)
```
@bflad bflad added bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. labels Oct 10, 2019
@bflad bflad requested a review from a team October 10, 2019 01:34
@ghost ghost added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 10, 2019
Copy link
Contributor

@ryndaniels ryndaniels left a comment

Choose a reason for hiding this comment

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

one question but otherwise LGTM 👍

--- PASS: TestAccAWSAutoScalingGroup_LoadBalancers (438.30s)

@@ -1493,3 +1527,75 @@ func flattenAutoScalingMixedInstancesPolicy(mixedInstancesPolicy *autoscaling.Mi

return []interface{}{m}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there ever a case when we'd want to set a timeout on these functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great question and yes, there might be! Quickly scanning the recent issues, I don't see any complaints about the similar change to the target group handling (that also does not have timeouts), but for now this is dependent on the AWS side entering some sort of failure state rather than staying in the adding/deleting state forever in those cases. 🤞

},
{
ResourceName: resourceName,
ImportState: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

🎊

@bflad bflad added this to the v2.35.0 milestone Oct 31, 2019
@bflad bflad merged commit 1274620 into master Oct 31, 2019
@bflad bflad deleted the b-aws_autoscaling_group-load_balancers-update-batching branch October 31, 2019 19:25
bflad added a commit that referenced this pull request Oct 31, 2019
@ghost
Copy link

ghost commented Nov 7, 2019

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@Itiho
Copy link

Itiho commented Dec 14, 2019

The problem still happens here:
Terraform v0.12.18

  • provider.aws v2.42.0
Error: Failure attaching AutoScaling Group lc-autf-4-0-20-27-PGWEB-QA-20191214194536076900000001-asg with ALB Target Group: arn:aws:elasticloadbalancing:us-east-1:106431551699:targetgroup/tf-2019110818465657090000000c/20b68e9c4fa34380: ValidationError: Trying to update too many Load Balancers/Target Groups at once. The limit is 10
	status code: 400, request id: 6c62f77e-1eaa-11ea-96a8-0d0d00d2891c

@ghost
Copy link

ghost commented Dec 15, 2019

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 Dec 15, 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.

3 participants