provider/aws: Allow WAF SizeConstraint with no tuples
This commit is contained in:
parent
3fb671be1f
commit
bf99b53d17
|
@ -115,6 +115,7 @@ func resourceAwsWafSizeConstraintSetRead(d *schema.ResourceData, meta interface{
|
||||||
func resourceAwsWafSizeConstraintSetUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsWafSizeConstraintSetUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AWSClient).wafconn
|
conn := meta.(*AWSClient).wafconn
|
||||||
|
|
||||||
|
if d.HasChange("size_constraints") {
|
||||||
o, n := d.GetChange("size_constraints")
|
o, n := d.GetChange("size_constraints")
|
||||||
oldS, newS := o.(*schema.Set).List(), n.(*schema.Set).List()
|
oldS, newS := o.(*schema.Set).List(), n.(*schema.Set).List()
|
||||||
|
|
||||||
|
@ -122,6 +123,7 @@ func resourceAwsWafSizeConstraintSetUpdate(d *schema.ResourceData, meta interfac
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf("[ERROR] Error updating SizeConstraintSet: {{err}}", err)
|
return errwrap.Wrapf("[ERROR] Error updating SizeConstraintSet: {{err}}", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resourceAwsWafSizeConstraintSetRead(d, meta)
|
return resourceAwsWafSizeConstraintSetRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,29 @@ func TestAccAWSWafSizeConstraintSet_changeConstraints(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccAWSWafSizeConstraintSet_noConstraints(t *testing.T) {
|
||||||
|
var ipset waf.SizeConstraintSet
|
||||||
|
setName := fmt.Sprintf("sizeConstraintSet-%s", acctest.RandString(5))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckAWSWafSizeConstraintSetDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccAWSWafSizeConstraintSetConfig_noConstraints(setName),
|
||||||
|
Check: resource.ComposeAggregateTestCheckFunc(
|
||||||
|
testAccCheckAWSWafSizeConstraintSetExists("aws_waf_size_constraint_set.size_constraint_set", &ipset),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_waf_size_constraint_set.size_constraint_set", "name", setName),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_waf_size_constraint_set.size_constraint_set", "size_constraints.#", "0"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckAWSWafSizeConstraintSetDisappears(v *waf.SizeConstraintSet) resource.TestCheckFunc {
|
func testAccCheckAWSWafSizeConstraintSetDisappears(v *waf.SizeConstraintSet) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).wafconn
|
conn := testAccProvider.Meta().(*AWSClient).wafconn
|
||||||
|
@ -308,3 +331,10 @@ resource "aws_waf_size_constraint_set" "size_constraint_set" {
|
||||||
}
|
}
|
||||||
}`, name)
|
}`, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccAWSWafSizeConstraintSetConfig_noConstraints(name string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "aws_waf_size_constraint_set" "size_constraint_set" {
|
||||||
|
name = "%s"
|
||||||
|
}`, name)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue