Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Display the configuration_aliases associated with the required_providers #819

@christopher-howse-vgh

Description

@christopher-howse-vgh

What problem are you facing?

I want to be able to programatically determine the aliases needed for providers when I'm publishing a reusable terraform module. This would allow me to publish parsable documentation alongside my module so that I could prompt a user to supply the required providers when they want to deploy that module.

When I run terraform-docs json --show providers,requirements . on this module:

module "submodule" {
  providers = {
    null.example-alias = null.example-alias
  }
  source = "./submodule"
}

terraform {
  required_providers {
    null = {
      source  = "hashicorp/null"
      version = "3.2.3"
      configuration_aliases = [null.example-alias]
    }
  }
}

provider "null" {
  alias = "example-alias"
}

I'm given the following output:

{
  "header": "",
  "footer": "",
  "inputs": [],
  "modules": [],
  "outputs": [],
  "providers": [],
  "requirements": [
    {
      "name": "null",
      "version": "3.2.3"
    }
  ],
  "resources": []
}

This doesn't tell me anything about the alias "example-alias" that needs to be used for the null provider.

How could terraform-docs help solve your problem?

terraform-docs could help solve this problem by exposing the configuration_aliases alongside the name and version information of each requirement.

If I was presented with this output:

{
  "header": "",
  "footer": "",
  "inputs": [],
  "modules": [],
  "outputs": [],
  "providers": [],
  "requirements": [
    {
      "name": "null",
      "version": "3.2.3",
      "aliases": "null.example-alias"
    }
  ],
  "resources": []
}

Then I would know what aliases to prompt the users for when they wish to deploy a terraform module.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions