Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf12 errors on parameter list format #207

Open
twellspring opened this issue Jun 25, 2020 · 1 comment
Open

tf12 errors on parameter list format #207

twellspring opened this issue Jun 25, 2020 · 1 comment

Comments

@twellspring
Copy link
Contributor

For the tf12 parser the block syntax works as expected:

  parameter {
        name  = "tls"
        value = "enabled"
      }
  parameter  {
        name = "audit_logs"
        value = "enabled"
      }

But the list of objects returns a warning/failure condition for the same rule

  parameter   = 
    [{
        name  = "tls"
        value = "enabled"
      },
      {
        name = "audit_logs"
        value = "enabled"
      }]

Per https://www.terraform.io/docs/configuration/attr-as-blocks.html this syntax is not recommended, but is still supported.

Assertion that works for blocks and fails for list of objects

    assertions:
      - some:
          key: parameter
          expressions:
            - and:
              - key: name
                op: eq
                value: tls
              - key: value
                op: eq
                value: enabled
@milldr milldr self-assigned this Jul 7, 2020
milldr added a commit that referenced this issue Jul 7, 2020
@milldr
Copy link
Contributor

milldr commented Jul 8, 2020

I am able to reproduce the error and am working on a resolution. So far, looks like separate blocks are grouped together as a single block and then linted. Whereas a joined block that's already in that format isnt read correctly, and instead UNDEFINED is returned. Looking into why now.

In this example, fail_best has the working, separated block syntax and fail_alt has the failing, joined as a list block syntax.

  {                                                                         
    "ID": "fail_best",                                                      
    "Type": "aws_redshift_parameter_group",                                 
    "Category": "resource",                                                 
    "Properties": {                                                         
      "__name__": "fail_best",                                              
      "__type__": "aws_redshift_parameter_group",                           
      "family": "redshift-1.0",                                             
      "name": "fail_foo",                                                   
      "parameter": [                                                        
        {                                                                   
          "name": "tls",                                                    
          "value": "disabled"                                               
        },                                                                  
        {                                                                   
          "name": "audit_logs",                                             
          "value": "enabled"                                                
        }                                                                   
      ]                                                                     
    },                                                                      
    "Filename": "./testdata/resources/attr_block_syntax.tf",                
    "LineNumber": 33                                                        
  },                                                                        
  {                                                                         
    "ID": "fail_alt",                                                       
    "Type": "aws_redshift_parameter_group",                                 
    "Category": "resource",                                                 
    "Properties": {                                                         
      "__name__": "fail_alt",                                               
      "__type__": "aws_redshift_parameter_group",                           
      "family": "redshift-1.0",                                             
      "name": "fail_bar",                                                   
      "parameter": "UNDEFINED"                                              
    },                                                                      
    "Filename": "./testdata/resources/attr_block_syntax.tf",                
    "LineNumber": 48                                                        
  }                                                                         

@milldr milldr removed their assignment Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants