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

add arn to aws_wafregional_ipset #4816

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.