Created
August 28, 2022 03:14
-
-
Save jodiecunningham/d2e9dd52d89d9646eda047c7ef30c085 to your computer and use it in GitHub Desktop.
Quick view of Terraform resource schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} |
Author
jodiecunningham
commented
Aug 28, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment