Skip to content

Instantly share code, notes, and snippets.

@nitrocode
Created June 15, 2018 02:36
Show Gist options
  • Select an option

  • Save nitrocode/b9e59eb852a47d260df910dcabdb7fdb to your computer and use it in GitHub Desktop.

Select an option

Save nitrocode/b9e59eb852a47d260df910dcabdb7fdb to your computer and use it in GitHub Desktop.
tfa will read the terraform.tfstate file and print out all the attributes of a resource
#!/bin/sh
# Usage: tfa aws_instance.demo
# Depends on jq
# Must be run in a directory where the json terraform.tfstate file exists
function tfa () {
cat terraform.tfstate | jq ".modules[0].resources.\"$1\".primary.attributes";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment