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

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

Open
dev-dull opened this issue Jun 28, 2018 · 3 comments

Comments

@dev-dull
Copy link
Owner

dev-dull commented Jun 28, 2018

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
Copy link
Owner Author

dev-dull commented May 21, 2019

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
Copy link
Owner Author

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
Copy link
Owner Author

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.

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

1 participant