Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resource/aws_waf_sql_injection_match_set: Properly set sql_injection_…
Browse files Browse the repository at this point in the history
…match_tuples into Terraform state

Reference: #9954

Previously:

```
/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_waf_sql_injection_match_set.go:101:38: R004: ResourceData.Set() incompatible value type: []*github.com/aws/aws-sdk-go/service/waf.SqlInjectionMatchTuple
```

Fixes `d.Set()` handling for this attribute with existing flatten function (used by `aws_wafregional_sql_injection_match_set` resource) and one associated test configuration so that it matches API canonicalization, which is now enforced by the testing since the value is being properly read into the Terraform state.

Output from acceptance testing:

```
--- PASS: TestAccAWSWafSqlInjectionMatchSet_noTuples (13.29s)
--- PASS: TestAccAWSWafSqlInjectionMatchSet_disappears (17.63s)
--- PASS: TestAccAWSWafSqlInjectionMatchSet_basic (17.65s)
--- PASS: TestAccAWSWafSqlInjectionMatchSet_changeTuples (23.46s)
--- PASS: TestAccAWSWafSqlInjectionMatchSet_changeNameForceNew (31.73s)
```
bflad committed Jan 6, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7683414 commit 3e1cc56
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 4 additions & 1 deletion aws/resource_aws_waf_sql_injection_match_set.go
Original file line number Diff line number Diff line change
@@ -98,7 +98,10 @@ func resourceAwsWafSqlInjectionMatchSetRead(d *schema.ResourceData, meta interfa
}

d.Set("name", resp.SqlInjectionMatchSet.Name)
d.Set("sql_injection_match_tuples", resp.SqlInjectionMatchSet.SqlInjectionMatchTuples)

if err := d.Set("sql_injection_match_tuples", flattenWafSqlInjectionMatchTuples(resp.SqlInjectionMatchSet.SqlInjectionMatchTuples)); err != nil {
return fmt.Errorf("error setting sql_injection_match_tuples: %s", err)
}

return nil
}
9 changes: 0 additions & 9 deletions aws/resource_aws_waf_sql_injection_match_set_test.go
Original file line number Diff line number Diff line change
@@ -134,14 +134,6 @@ func TestAccAWSWafSqlInjectionMatchSet_changeTuples(t *testing.T) {
"aws_waf_sql_injection_match_set.sql_injection_match_set", "name", setName),
resource.TestCheckResourceAttr(
"aws_waf_sql_injection_match_set.sql_injection_match_set", "sql_injection_match_tuples.#", "1"),
resource.TestCheckResourceAttr(
"aws_waf_sql_injection_match_set.sql_injection_match_set", "sql_injection_match_tuples.3333510133.field_to_match.#", "1"),
resource.TestCheckResourceAttr(
"aws_waf_sql_injection_match_set.sql_injection_match_set", "sql_injection_match_tuples.3333510133.field_to_match.4253810390.data", "GET"),
resource.TestCheckResourceAttr(
"aws_waf_sql_injection_match_set.sql_injection_match_set", "sql_injection_match_tuples.3333510133.field_to_match.4253810390.type", "METHOD"),
resource.TestCheckResourceAttr(
"aws_waf_sql_injection_match_set.sql_injection_match_set", "sql_injection_match_tuples.3333510133.text_transformation", "NONE"),
),
},
},
@@ -314,7 +306,6 @@ resource "aws_waf_sql_injection_match_set" "sql_injection_match_set" {
field_to_match {
type = "METHOD"
data = "GET"
}
}
}

0 comments on commit 3e1cc56

Please sign in to comment.