Skip to content

terraform_docs failing on complex types which contains "description"  #65

@MaxymVlasov

Description

@MaxymVlasov

How reproduce

Working code:

staged README.md

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

staged vars.tf

variable "ingress_cidr_blocks" {
  description = "Bzzzzz"
  type = list(
    object({
      # description = string
      cidr_blocks = string
      from_port   = number
      to_port     = number
      protocol    = string
    })
  )

  default = [
    {
      description = "SG"
      cidr_blocks = "10.0.0.0/32"
      from_port   = 22
      to_port     = 22
      protocol    = "tcp"
    },
  ]
}

provider "aws" {
  region = "eu-west-1"
}

If uncomment # description = string - terraform_docs failed:

Terraform docs...........................................................Failed
hookid: terraform_docs

2019/09/09 18:19:45 At 4:21: Unknown token: 4:21 IDENT string

Root case

Error happens because awk rewrite this type to next construction:

variable "ingress_cidr_blocks" {
  description = "Bzzzzz"
  type = "list("
      description = string
  default = [
    {
      description = "SG"
      cidr_blocks = "10.0.0.0/32"
      from_port   = 22
      to_port     = 22
      protocol    = "tcp"
    },
  ]
}

Suggestion

"type" need be rewrite to "multiline", but I spend about 2 hours on it and not get excepted result.
I made crutch that fix error, but it will be good have full value, as in "default" block.

Workaround

Just not specify description field in complex types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions