PyTerraBackTyl icon indicating copy to clipboard operation
PyTerraBackTyl copied to clipboard

Changes to JSON output in Terraform 0.12 might break some automatic parsing features (e.g.: the Slack plugin)

Open dev-dull opened this issue 7 years ago • 3 comments

Hasicorp announced a number of improvements that will come to Terraform 0.12 including 1:1 mapping of Terraform HCL parameters and the tfstate JSON file. PyTerraBackTYL does some automated parsing of the state file (specifically to gather hostnames) which may break depending on how significantly the JSON format changes.

Reference: https://www.hashicorp.com/blog/terraform-0-1-2-preview

The fix here will be mostly (if not completely) a configuration change: The JSON paths defined in the HELPER_HOSTNAME_QUERY_MAP configuration item of config.yaml will need to be updated to match the new hostname locations.

In addition to the configuration change, the hard-coded JSON path in abc_tylstore.TYLHelpers.get_hostnames_from_tfstate(), which is used to identify the provider type, may also need updated.

dev-dull avatar Jun 28 '18 20:06 dev-dull

I've confirmed that the JSON in Terraform 0.12 has some significant changes that will require one of two possible solutions .

Option 1:

  • Terraform provider detection:
    • Grab the terraform version number out of the tfstate file.
    • Based on the version, use the appropriate JSON path to grab the provider
    • CAUTION: It appears that the current Terraform 0.12 Beta currently returns as v0.11.8
  • Hostname retrieval:
    • Check for both v0.11 and v0.12 HELPER_HOSTNAME_QUERY_MAP configurations
    • Use Terraform version (grabbed from previous) to use the right set of JSON paths

OR

Option 2:

  • Make the JSON path for provider detection user-configurable in config.yaml and provide 0.11 and 0.12 configurations.

dev-dull avatar May 21 '19 21:05 dev-dull

Regarding Terraform version being misreported, see Terraform issue 21379. The work-around for now is to start with brand new Terraform environment and then the version should be correctly reported as 0.12 in the state file.

dev-dull avatar May 21 '19 22:05 dev-dull

Terraform 0.12 was released when I wasn't looking. A quick fix now exists in the 'beta' branch. See changes to config.yaml and abc_tylstore.TYLHelpers.

You should apply the changes in the beta branch if you are using Terraform 0.12 AND you use the TYLHelpers.get_hostnames_from_tfstate() funciton. Note that the mentioned function is used in the Slack plugin.

dev-dull avatar Jun 19 '19 22:06 dev-dull