diff --git a/aws/resource_aws_waf_ipset.go b/aws/resource_aws_waf_ipset.go index 26c6fe74eb1..056098d4200 100644 --- a/aws/resource_aws_waf_ipset.go +++ b/aws/resource_aws_waf_ipset.go @@ -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/hashicorp/terraform/helper/schema" @@ -23,6 +24,10 @@ func resourceAwsWafIPSet() *schema.Resource { Required: true, ForceNew: true, }, + "arn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, "ip_set_descriptors": &schema.Schema{ Type: schema.TypeSet, Optional: true, @@ -94,6 +99,15 @@ func resourceAwsWafIPSetRead(d *schema.ResourceData, meta interface{}) error { d.Set("name", resp.IPSet.Name) + arn := arn.ARN{ + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Service: "waf", + AccountID: meta.(*AWSClient).accountid, + Resource: fmt.Sprintf("ipset/%s", d.Id()), + } + d.Set("arn", arn.String()) + return nil } diff --git a/aws/resource_aws_waf_ipset_test.go b/aws/resource_aws_waf_ipset_test.go index ee75931163d..f01c776f645 100644 --- a/aws/resource_aws_waf_ipset_test.go +++ b/aws/resource_aws_waf_ipset_test.go @@ -3,6 +3,7 @@ package aws import ( "fmt" "reflect" + "regexp" "testing" "github.com/hashicorp/terraform/helper/resource" @@ -33,6 +34,8 @@ func TestAccAWSWafIPSet_basic(t *testing.T) { "aws_waf_ipset.ipset", "ip_set_descriptors.4037960608.type", "IPV4"), resource.TestCheckResourceAttr( "aws_waf_ipset.ipset", "ip_set_descriptors.4037960608.value", "192.0.7.0/24"), + resource.TestMatchResourceAttr("aws_waf_ipset.ipset", "arn", + regexp.MustCompile(`^arn:[\w-]+:([a-zA-Z0-9\-])+:([a-z]{2}-(gov-)?[a-z]+-\d{1})?:(\d{12})?:(.*)$`)), ), }, }, diff --git a/website/docs/r/waf_ipset.html.markdown b/website/docs/r/waf_ipset.html.markdown index 4fd2ff866b5..87b5f105feb 100644 --- a/website/docs/r/waf_ipset.html.markdown +++ b/website/docs/r/waf_ipset.html.markdown @@ -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. \ No newline at end of file