Skip to content

Commit

Permalink
only modify 'enable_waf_fail_open' argument if configured on create
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Dec 6, 2021
1 parent 83f1d84 commit 3660b44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/22072.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_lb: Correctly configure `enable_waf_fail_open` during resource creation
```
7 changes: 6 additions & 1 deletion internal/service/elbv2/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,12 @@ func resourceLoadBalancerUpdate(d *schema.ResourceData, meta interface{}) error
})
}

if d.HasChange("enable_waf_fail_open") || d.IsNewResource() {
// The "waf.fail_open.enabled" attribute is not available in all AWS regions
// e.g. us-gov-east-1; thus, we can instead only modify the attribute as a result of d.HasChange()
// to avoid "ValidationError: Load balancer attribute key 'waf.fail_open.enabled' is not recognized"
// when modifying the attribute right after resource creation.
// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/22037
if d.HasChange("enable_waf_fail_open") {
attributes = append(attributes, &elbv2.LoadBalancerAttribute{
Key: aws.String("waf.fail_open.enabled"),
Value: aws.String(strconv.FormatBool(d.Get("enable_waf_fail_open").(bool))),
Expand Down

0 comments on commit 3660b44

Please sign in to comment.