Skip to content

Commit a20ba47

Browse files
committed
feat(teo): add message field to teo bind security template resource
1 parent e90d9a2 commit a20ba47

16 files changed

Lines changed: 1651 additions & 1574 deletions

File tree

.changelog/4352.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```release-note:enhancement
2-
resource/tencentcloud_teo_bind_security_template: add message computed parameter and replace read API with DescribeSecurityTemplateBindings
3-
```
2+
resource/tencentcloud_teo_bind_security_template: add `message` computed parameter
3+
```

openspec/changes/archive/2026-07-28-add-teo-bind-security-template-message/design.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

openspec/changes/archive/2026-07-28-add-teo-bind-security-template-message/proposal.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

openspec/changes/archive/2026-07-28-add-teo-bind-security-template-message/specs/teo-bind-security-template-read-api/spec.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

openspec/changes/archive/2026-07-28-add-teo-bind-security-template-message/tasks.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

openspec/changes/archive/2026-07-28-add-teo-bind-security-template-message/.openspec.yaml renamed to openspec/changes/archive/2026-08-19-add-teo-bind-security-template-message/.openspec.yaml

File renamed without changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Context
2+
3+
The `tencentcloud_teo_bind_security_template` resource manages template-to-domain bindings for TEO security policies. The Read path uses `DescribeTeoBindSecurityTemplateById` which returns an `EntityStatus` struct. The vendor SDK's `EntityStatus` struct already includes a `Message` field (instance configuration delivery message), but the resource schema currently does not expose it.
4+
5+
The service layer `DescribeTeoBindSecurityTemplateById` handles special-case logic for locating bindings and is intentionally kept as-is. This change only adds the `message` computed field to the resource schema and sets it in the Read function when the returned `EntityStatus.Message` is non-nil.
6+
7+
## Goals / Non-Goals
8+
9+
**Goals:**
10+
- Add a `message` computed attribute to `tencentcloud_teo_bind_security_template` resource
11+
- Preserve all existing behavior (status field, id construction, nil handling, retry logic)
12+
13+
**Non-Goals:**
14+
- Do not modify the service layer `DescribeTeoBindSecurityTemplateById` function or any other service code
15+
- Do not change the Create or Delete paths (they use `BindSecurityTemplateToEntity` which is unaffected)
16+
- Do not add `message` as an input parameter (it is read-only/computed)
17+
- Do not change the `EntityStatus` struct in the vendor SDK
18+
19+
## Decisions
20+
21+
### Decision 1: Add `message` as a `Computed` field in the schema
22+
23+
**Rationale**: `Message` is read-only configuration delivery information. It should be `Computed` only (not `Required` or `Optional`), matching the pattern of the existing `status` field.
24+
25+
### Decision 2: Set `message` from `respData.Message` only when non-nil
26+
27+
**Rationale**: Following the existing pattern for the `status` field, the Read function only calls `d.Set("message", ...)` when `respData.Message` is not nil. This avoids overwriting the field unnecessarily and keeps the behavior consistent with the rest of the Read function.
28+
29+
## Risks / Trade-offs
30+
31+
- **Risk**: The service layer may not currently populate the `Message` field, so the `message` attribute may remain empty until the service layer is updated separately.
32+
**Mitigation**: This is acceptable and intentional — the service layer handles special cases and must not be modified in this change. The schema field is additive and backward compatible. When the service layer returns `Message`, it will automatically flow through to the resource state without further schema changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Why
2+
3+
The `tencentcloud_teo_bind_security_template` resource currently exposes only `status` from the template binding query result. The cloud API `EntityStatus` struct returned by the read path includes an additional `Message` field that provides human-readable delivery status information (e.g., failure reasons). Exposing this `Message` field as a computed attribute gives users visibility into configuration delivery details without having to check the cloud console.
4+
5+
## What Changes
6+
7+
- Add a new `message` computed attribute to the `tencentcloud_teo_bind_security_template` resource schema, sourced from the `Message` field of the `EntityStatus` returned by the read path.
8+
9+
## Capabilities
10+
11+
### New Capabilities
12+
- `teo-bind-security-template-message`: Expose the `Message` field of `EntityStatus` as a computed attribute on `tencentcloud_teo_bind_security_template`.
13+
14+
## Impact
15+
16+
- **Affected files**:
17+
- `tencentcloud/services/teo/resource_tc_teo_bind_security_template.go` — add `message` schema field and set it in Read
18+
- `tencentcloud/services/teo/resource_tc_teo_bind_security_template.md` — add `message` to example usage
19+
- `tencentcloud/services/teo/resource_tc_teo_bind_security_template_test.go` — add test coverage for `message`
20+
- **Backward compatibility**: Fully backward compatible — the new `message` field is computed-only, and the existing `status` field behavior is preserved

openspec/changes/archive/2026-07-28-add-teo-bind-security-template-message/specs/teo-bind-security-template-message/spec.md renamed to openspec/changes/archive/2026-08-19-add-teo-bind-security-template-message/specs/teo-bind-security-template-message/spec.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
## ADDED Requirements
22

3-
### Requirement: Resource exposes Message from DescribeSecurityTemplateBindings
4-
The `tencentcloud_teo_bind_security_template` resource SHALL expose a `message` computed attribute of type `TypeString` in its schema. The value SHALL be sourced from the `Message` field of `EntityStatus` returned by the `DescribeSecurityTemplateBindings` API.
3+
### Requirement: Resource exposes Message field
4+
The `tencentcloud_teo_bind_security_template` resource SHALL expose a `message` computed attribute of type `TypeString` in its schema. The value SHALL be sourced from the `Message` field of the `EntityStatus` returned by the read path's service function.
55

66
#### Scenario: Message is set during Read
7-
- **WHEN** the `DescribeSecurityTemplateBindings` API returns an `EntityStatus` with a non-nil `Message` field
7+
- **WHEN** the service function returns an `EntityStatus` with a non-nil `Message` field
88
- **THEN** the resource Read function SHALL set `message` on the resource data to the value of `EntityStatus.Message`
99

10-
#### Scenario: Message is nil in API response
11-
- **WHEN** the `DescribeSecurityTemplateBindings` API returns an `EntityStatus` with a nil `Message` field
10+
#### Scenario: Message is nil in service response
11+
- **WHEN** the service function returns an `EntityStatus` with a nil `Message` field
1212
- **THEN** the resource Read function SHALL NOT call `d.Set("message", ...)` (the field retains its prior value or zero value)
1313

1414
#### Scenario: Message is not set by user during Create
1515
- **WHEN** a user creates a `tencentcloud_teo_bind_security_template` resource without specifying `message`
16-
- **THEN** the resource SHALL still be created successfully because `message` is `Computed` only
16+
- **THEN** the resource SHALL still be created successfully because `message` is `Computed` only
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## 1. Resource Schema Changes
2+
3+
- [x] 1.1 Add `message` computed field (`TypeString`, `Computed: true`) to the resource schema in `resource_tc_teo_bind_security_template.go`.
4+
- [x] 1.2 In the `resourceTencentCloudTeoBindSecurityTemplateRead` function, set `message` from `respData.Message` when `respData.Message` is not nil.
5+
6+
## 2. Documentation
7+
8+
- [x] 2.1 Update `resource_tc_teo_bind_security_template.md` example usage to include the `message` attribute in the output.
9+
10+
## 3. Testing
11+
12+
- [x] 3.1 Add test cases in `resource_tc_teo_bind_security_template_test.go` to verify the `message` schema field exists and is `Computed`.
13+
- [x] 3.2 Add test case to verify the `message` attribute remains empty when the service layer does not populate `Message`.
14+
15+
## 4. Validation
16+
17+
- [x] 4.1 Verify the code compiles successfully with `go build ./...`. (Handled by tfpacer-finalize skill per workspace rules)
18+
- [x] 4.2 Run `make doc` to regenerate website documentation. (Handled by tfpacer-finalize skill per workspace rules)

0 commit comments

Comments
 (0)