This is the repository for Couchbase's Terraform-Provider-Capella which forms a Terraform plugin for use with Couchbase Capella.
- We use Go Modules to manage dependencies, so you can develop outside your
$GOPATH. - We use golangci-lint to lint our code, you can install it locally via
make setup.
To use a released provider in your Terraform environment, run terraform init and Terraform will automatically install the provider.
Documentation about the provider specific configuration options can be found on the provider's website.
See Contributing.md
For information on how to prepare and release a new version of the provider, see Release Process Documentation.
The release process is automated with a single command:
make release-prep VERSION=1.5.4This automatically generates changelogs and upgrade guides with intelligent content extraction from PRs.
Most of the new features of the provider are using capella-public-apis Public APIs are updated automatically, tracking all new Capella features.
This repository includes an OpenAPI-generated client in internal/generated/api (keeping the existing hand-written client in internal/api for backward compatibility).
Generate/update the client before working on a new resource or data source:
-
Ensure the generator is installed:
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest -
Regenerate from the root
openapi.generated.yaml:make gen-api
The command writes the client/types to internal/generated/api/openapi.gen.go.
Notes:
- Provider wiring makes both clients available:
providerschema.Data.ClientV1: legacy HTTP client (internal/api)providerschema.Data.ClientV2: generated client with typed methods (internal/generated/api)
- When adding a new resource/data source, prefer calling
ClientV2for new endpoints and migrate incrementally.
Provider documentation is automatically generated from Go schema definitions and custom templates:
make build-docsThis command:
- Generates documentation using
tfplugindocs - Copies custom content from
templates/todocs/ - Automatically reads OpenAPI spec from
openapi.generated.yamlat runtime
Note: The OpenAPI spec is loaded from the filesystem at runtime, so documentation is always up-to-date with the latest spec changes - no rebuild needed!
Field descriptions are automatically extracted from the OpenAPI spec using the SchemaBuilder and a generic function:
// In internal/resources/project_schema.go
var projectBuilder = capellaschema.NewSchemaBuilder("project")
"name": capellaschema.WithOpenAPIDescription(
projectBuilder,
stringAttribute([]string{required}),
"name", // Automatically finds description in OpenAPI spec
), // No type assertion needed - fully type-safe!This provides rich documentation with:
- Detailed field descriptions
- Validation constraints (min/max length, patterns)
- Enum values and defaults
- Format specifications (UUID, date-time, etc.)
See internal/docs/README.md for implementation details.
To preserve custom content (upgrade guides, custom pages):
-
Add files to
templates/directory:templates/ ├── guides/ # Upgrade guides ├── index.md.tmpl # Custom homepage └── ... -
Run
make build-docs- your custom content will be preserved
The directory structure follows Terraform ecosystem conventions:
/
├── templates/ ← SOURCE (input files you edit)
├── docs/ ← OUTPUT (generated, DO NOT EDIT)
└── examples/
Separation of Concerns:
templates/= What you write (source files)docs/= Whattfplugindocsgenerates (output)
When tfplugindocs runs, it:
- Clears/updates the
docs/directory - Generates docs from Go schemas
- Copies from
templates/→docs/
If templates/ were inside docs/, it would be deleted during generation! This pattern is used by all official Terraform providers (AWS, Google, Azure, etc.) and is the default behavior of tfplugindocs.
Important: Never edit files in docs/ directly - they will be overwritten!
- DO edit files in
templates/for custom content - DO edit Go schema files for field descriptions
- DO run
make build-docsafter changes - DON'T manually edit generated files in
docs/
See templates/README.md for more details.