Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Name in resources section into Resource Type and ResourceName #645

Open
nitrocode opened this issue Oct 25, 2022 · 1 comment · May be fixed by #649
Open

Split Name in resources section into Resource Type and ResourceName #645

nitrocode opened this issue Oct 25, 2022 · 1 comment · May be fixed by #649

Comments

@nitrocode
Copy link
Contributor

nitrocode commented Oct 25, 2022

What problem are you facing?

Id like a cleaner resource section by breaking up the current Name which is the fully qualified address of the resource into Type and Name

https://developer.hashicorp.com/terraform/cli/state/resource-addressing#resource-spec

A resource spec addresses a specific resource instance in the selected module. It has the following syntax:
resource_type.resource_name[instance index]

  • resource_type - Type of the resource being addressed.
  • resource_name - User-defined name of the resource.
  • [instance index] - (Optional) Index to select an instance from a resource that has multiple instances, surrounded by square bracket characters ([ and ]).

How could terraform-docs help solve your problem?

Current render

Name Type
aws_iam_role.default resource
aws_partition.default data source

Current code

|     Name                   |         Type              |
|----------------------------|---------------------------|
|    aws_iam_role.default |         resource          |
|    aws_partition.default |          data source      |

New render

Resource Type Resource Name Type
aws_iam_role default resource
aws_partition default data source

New code

|     Resource Type                   |     Resource Name                   |         Type              |
|----------------------------|---------------------------|---------------------------|
|    [aws_iam_role]() [↪](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | default |         resource          |
|    [aws_partition]() [↪](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | default |          data source      |

We could also add a column for the index to differentiate between count and for each resources

Currently there is only a link to the upstream resource name in the registry docs but it would be nice to also add an anchor link somehow. We usually use it on the name so perhaps we can keep that consistent and create a separate link to upstream docs using

@nitrocode nitrocode changed the title Split Name in reaources section into Type and Name Split Name in resources section into Type and Name Oct 25, 2022
@nitrocode nitrocode changed the title Split Name in resources section into Type and Name Split Name in resources section into Resource Type and ResourceName Oct 25, 2022
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
…rmats to use the GetResourceType() and the GetResourceName() functions
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
…tions in favor of Spec()

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
…me() functions

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
…rmats to use the GetResourceType() and the GetResourceName() functions

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
…and name splitted format

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Nov 4, 2022
… format

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Jul 20, 2023
…tions in favor of Spec()

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Jul 20, 2023
…me() functions

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Jul 20, 2023
Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Jul 20, 2023
…rmats to use the GetResourceType() and the GetResourceName() functions

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Jul 20, 2023
…and name splitted format

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
edgarsandi added a commit to edgarsandi/terraform-docs that referenced this issue Jul 20, 2023
… format

Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
@jason-johnson
Copy link

jason-johnson commented Sep 14, 2023

In the meantime, this can be done via the .Module field. The structure is defined here.

E.g. I wanted to have a table of just the resources (the data sources the module uses are kind of private information) so I didn't want to show the "type" (it's always resource) or the name of the resource (also implementation detail). I used this:

## Resources

| Name |
| ---- | 
{{- range .Module.Resources }}
  {{- if eq .GetMode "resource" }}
  | [{{ .ProviderName }}_{{ .Type }}]({{ .URL }}) |
  {{- end -}}
{{- end }}

Note that I concat provider name with type so that the constructed string matches what is actually in the tf file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants