Skip to content

Commit

Permalink
Fix 'Invalid value for "inputMap" parameter: the given object has no …
Browse files Browse the repository at this point in the history
…attribute "type"' (#102)

The current code has a bug:
```
│ Error: Invalid function argument
│
│   on .terraform/modules/waf.waf/main.tf line 6111, in resource "aws_wafv2_web_acl" "main":
│ 6111:                       priority = lookup(byte_match_statement.value, "priority")
│     ├────────────────
│     │ byte_match_statement.value is object with 4 attributes
│
│ Invalid value for "inputMap" parameter: the given object has no attribute "priority".
╵
╷
│ Error: Invalid function argument
│
│   on .terraform/modules/waf.waf/main.tf line 6112, in resource "aws_wafv2_web_acl" "main":
│ 6112:                       type     = lookup(byte_match_statement.value, "type")
│     ├────────────────
│     │ byte_match_statement.value is object with 4 attributes
│
│ Invalid value for "inputMap" parameter: the given object has no attribute "type".
```

This happens because we need to fetch the text_transformation element of
the object and not the object itself.
  • Loading branch information
nunofernandes authored May 19, 2023
1 parent 4b5da5c commit ee76f54
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,7 @@ resource "aws_wafv2_web_acl" "main" {
}

dynamic "scope_down_statement" {
for_each = length(lookup(rate_based_statement.value, "scope_down_statement", {})) == 0 ? [] : [lookup(rate_based_statement.value, "scope_down_statement", {})]
for_each = contains(keys(rate_based_statement.value), "scope_down_statement") && rate_based_statement.value["scope_down_statement"] != null ? [lookup(rate_based_statement.value, "scope_down_statement", {})] : []
content {
# scope down byte_match_statement
dynamic "byte_match_statement" {
Expand Down Expand Up @@ -6108,8 +6108,8 @@ resource "aws_wafv2_web_acl" "main" {
positional_constraint = lookup(byte_match_statement.value, "positional_constraint")
search_string = lookup(byte_match_statement.value, "search_string")
text_transformation {
priority = lookup(byte_match_statement.value, "priority")
type = lookup(byte_match_statement.value, "type")
priority = lookup(byte_match_statement.value["text_transformation"], "priority")
type = lookup(byte_match_statement.value["text_transformation"], "type")
}
}
}
Expand Down

0 comments on commit ee76f54

Please sign in to comment.