Terraform provider

From ippontech/terraform-provider-anthropic · View interactive version

Terraform provider is an AI agent skill from the GitHub repository ippontech/terraform-provider-anthropic. Adds or changes resources, data sources, examples, documentation templates and Terraform native tests in this Go Terraform provider for the Anthropic API. Use when implementing, updating or removing a resource or data source, adding a Go dependency, or writing a `.tftest.hcl` test or a docs template

How to use this skill

Skill file

terraform-provider

CLAUDE.md is the reference for this provider: architecture, the steps of Adding a resource or data source, Testing (Go tests and Terraform native tests), Provider coding conventions and Commands. Read those sections before writing code, plus internal/services/<service>/CLAUDE.md for the service you touch when that file exists. This skill only adds what CLAUDE.md does not carry; when the two disagree, CLAUDE.md wins and this skill needs fixing.

Start from a sibling

Before writing a resource or data source, read the closest existing one in the same service (same API family and credential), its tests, its example and its template, and copy their shape. The service package already shows the client it uses (pd.Client, pd.AdminClient, pd.AdminKeyClient or pd.OAuthClient), its shared test helpers and its state-mapping style; a new file that diverges from its siblings is the most common review finding.

Go dependencies

Pin every new module to an explicit version, because @latest takes whatever was published last, pre-release or minutes-old release included, and the version should be a deliberate choice visible in review. List the versions, pick the most recent stable release, then tidy:

go list -m -versions github.com/author/dependency
go get github.com/author/dependency@vX.Y.Z
go mod tidy

Commit go.mod and go.sum together; make tidy-check (part of make) fails when they are not tidy. The Anthropic Go SDK has its own pin and bump rule in CLAUDE.md: do not bump it as part of a feature.

Terraform file names

Use snake_case for every new Terraform file (data_source.tf, resource.tf, versions.tf), because the docs templates and native tests reference these exact names. Two older examples still use data-source.tf; leave them unless the task is to rename them.

Documentation

docs/ is generated by make generate and published as is to the Terraform Registry:

Every template under templates/resources/ and templates/data-sources/ follows the same shape. Copy a sibling from the same subcategory and adapt it:

---
page_title: "anthropic_<name> Resource - anthropic"
subcategory: "<Category>"
description: |-
  One-line description.
---

# anthropic_<name> (Resource)

One-line description, then any load-bearing behaviour (archive on destroy, write-only secrets).

> **API**: `POST/GET/DELETE /v1/<path>[/{id}]` (<API family>).
> **Auth**: Standard API key (`api_key` / `ANTHROPIC_API_KEY`).
> **Beta header**: `anthropic-beta: <header>` (or None).
> **Cost**: Free for management (or what is billed).

## Example Usage

{{ codefile "hcl" "examples/resources/<name>/resource.tf" }}

{{ .SchemaMarkdown | trimspace }}

## Import

Import an existing <name> using its ID:

terraform import anthropic_<name>.example <id>

For a data source: page_title: "anthropic_<name> Data Source - anthropic", the heading (Data Source), the example path examples/data-sources/<name>/data_source.tf, and no Import section. Reuse an existing subcategory value (grep -h '^subcategory' templates/*/*.tmpl | sort -u) rather than inventing a near-duplicate, because each distinct value becomes a group in the Registry sidebar.

Native tests

The layout of tests/ (root module, ../examples/... sources, the file-level test { parallel = true }, plan-only and mock_provider cases) is in CLAUDE.md, Terraform native tests. When writing a test file, these run block options are the ones this repository uses:

| Option | Default | Use |

|---|---|---|

| command | apply | plan for Admin API and OAuth resources, which have no test organization or CI token (see CLAUDE.md) |

| module | none | source = "../examples/<kind>/<name>", always the public example |

| variables | none | overrides for this run only |

| assert | none | one condition and error_message per check |

| expect_failures | none | a validation or check block that must fail |

| state_key | none | shares state between runs that source different modules |

When writing the test:

Done

The change is ready to commit when make passes (it formats, lints, tests, installs and regenerates docs), make terraform-test passes (or you state which tests could not run for lack of credentials), pre-commit run -a passes with the new files staged (it skips untracked files), and docs/ shows the regenerated page with a non-empty subcategory.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.