From a2792f46c2afea1f2745c1b271ab913764789de7 Mon Sep 17 00:00:00 2001 From: Jake Champlin Date: Fri, 10 Feb 2017 12:46:35 -0500 Subject: [PATCH] provider/aws: Fix SecurityGroupRule regression 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 ``` --- builtin/providers/aws/resource_aws_security_group_rule.go | 5 +++-- .../providers/aws/resource_aws_security_group_rule_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_security_group_rule.go b/builtin/providers/aws/resource_aws_security_group_rule.go index e1de498030c2..f110f98ea879 100644 --- a/builtin/providers/aws/resource_aws_security_group_rule.go +++ b/builtin/providers/aws/resource_aws_security_group_rule.go @@ -608,9 +608,10 @@ func validateAwsSecurityGroupRule(d *schema.ResourceData) error { _, blocksOk := d.GetOk("cidr_blocks") _, sourceOk := d.GetOk("source_security_group_id") _, selfOk := d.GetOk("self") - if !blocksOk && !sourceOk && !selfOk { + _, prefixOk := d.GetOk("prefix_list_ids") + if !blocksOk && !sourceOk && !selfOk && !prefixOk { return fmt.Errorf( - "One of ['cidr_blocks', 'self', 'source_security_group_id'] must be set to create an AWS Security Group Rule") + "One of ['cidr_blocks', 'self', 'source_security_group_id', 'prefix_list_ids'] must be set to create an AWS Security Group Rule") } return nil } diff --git a/builtin/providers/aws/resource_aws_security_group_rule_test.go b/builtin/providers/aws/resource_aws_security_group_rule_test.go index 93d39d3574e0..f9b0004ffeb9 100644 --- a/builtin/providers/aws/resource_aws_security_group_rule_test.go +++ b/builtin/providers/aws/resource_aws_security_group_rule_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "log" + "regexp" "testing" "github.com/aws/aws-sdk-go/aws" @@ -12,7 +13,6 @@ import ( "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "regexp" ) func TestIpPermissionIDHash(t *testing.T) {