Skip to content

Instantly share code, notes, and snippets.

@jodiecunningham
Created August 28, 2022 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodiecunningham/d2e9dd52d89d9646eda047c7ef30c085 to your computer and use it in GitHub Desktop.
Save jodiecunningham/d2e9dd52d89d9646eda047c7ef30c085 to your computer and use it in GitHub Desktop.
Quick view of Terraform resource schema
tfschema () {
if [ $# -ne 2 ]
then
echo -e "This function requires exactly two arguments, in order: providername resourcename "
echo "Try: tfschema registry.terraform.io/hashicorp/vsphere vsphere_virtual_machine"
echo "It is required to have already run terraform init with HCL for the provider used in the first argument."
echo "Try again. You have 1 life remaining. Exiting..."
return
fi
if ! which terraform >/dev/null 2>&1
then
echo "terraform not found. Exiting..."
return
fi
terraform providers schema --json|jq '.provider_schemas["'"$1"'"].resource_schemas["'"$2"'"].block| .attributes, .block_types|values'
}
@jodiecunningham
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment