Skip to content

Add native HCP Terraform run-id input support (--hcp-run-id) in tfplan2md #632

Description

@dwizzle204

Feature request

Please add native support for generating reports directly from an HCP Terraform run ID, without requiring users to manually download plan JSON first.

Motivation

Today, using tfplan2md with HCP Terraform workflows typically requires extra scripting to:

  1. Call HCP/TFC APIs
  2. Locate the plan artifact for a run
  3. Download and pass JSON to tfplan2md

A first-class HCP input path would simplify this dramatically for CI pipelines and local troubleshooting.

Proposed UX

Add a CLI option:

tfplan2md --hcp-run-id <run-id> --output report.md

Auth / endpoint configuration

  • TFE_TOKEN (required)
  • TFE_ADDRESS (optional, default https://app.terraform.io)

Input rules

  • --hcp-run-id should be mutually exclusive with positional plan-file input and explicit stdin input.
  • If --hcp-run-id is provided, it should be treated as the selected input source.

Expected behavior

Given a valid run ID and token, tfplan2md should:

  1. Resolve the run in HCP Terraform
  2. Retrieve the associated plan JSON (or equivalent payload needed for current render pipeline)
  3. Produce standard markdown output identical in structure to existing local JSON input behavior

Error handling expectations

Clear, actionable errors for:

  • missing TFE_TOKEN
  • invalid/nonexistent run ID
  • non-success HTTP responses (401/403/404/5xx)
  • malformed or unexpected API payloads
  • connectivity/timeouts

Why this would help

This would make tfplan2md much easier to adopt in real HCP Terraform environments by removing custom glue code and making run-based report generation a one-command workflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions