Skip to content

Commit

Permalink
Merge pull request #7718 from terraform-providers/td-aws_wafregional_…
Browse files Browse the repository at this point in the history
…byte_match_set-remove-deprecated

resource/aws_wafregional_byte_match_set: Remove deprecated byte_match_tuple configuration block
  • Loading branch information
bflad authored Feb 26, 2019
2 parents d41f922 + 53d5d6a commit f701972
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
35 changes: 8 additions & 27 deletions aws/resource_aws_wafregional_byte_match_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ func resourceAwsWafRegionalByteMatchSet() *schema.Resource {
ForceNew: true,
},
"byte_match_tuple": {
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"byte_match_tuples"},
Deprecated: "use `byte_match_tuples` instead",
Type: schema.TypeSet,
Optional: true,
Removed: "use `byte_match_tuples` configuration block(s) instead",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"field_to_match": {
Expand Down Expand Up @@ -155,15 +154,10 @@ func resourceAwsWafRegionalByteMatchSetRead(d *schema.ResourceData, meta interfa
return nil
}

if _, ok := d.GetOk("byte_match_tuple"); ok {
if err := d.Set("byte_match_tuple", flattenWafByteMatchTuplesWR(resp.ByteMatchSet.ByteMatchTuples)); err != nil {
return fmt.Errorf("error setting byte_match_tuple: %s", err)
}
} else {
if err := d.Set("byte_match_tuples", flattenWafByteMatchTuplesWR(resp.ByteMatchSet.ByteMatchTuples)); err != nil {
return fmt.Errorf("error setting byte_match_tuples: %s", err)
}
if err := d.Set("byte_match_tuples", flattenWafByteMatchTuplesWR(resp.ByteMatchSet.ByteMatchTuples)); err != nil {
return fmt.Errorf("error setting byte_match_tuples: %s", err)
}

d.Set("name", resp.ByteMatchSet.Name)

return nil
Expand Down Expand Up @@ -195,15 +189,7 @@ func resourceAwsWafRegionalByteMatchSetUpdate(d *schema.ResourceData, meta inter
region := meta.(*AWSClient).region
log.Printf("[INFO] Updating ByteMatchSet: %s", d.Get("name").(string))

if d.HasChange("byte_match_tuple") {
o, n := d.GetChange("byte_match_tuple")
oldT, newT := o.(*schema.Set).List(), n.(*schema.Set).List()

err := updateByteMatchSetResourceWR(d, oldT, newT, conn, region)
if err != nil {
return fmt.Errorf("Error updating ByteMatchSet: %s", err)
}
} else if d.HasChange("byte_match_tuples") {
if d.HasChange("byte_match_tuples") {
o, n := d.GetChange("byte_match_tuples")
oldT, newT := o.(*schema.Set).List(), n.(*schema.Set).List()

Expand All @@ -221,12 +207,7 @@ func resourceAwsWafRegionalByteMatchSetDelete(d *schema.ResourceData, meta inter

log.Printf("[INFO] Deleting ByteMatchSet: %s", d.Get("name").(string))

var oldT []interface{}
if _, ok := d.GetOk("byte_match_tuple"); ok {
oldT = d.Get("byte_match_tuple").(*schema.Set).List()
} else {
oldT = d.Get("byte_match_tuples").(*schema.Set).List()
}
oldT := d.Get("byte_match_tuples").(*schema.Set).List()

if len(oldT) > 0 {
var newT []interface{}
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_wafregional_rate_based_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ resource "aws_wafregional_ipset" "ipset" {
resource "aws_wafregional_byte_match_set" "set" {
name = "%s"
byte_match_tuple {
byte_match_tuples {
text_transformation = "NONE"
target_string = "badrefer1"
positional_constraint = "CONTAINS"
Expand Down
1 change: 0 additions & 1 deletion website/docs/r/wafregional_byte_match_set.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ resource "aws_wafregional_byte_match_set" "byte_set" {
The following arguments are supported:

* `name` - (Required) The name or description of the ByteMatchSet.
* `byte_match_tuple` - **Deprecated**, use `byte_match_tuples` instead.
* `byte_match_tuples` - (Optional)Settings for the ByteMatchSet, such as the bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests. ByteMatchTuple documented below.


Expand Down

0 comments on commit f701972

Please sign in to comment.