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

If a line ends with ")", the tagged file is invalid #56

Closed
RLRabinowitz opened this issue Oct 5, 2020 · 1 comment · Fixed by #63
Closed

If a line ends with ")", the tagged file is invalid #56

RLRabinowitz opened this issue Oct 5, 2020 · 1 comment · Fixed by #63
Assignees
Labels
P2 waiting-for-hashi Issue reported and waiting for a resolution in by hashicorp/hcl

Comments

@RLRabinowitz
Copy link
Contributor

The following file ends up as an invalid terraform file after tagging:

resource "kubernetes_deployment" "audit_server" {
  metadata {
    name = "terraform-example"
  }
  spec {
    replicas = var.pre_migration_scale_down_mode_enabled ? 0 : (var.minimal_setup_enabled ? local.minimal_setup_replicas : 1)
    strategy {
      type = local.kubernetes_deployment_strategy_rolling_update
    }
  }
}

resource "google_pubsub_topic" "audit_topic" {
}

The output file will contain the following lines:

  spec {
    replicas = var.pre_migration_scale_down_mode_enabled ? 0 : (var.minimal_setup_enabled ? local.minimal_setup_replicas : 1
      ) strategy {
      type = local.kubernetes_deployment_strategy_rolling_update
    }
  }

Trying to run terraform plan on that file will result in the error:

      ) strategy {
An argument definition must end with a newline.

The resource wasn't tagged, and yet it was still altered, and it became invalid because terratag dropped the ) to the next line

@RLRabinowitz
Copy link
Contributor Author

RLRabinowitz commented Oct 6, 2020

This seems to be caused by an issue with hclwrite.ParseConfig: hashicorp/hcl#402

@roni-frantchi roni-frantchi added waiting-for-hashi Issue reported and waiting for a resolution in by hashicorp/hcl and removed 🎯 focus labels Oct 7, 2020
@shlomimatichin shlomimatichin self-assigned this Oct 11, 2020
shlomimatichin added a commit to shlomimatichin/terratag that referenced this issue Oct 12, 2020
roni-frantchi added a commit that referenced this issue Oct 12, 2020
* Bugfix: #56, by forking hcl, submitted PR

* added test

Co-authored-by: Roni Frantchi <roni-frantchi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 waiting-for-hashi Issue reported and waiting for a resolution in by hashicorp/hcl
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants