Skip to content

Create schemas for community terraform providers for use by the IntelliJ terraform plugin

Notifications You must be signed in to change notification settings

DaraDadachanji/terraform_provider_schema_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Plugin Schemas

The terraform plugin in IntelliJ relies on schemas for providers to provide suggestions. For community created plugins you have to generate these schemas yourself. This repository helps you do so

Instructions

add providers to providers.tf

for example:

terraform {
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "0.71.0"
    }
  }
}

Then run main.sh to generate and move the schemas

You may need to restart IntelliJ for it to take effect

How it works

Generating providers schema

terraform init will find and download required providers

terraform providers schema then converts those into a usable json format

converting providers schema

the raw format of the providers schema is slightly different from what the plugin expects. convert.py fixes the format.

For example the provider blocks look like

 {
    "provider": {
        "version": 0,
        "block": {
            "attributes": {
                "account": {
                    "type": "string",
                    "description": "blah blah blah",
                    "description_kind": "plain",
                    "optional": true
                },
                "browser_auth": {
                    "type": "bool",
                    "description": "blah blah blah",
                    "description_kind": "plain",
                    "optional": true
                }
            }
        }
    }
 }

While the plugin expects them to look like:

{
    "provider": {
        "account": {
            "type": "string",
            "description": "blah blah blah",
            "description_kind": "plain",
            "optional": true
        },
        "browser_auth": {
            "type": "bool",
            "description": "blah blah blah",
            "description_kind": "plain",
            "optional": true
        }
    }
}

The same is true of the resource schemas and data_source schemas

Loading the generated schemas

The terraform plugin expects the schemas at ~/.terraform.d/schemas

Extras

providers.tf contains a sample for the snowflake plugin

providers.schema.json can be used to validate your schema output if you choose to do the conversion some other way

About

Create schemas for community terraform providers for use by the IntelliJ terraform plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published