Skip to content

Commit

Permalink
Merge pull request #4816 from saravanan30erd/wafregional_ipset
Browse files Browse the repository at this point in the history
add arn to aws_wafregional_ipset
  • Loading branch information
bflad authored Jun 12, 2018
2 parents c8af574 + de9f282 commit 14df762
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aws/resource_aws_wafregional_ipset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/waf"
"github.com/aws/aws-sdk-go/service/wafregional"
Expand All @@ -24,6 +25,10 @@ func resourceAwsWafRegionalIPSet() *schema.Resource {
Required: true,
ForceNew: true,
},
"arn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"ip_set_descriptor": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -85,6 +90,15 @@ func resourceAwsWafRegionalIPSetRead(d *schema.ResourceData, meta interface{}) e
d.Set("ip_set_descriptor", flattenWafIpSetDescriptorWR(resp.IPSet.IPSetDescriptors))
d.Set("name", resp.IPSet.Name)

arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "waf-regional",
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
Resource: fmt.Sprintf("ipset/%s", d.Id()),
}
d.Set("arn", arn.String())

return nil
}

Expand Down
3 changes: 3 additions & 0 deletions aws/resource_aws_wafregional_ipset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"reflect"
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
Expand Down Expand Up @@ -34,6 +35,8 @@ func TestAccAWSWafRegionalIPSet_basic(t *testing.T) {
"aws_wafregional_ipset.ipset", "ip_set_descriptor.4037960608.type", "IPV4"),
resource.TestCheckResourceAttr(
"aws_wafregional_ipset.ipset", "ip_set_descriptor.4037960608.value", "192.0.7.0/24"),
resource.TestMatchResourceAttr("aws_wafregional_ipset.ipset", "arn",
regexp.MustCompile(`^arn:[\w-]+:waf-regional:[^:]+:\d{12}:ipset/.+$`)),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/wafregional_ipset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ The following arguments are supported:
In addition to all arguments above, the following attributes are exported:

* `id` - The ID of the WAF IPSet.
* `arn` - The ARN of the WAF IPSet.

0 comments on commit 14df762

Please sign in to comment.