uber / astro

Astro is a tool for managing multiple Terraform executions as a single command
Apache License 2.0
434 stars 31 forks source link

Detach flag is broken after update to 0.12 #44

Closed btromanova closed 5 years ago

btromanova commented 5 years ago

Running astro plan --detach after upgrading terraform configuration to 0.12 by following terraform guide from https://www.terraform.io/upgrade-guides/0-12.html gives the following error

module: ERROR
cannot delete key %v: does not exist

The problem seems to be that --detach tries to rewrite terraform block in the copied module config by removing backend field and gives an error when it fails to do so. terraform 0.12upgrade command creates versions.tf file with content

terraform {
  required_version = ">= 0.12"
}

Which creates a problem with current detach implementation.

btromanova commented 5 years ago

Actually, this was just the tip of the iceberg.

The implementation of the detach flag requires parsing the terraform configuration and removing remote backend configuration part.

Terraform 0.12 switched from https://github.com/hashicorp/hcl to https://github.com/hashicorp/hcl2, which requires to reimplement config parsing with the new library. So far I haven't seen clear documentation or examples of how to do what we were doing with the previous version of HCL (finding and removing the node with the specific path).