-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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: Fix AWS Security Group Rule Timeout #11809
Conversation
An AWS Security Group Rule requires at least one of `cidr_blocks`, `self`, or `source_security_group_id` in order to be successfully created. If the `aws_security_group_rule` doesn't contain one of these attributes, the AWS API will still return a `200` response, and not report any error in the response. Example response from the API on a malformed submission: ``` 2017/02/08 16:04:33 [DEBUG] plugin: terraform: ----------------------------------------------------- 2017/02/08 16:04:33 [DEBUG] plugin: terraform: aws-provider (internal) 2017/02/08 16:04:33 [DEBUG] [aws-sdk-go] DEBUG: Response ec2/AuthorizeSecurityGroupIngress Details: 2017/02/08 16:04:33 [DEBUG] plugin: terraform: ---[ RESPONSE ]-------------------------------------- 2017/02/08 16:04:33 [DEBUG] plugin: terraform: HTTP/1.1 200 OK 2017/02/08 16:04:33 [DEBUG] plugin: terraform: Connection: close 2017/02/08 16:04:33 [DEBUG] plugin: terraform: Transfer-Encoding: chunked 2017/02/08 16:04:33 [DEBUG] plugin: terraform: Content-Type: text/xml;charset=UTF-8 2017/02/08 16:04:33 [DEBUG] plugin: terraform: Date: Wed, 08 Feb 2017 21:04:33 GMT 2017/02/08 16:04:33 [DEBUG] plugin: terraform: Server: AmazonEC2 2017/02/08 16:04:33 [DEBUG] plugin: terraform: Vary: Accept-Encoding 2017/02/08 16:04:33 [DEBUG] plugin: terraform: 2017/02/08 16:04:33 [DEBUG] plugin: terraform: 102 2017/02/08 16:04:33 [DEBUG] plugin: terraform: <?xml version="1.0" encoding="UTF-8"?> 2017/02/08 16:04:33 [DEBUG] plugin: terraform: <AuthorizeSecurityGroupIngressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> 2017/02/08 16:04:33 [DEBUG] plugin: terraform: <requestId>ac08c33f-8043-46d4-b637-4c4b2fc7a094</requestId> 2017/02/08 16:04:33 [DEBUG] plugin: terraform: <return>true</return> 2017/02/08 16:04:33 [DEBUG] plugin: terraform: </AuthorizeSecurityGroupIngressResponse> 2017/02/08 16:04:33 [DEBUG] plugin: terraform: 0 2017/02/08 16:04:33 [DEBUG] plugin: terraform: 2017/02/08 16:04:33 [DEBUG] plugin: terraform: 2017/02/08 16:04:33 [DEBUG] plugin: terraform: ----------------------------------------------------- ``` This previously caused Terraform to wait until the security_group_rule propagated, which never happened due to the silent failure. The changeset ensures that one of the required attributes are set prior to creating the aws_security_group_rule. Also catches the error returned from the retry function. Previously the error was ignored, and only logged at the `DEBUG` level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noticed regression
_, selfOk := d.GetOk("self") | ||
if !blocksOk && !sourceOk && !selfOk { | ||
return fmt.Errorf( | ||
"One of ['cidr_blocks', 'self', 'source_security_group_id'] must be set to create an AWS Security Group Rule") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think prefix_list_ids
need to be added to this special club, see TestAccAWSSecurityGroupRule_PrefixListEgress
A security_group_rule can also be created from a `prefix_list_id`. Introduced in #11809 ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSecurityGroupRule_PrefixListEgress' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/10 12:41:40 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSecurityGroupRule_PrefixListEgress -timeout 120m === RUN TestAccAWSSecurityGroupRule_PrefixListEgress --- PASS: TestAccAWSSecurityGroupRule_PrefixListEgress (33.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 33.970s ```
A security_group_rule can also be created from a `prefix_list_id`. Introduced in #11809 ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSecurityGroupRule_PrefixListEgress' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/10 12:41:40 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSecurityGroupRule_PrefixListEgress -timeout 120m === RUN TestAccAWSSecurityGroupRule_PrefixListEgress --- PASS: TestAccAWSSecurityGroupRule_PrefixListEgress (33.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 33.970s ```
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. |
An AWS Security Group Rule requires at least one of
cidr_blocks
,self
, orsource_security_group_id
in order to be successfully created.If the
aws_security_group_rule
doesn't contain one of these attributes, the AWS API will still return a200
response, and not report any error in the response.Example response from the API on a malformed submission:
This previously caused Terraform to wait until the security_group_rule propagated, which never happened due to the silent failure.
The changeset ensures that one of the required attributes are set prior to creating the aws_security_group_rule.
Also catches the error returned from the retry function. Previously the error was ignored, and only logged at the
DEBUG
level.Fixes: #10377, #10064, #6938, and #3587