diff --git a/hcl2/hcl2.lark b/hcl2/hcl2.lark index f477e3b5..ea2fd80e 100644 --- a/hcl2/hcl2.lark +++ b/hcl2/hcl2.lark @@ -5,8 +5,9 @@ block : identifier (identifier | STRING_LIT)* new_line_or_comment? "{" body "}" new_line_and_or_comma: new_line_or_comment | "," | "," new_line_or_comment new_line_or_comment: ( /\n/ | /#.*\n/ | /\/\/.*\n/ )+ -identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/ | IN +identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/ | IN | FOR IN : "in" +FOR : "for" ?expression : expr_term | operation | conditional diff --git a/hcl2/transformer.py b/hcl2/transformer.py index 998a9dd1..ddc7269f 100644 --- a/hcl2/transformer.py +++ b/hcl2/transformer.py @@ -116,7 +116,7 @@ def provider_function_call(self, args: List) -> str: args_str = "" if len(args) > 5: args_str = ", ".join([str(arg) for arg in args[5] if arg is not Discard]) - provider_func = "::".join([args[0],args[2],args[4]]) + provider_func = "::".join([args[0], args[2], args[4]]) return f"{provider_func}({args_str})" def arguments(self, args: List) -> List: diff --git a/test/helpers/terraform-config-json/resource_for_attribute.json b/test/helpers/terraform-config-json/resource_for_attribute.json new file mode 100644 index 00000000..51445926 --- /dev/null +++ b/test/helpers/terraform-config-json/resource_for_attribute.json @@ -0,0 +1,13 @@ +{ + "resource": [ + { + "custom_provider_resource": { + "resource_name": { + "name": "resource_name", + "attribute": "attribute_value", + "for": "attribute_value2" + } + } + } + ] +} diff --git a/test/helpers/terraform-config/resource_for_attribute.tf b/test/helpers/terraform-config/resource_for_attribute.tf new file mode 100644 index 00000000..3478644f --- /dev/null +++ b/test/helpers/terraform-config/resource_for_attribute.tf @@ -0,0 +1,5 @@ +resource "custom_provider_resource" "resource_name" { + name = "resource_name" + attribute = "attribute_value" + for = "attribute_value2" +}