Entity Requirements Documentation
Produce an OpenSpec spec (spec.md) for an existing Terraform resource or data source by examining its code path and capturing behavior. Follow dev-docs/high-level/openspec-requirements.md and the OpenSpec shape: ## Purpose, optional ## Schema, ## Requirements with ### Requirement: and #### Scenario: blocks; use SHALL / MUST in requirement text.
Input
- Entity: User specifies the Terraform entity (e.g.
elasticstack_elasticsearch_security_role) or the implementation path (e.g. internal/elasticsearch/security/role).
- Resolve the implementation package:
- For Plugin Framework based entities, search for
req.ProviderTypeName + "_...".
- For SDK based entities, this is defined in
internal/provider/provider.go.
Workflow
Locate implementation
- Resource: Package under
internal/ containing resource.Resource and Schema, Create, Read, Update, Delete (and optionally ImportState, UpgradeState).
- Data source: Package or file (e.g.
*_data_source.go) containing a data source Schema and Read.
Examine code path
Use the checklist in reference.md so nothing is missed:
- Schema (attributes, blocks, required/optional/computed, plan modifiers, validators).
- Metadata: type name, import, state upgrade.
- CRUD: which APIs are called, how
id is set, how errors and “not found” are handled.
- Connection: default client vs resource-level override (e.g.
elasticsearch_connection).
- Compatibility: version checks and “Unsupported Feature” behavior.
- Mapping: config/API/state (JSON parsing, empty vs null, preserve-unknown behavior).
- Lifecycle: replacement vs in-place update (e.g.
RequiresReplace).
Write the spec
- Path:
openspec/specs/<capability>/spec.md (e.g. openspec/specs/elasticsearch-security-role/spec.md). Use a stable capability id: <backend>-<area>-<resource> (see authoring guide).
- Title and implementation: H1 title and a line
Resource implementation: or Data source implementation: with the Go package path (as in legacy docs).
- Purpose: Short
## Purpose paragraph.
- Schema: Optional
## Schema with HCL-style block listing each attribute/block with <required|optional|optional+computed|computed>, types, and notes. Example reference: openspec/specs/elasticsearch-security-role/spec.md.
- Requirements:
### Requirement: … sections (group related behaviors; reference legacy REQ ids in titles like (REQ-001–REQ-003) when useful). Each requirement body MUST contain SHALL or MUST. Add #### Scenario: blocks (Given/When/Then) for verifiable behavior. Derive everything from the code; do not invent behavior. Categories: API, Identity, Import, Lifecycle, Connection, Compatibility, Create/Update, Read, Delete, Mapping, Plan/State, State, StateUpgrade. See reference.md.
Quality
- Every requirement must be traceable to the implementation (file/function or logic).
- Schema and requirements must be consistent (e.g. if schema has
description optional with a version note, there must be a Compatibility requirement for that version).
- For resources with state upgrade, include StateUpgrade requirements describing each version transition and error behavior.
Output format
Use this OpenSpec-oriented structure:
# `<name>` — Schema and Functional Requirements
Resource implementation: `<GO_PACKAGE_OR_DIR>`
## Purpose
...
## Schema
\`\`\`hcl
...
\`\`\`
## Requirements
### Requirement: Short name (REQ-xxx)
The resource SHALL ...
#### Scenario: ...
- GIVEN ...
- WHEN ...
- THEN ...
Reference
- Authoring:
dev-docs/high-level/openspec-requirements.md
- Example:
openspec/specs/elasticsearch-security-role/spec.md
- Full code-path checklist and requirement categories: reference.md
1---2name: existing-entity-requirements3description: Examines an existing Terraform resource or data source implementation and produces an OpenSpec requirements document under openspec/specs/. Use when the user asks to document requirements for a Terraform entity, capture behavior from code, or write a requirements doc for a resource/data source.4---56# Entity Requirements Documentation78Produce an **OpenSpec spec** (`spec.md`) for an existing Terraform resource or data source by examining its code path and capturing behavior. Follow [`dev-docs/high-level/openspec-requirements.md`](../../../dev-docs/high-level/openspec-requirements.md) and the OpenSpec shape: `## Purpose`, optional `## Schema`, `## Requirements` with `### Requirement:` and `#### Scenario:` blocks; use **SHALL** / **MUST** in requirement text.910## Input1112- **Entity**: User specifies the Terraform entity (e.g. `elasticstack_elasticsearch_security_role`) or the implementation path (e.g. `internal/elasticsearch/security/role`).13- Resolve the implementation package: 14* For Plugin Framework based entities, search for `req.ProviderTypeName + "_..."`. 15* For SDK based entities, this is defined in `internal/provider/provider.go`. 1617## Workflow18191. **Locate implementation**20 - **Resource**: Package under `internal/` containing `resource.Resource` and `Schema`, `Create`, `Read`, `Update`, `Delete` (and optionally `ImportState`, `UpgradeState`).21 - **Data source**: Package or file (e.g. `*_data_source.go`) containing a data source `Schema` and `Read`.22232. **Examine code path** 24 Use the checklist in [reference.md](reference.md) so nothing is missed:25 - Schema (attributes, blocks, required/optional/computed, plan modifiers, validators).26 - Metadata: type name, import, state upgrade.27 - CRUD: which APIs are called, how `id` is set, how errors and “not found” are handled.28 - Connection: default client vs resource-level override (e.g. `elasticsearch_connection`).29 - Compatibility: version checks and “Unsupported Feature” behavior.30 - Mapping: config/API/state (JSON parsing, empty vs null, preserve-unknown behavior).31 - Lifecycle: replacement vs in-place update (e.g. `RequiresReplace`).32333. **Write the spec**34 - **Path**: `openspec/specs/<capability>/spec.md` (e.g. `openspec/specs/elasticsearch-security-role/spec.md`). Use a stable capability id: `<backend>-<area>-<resource>` (see authoring guide).35 - **Title and implementation**: H1 title and a line `Resource implementation:` or `Data source implementation:` with the Go package path (as in legacy docs).36 - **Purpose**: Short `## Purpose` paragraph.37 - **Schema**: Optional `## Schema` with HCL-style block listing each attribute/block with `<required|optional|optional+computed|computed>`, types, and notes. Example reference: `openspec/specs/elasticsearch-security-role/spec.md`.38 - **Requirements**: `### Requirement: …` sections (group related behaviors; reference legacy REQ ids in titles like `(REQ-001–REQ-003)` when useful). Each requirement body MUST contain **SHALL** or **MUST**. Add `#### Scenario:` blocks (Given/When/Then) for verifiable behavior. Derive everything from the code; do not invent behavior. Categories: API, Identity, Import, Lifecycle, Connection, Compatibility, Create/Update, Read, Delete, Mapping, Plan/State, State, StateUpgrade. See [reference.md](reference.md).39404. **Quality**41 - Every requirement must be traceable to the implementation (file/function or logic).42 - Schema and requirements must be consistent (e.g. if schema has `description` optional with a version note, there must be a Compatibility requirement for that version).43 - For resources with state upgrade, include StateUpgrade requirements describing each version transition and error behavior.4445## Output format4647Use this OpenSpec-oriented structure:4849```markdown50# `<name>` — Schema and Functional Requirements5152Resource implementation: `<GO_PACKAGE_OR_DIR>`5354## Purpose55...5657## Schema58\`\`\`hcl59...60\`\`\`6162## Requirements6364### Requirement: Short name (REQ-xxx)6566The resource SHALL ...6768#### Scenario: ...69- GIVEN ...70- WHEN ...71- THEN ...72```7374## Reference7576- Authoring: `dev-docs/high-level/openspec-requirements.md`77- Example: `openspec/specs/elasticsearch-security-role/spec.md`78- Full code-path checklist and requirement categories: [reference.md](reference.md)