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

Add support for docs command which would get the documents for the provider #36148

Open
ujjwal-ibm opened this issue Dec 2, 2024 · 2 comments · May be fixed by #36149
Open

Add support for docs command which would get the documents for the provider #36148

ujjwal-ibm opened this issue Dec 2, 2024 · 2 comments · May be fixed by #36149
Labels
enhancement new new issue not yet triaged

Comments

@ujjwal-ibm
Copy link

Terraform Version

Terraform v1.7.5

Use Cases

  • Efficient Access to Documentation:As a Terraform user, I often need to refer to provider plugin documentation. Currently, this requires switching to the Terraform Registry, which disrupts my workflow.

  • Discovery of Resources and Data Sources: It's difficult to quickly identify available resources and data sources for a provider without manually browsing the Registry.

  • Offline or Simplified Access:There’s no straightforward way to fetch and access documentation directly within the terminal, especially when working offline

  • Streamlined Exploration:New providers or unfamiliar resources require constant back-and-forth between the terminal and the Registry, which is inefficient.

  • Improved Developer Experience:A built-in command for documentation would help both users and developers by reducing lookup time and enabling quick reference during development or debugging.

Attempted Solutions

  • Manual Access via Registry: Opened the Terraform Registry in a browser, searched for the provider, and manually located the relevant resource or data source. This process is time-consuming and disrupts the terminal-focused workflow.

  • Using terraform providers Command: Used the existing terraform providers command to list installed providers. This command does not offer detailed documentation or an overview of resources and data sources.

  • Downloading Provider Repositories: Cloned provider repositories to explore documentation. This is not a scalable solution and requires additional effort to locate relevant information.

Proposal

Introduce a new Terraform command: terraform docs

Key Features:

  • Fetch Documentation for Installed Providers
  • Display an overview of provider-specific resources and data sources.
  • List Available Resources and Data Sources
  • List all available options for a provider in a clear, terminal-friendly format.
  • Fetch Resource-Specific Documentation
  • Display detailed documentation for a specific resource or data source.

terraform docs -h

Usage: terraform docs [options] [resource(data)_name] [-r/-d flag] ''

Shows provider documentation for resources and data sources.

Options:
-l List all available resources and data sources

Examples:
terraform docs aws -l # List all AWS provider resources and data sources
terraform docs random random_id # Show documentation for the random_id resource

Additional Proposal:

  • Cache fetched documentation for offline use.
  • Include links to official Terraform Registry pages when displaying resource documentation for users requiring more details.

Example Scenarios:

List all resources and data sources:

terraform docs aws -l

Output:

Resources:

  • aws_instance
  • aws_s3_bucket
  • aws_vpc

Data Sources:

  • aws_ami
  • aws_subnet
  • aws_vpc_endpoint

View detailed documentation for a specific resource:

terraform docs aws aws_instance -r

Output:

Resource: aws_instance
Description: Manages an EC2 instance on AWS.

Arguments:
- ami (string) - ID of the AMI to use for the instance.
- instance_type (string) - Type of instance to start.

Example:
    resource "aws_instance" "example" {
      ami           = "ami-12345678"
      instance_type = "t2.micro"
    }

References

No response

@ujjwal-ibm ujjwal-ibm added enhancement new new issue not yet triaged labels Dec 2, 2024
@ujjwal-ibm ujjwal-ibm linked a pull request Dec 2, 2024 that will close this issue
@crw
Copy link
Contributor

crw commented Dec 2, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@ujjwal-ibm
Copy link
Author

@crw thanks for the quick reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants