You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `tencentcloud_teo_l7_acc_rule_v2` resource manages TEO L7 acceleration rules through the cloud API. The resource currently supports `zone_id`, `rule_id`, `status`, `rule_name`, `description`, `branches`, and `rule_priority` parameters. The CRUD operations (Create, Read, Update, Delete) are already implemented using `CreateL7AccRules`, `DescribeL7AccRules`, `ModifyL7AccRule`, and `DeleteL7AccRules` API interfaces from the `teo/v20220901` SDK package.
4
+
5
+
The core data structure `RuleEngineItem` in the SDK contains: `Status`, `RuleId`, `RuleName`, `Description`, `Branches`, and `RulePriority`.
6
+
7
+
The current resource uses a composite ID (`zoneId + FILED_SP + ruleId`) and supports import via `ImportStatePassthrough`.
8
+
9
+
## Goals / Non-Goals
10
+
11
+
**Goals:**
12
+
- Ensure all CRUD API parameters are correctly mapped in the `tencentcloud_teo_l7_acc_rule_v2` resource
13
+
- Verify parameter consistency across CreateL7AccRules, ModifyL7AccRule, DeleteL7AccRules, and DescribeL7AccRules interfaces
14
+
- Maintain backward compatibility with existing Terraform configurations and state
15
+
16
+
**Non-Goals:**
17
+
- Adding new action types to the `branches.actions` schema (e.g., new operation names)
18
+
- Modifying the `RuleEngineItem` data structure or adding new SDK fields
19
+
- Changing the composite ID format or import behavior
20
+
21
+
## Decisions
22
+
23
+
1.**Parameter mapping approach**: All parameters listed in the requirement (`ZoneId`, `Rules`, `zone_id`, `rule_id`, `status`, `rule_name`, `description`, `branches`, `RuleIds`, `Values`) already exist in the current resource implementation. The Create function maps `zone_id` → `request.ZoneId` and individual fields → `RuleEngineItem` within `request.Rules`. The Modify function maps `zone_id` → `request.ZoneId` and fields → `request.Rule`. The Delete function maps `zone_id` → `request.ZoneId` and `rule_id` → `request.RuleIds`. The Describe (read) uses `Filters` with `Name: "rule-id"` and `Values: [ruleId]`.
24
+
25
+
2.**DescribeL7AccRules parameter mapping**: The requirement specifies `request.Values` → `rule_id`. In the SDK, `DescribeL7AccRulesRequest` uses `Filters []*Filter` where each `Filter` has `Name` and `Values` fields. The current implementation correctly uses `Filters` with `Name: "rule-id"` and `Values: []string{ruleId}`. This is the correct mapping since the SDK doesn't have a direct `Values` field at the request level.
26
+
27
+
3.**Backward compatibility**: All parameter additions are Optional or Computed, ensuring existing configurations remain valid.
28
+
29
+
## Risks / Trade-offs
30
+
31
+
-[Risk] Parameter naming inconsistency between Create (`ZoneId` → `ZoneId` in requirement vs `zone_id` in schema) → Mitigation: The schema uses snake_case as per Terraform convention; the mapping is correctly handled in the Create/Update functions
32
+
-[Risk] The DescribeL7AccRules API uses `Filters` not direct `Values` → Mitigation: Current implementation correctly uses `Filters` with `Name: "rule-id"` which maps to the `rule_id` parameter
The `tencentcloud_teo_l7_acc_rule_v2` resource needs to add new parameters to support the full CRUD lifecycle of L7 acceleration rules via the cloud API. The current resource already supports `zone_id`, `rule_id`, `status`, `rule_name`, `description`, `branches`, and `rule_priority`, but needs to be updated to properly map all parameters across the Create, Modify, Delete, and Describe API interfaces.
4
+
5
+
## What Changes
6
+
7
+
- Add parameter mappings for the `CreateL7AccRules` API interface (`ZoneId`, `Rules`)
8
+
- Add parameter mappings for the `ModifyL7AccRule` API interface (`zone_id`, `rule_id`, `status`, `rule_name`, `description`, `branches`)
9
+
- Add parameter mappings for the `DeleteL7AccRules` API interface (`zone_id`, `rule_id`)
10
+
- Add parameter mappings for the `DescribeL7AccRules` API interface (`rule_id` via `Values` filter)
11
+
12
+
## Capabilities
13
+
14
+
### New Capabilities
15
+
-`teo-l7-acc-rule-v2-crud-params`: Full CRUD parameter mapping support for the tencentcloud_teo_l7_acc_rule_v2 resource, ensuring all parameters are correctly mapped across CreateL7AccRules, ModifyL7AccRule, DeleteL7AccRules, and DescribeL7AccRules API interfaces.
16
+
17
+
### Modified Capabilities
18
+
-`rule-ids-output`: Update the existing spec to reflect the new CRUD parameter mappings and ensure consistency with the full API parameter set.
The `tencentcloud_teo_l7_acc_rule_v2` resource SHALL NOT have a `rule_ids` computed attribute. The `rule_id` attribute provides the single rule ID managed by this resource.
5
+
6
+
#### Scenario: rule_ids is not in schema
7
+
-**WHEN** a user inspects the `tencentcloud_teo_l7_acc_rule_v2` resource schema
8
+
-**THEN** there SHALL NOT be a `rule_ids` attribute
The `tencentcloud_teo_l7_acc_rule_v2` resource's Create function SHALL map the `zone_id` schema parameter to `request.ZoneId` and the rule fields (`status`, `rule_name`, `description`, `branches`) to a `RuleEngineItem` within `request.Rules` when calling the `CreateL7AccRules` API.
5
+
6
+
#### Scenario: Create maps zone_id to request.ZoneId
7
+
-**WHEN** a user creates a `tencentcloud_teo_l7_acc_rule_v2` resource with `zone_id = "zone-abc123"`
8
+
-**THEN** the `CreateL7AccRules` API SHALL be called with `request.ZoneId = "zone-abc123"`
9
+
10
+
#### Scenario: Create maps rule fields to request.Rules
11
+
-**WHEN** a user creates a resource with `status = "enable"`, `rule_name = "test"`, `description = ["desc"]`, `branches = [...]`
12
+
-**THEN** the `CreateL7AccRules` API SHALL be called with `request.Rules` containing a `RuleEngineItem` with the corresponding `Status`, `RuleName`, `Description`, and `Branches` fields
The `tencentcloud_teo_l7_acc_rule_v2` resource's Update function SHALL map the `zone_id` schema parameter to `request.ZoneId` and the rule fields to `request.Rule` (a `RuleEngineItem`) when calling the `ModifyL7AccRule` API.
16
+
17
+
#### Scenario: Update maps zone_id to request.ZoneId
18
+
-**WHEN** a user updates a `tencentcloud_teo_l7_acc_rule_v2` resource
19
+
-**THEN** the `ModifyL7AccRule` API SHALL be called with `request.ZoneId` set from the composite ID's zone_id part
20
+
21
+
#### Scenario: Update maps rule_id to request.Rule.RuleId
22
+
-**WHEN** a user updates a resource with composite ID `zone-abc#rule-xyz`
23
+
-**THEN** the `ModifyL7AccRule` API SHALL be called with `request.Rule.RuleId = "rule-xyz"`
24
+
25
+
#### Scenario: Update maps mutable fields to request.Rule
26
+
-**WHEN** a user changes `status`, `rule_name`, `description`, or `branches`
27
+
-**THEN** the `ModifyL7AccRule` API SHALL be called with `request.Rule` containing the updated `Status`, `RuleName`, `Description`, and/or `Branches` fields
The `tencentcloud_teo_l7_acc_rule_v2` resource's Delete function SHALL map the `zone_id` to `request.ZoneId` and `rule_id` to `request.RuleIds` when calling the `DeleteL7AccRules` API.
31
+
32
+
#### Scenario: Delete maps zone_id to request.ZoneId
33
+
-**WHEN** a user deletes a `tencentcloud_teo_l7_acc_rule_v2` resource with composite ID `zone-abc#rule-xyz`
34
+
-**THEN** the `DeleteL7AccRules` API SHALL be called with `request.ZoneId = "zone-abc"`
35
+
36
+
#### Scenario: Delete maps rule_id to request.RuleIds
37
+
-**WHEN** a user deletes a resource with composite ID `zone-abc#rule-xyz`
38
+
-**THEN** the `DeleteL7AccRules` API SHALL be called with `request.RuleIds = ["rule-xyz"]`
The `tencentcloud_teo_l7_acc_rule_v2` resource's Read function SHALL use `Filters` with `Name: "rule-id"` and `Values: [ruleId]` derived from the `rule_id` parameter when calling the `DescribeL7AccRules` API.
42
+
43
+
#### Scenario: Read uses Filters with rule-id
44
+
-**WHEN** a user reads a `tencentcloud_teo_l7_acc_rule_v2` resource with composite ID `zone-abc#rule-xyz`
45
+
-**THEN** the `DescribeL7AccRules` API SHALL be called with `request.ZoneId = "zone-abc"` and `request.Filters` containing `{Name: "rule-id", Values: ["rule-xyz"]}`
-[x] 1.1 Verify and update the `zone_id` parameter mapping in `resource_tc_teo_l7_acc_rule_v2.go` Create function to ensure `request.ZoneId` is correctly set from schema `zone_id`
4
+
-[x] 1.2 Verify and update the `Rules` parameter mapping in Create function to ensure rule fields (`status`, `rule_name`, `description`, `branches`) are correctly mapped to `RuleEngineItem` within `request.Rules`
5
+
-[x] 1.3 Verify and update the Modify function to ensure `request.ZoneId` is set from `zone_id`, `request.Rule.RuleId` from `rule_id`, and other fields (`status`, `rule_name`, `description`, `branches`) are mapped to `request.Rule`
6
+
-[x] 1.4 Verify and update the Delete function to ensure `request.ZoneId` is set from `zone_id` and `request.RuleIds` from `rule_id`
7
+
-[x] 1.5 Verify and update the Read function (service layer `DescribeTeoL7AccRuleById`) to ensure `request.Filters` uses `Name: "rule-id"` and `Values: [ruleId]` for querying by `rule_id`
8
+
9
+
## 2. Testing
10
+
11
+
-[x] 2.1 Add unit tests in `resource_tc_teo_l7_acc_rule_v2_test.go` using gomonkey mock to verify Create function parameter mapping (zone_id → request.ZoneId, rule fields → request.Rules)
12
+
-[x] 2.2 Add unit tests to verify Modify function parameter mapping (zone_id → request.ZoneId, rule_id → request.Rule.RuleId, other fields → request.Rule)
13
+
-[x] 2.3 Add unit tests to verify Delete function parameter mapping (zone_id → request.ZoneId, rule_id → request.RuleIds)
14
+
-[x] 2.4 Add unit tests to verify Read function uses correct Filters (Name: "rule-id", Values: [ruleId])
15
+
-[x] 2.5 Run unit tests with `go test -gcflags="all=-l"` to verify all tests pass
16
+
17
+
## 3. Documentation
18
+
19
+
-[x] 3.1 Update `resource_tc_teo_l7_acc_rule_v2.md` to reflect the CRUD parameter mappings and ensure documentation is consistent with the implementation
The `tencentcloud_teo_l7_acc_rule_v2` resource's Create function SHALL map the `zone_id` schema parameter to `request.ZoneId` and the rule fields (`status`, `rule_name`, `description`, `branches`) to a `RuleEngineItem` within `request.Rules` when calling the `CreateL7AccRules` API.
5
+
6
+
#### Scenario: Create maps zone_id to request.ZoneId
7
+
-**WHEN** a user creates a `tencentcloud_teo_l7_acc_rule_v2` resource with `zone_id = "zone-abc123"`
8
+
-**THEN** the `CreateL7AccRules` API SHALL be called with `request.ZoneId = "zone-abc123"`
9
+
10
+
#### Scenario: Create maps rule fields to request.Rules
11
+
-**WHEN** a user creates a resource with `status = "enable"`, `rule_name = "test"`, `description = ["desc"]`, `branches = [...]`
12
+
-**THEN** the `CreateL7AccRules` API SHALL be called with `request.Rules` containing a `RuleEngineItem` with the corresponding `Status`, `RuleName`, `Description`, and `Branches` fields
The `tencentcloud_teo_l7_acc_rule_v2` resource's Update function SHALL map the `zone_id` schema parameter to `request.ZoneId` and the rule fields to `request.Rule` (a `RuleEngineItem`) when calling the `ModifyL7AccRule` API.
16
+
17
+
#### Scenario: Update maps zone_id to request.ZoneId
18
+
-**WHEN** a user updates a `tencentcloud_teo_l7_acc_rule_v2` resource
19
+
-**THEN** the `ModifyL7AccRule` API SHALL be called with `request.ZoneId` set from the compositeID's zone_id part
20
+
21
+
#### Scenario: Update maps rule_id to request.Rule.RuleId
22
+
-**WHEN** a user updates a resource with composite ID `zone-abc#rule-xyz`
23
+
-**THEN** the `ModifyL7AccRule` API SHALL be called with `request.Rule.RuleId = "rule-xyz"`
24
+
25
+
#### Scenario: Update maps mutable fields to request.Rule
26
+
-**WHEN** a user changes `status`, `rule_name`, `description`, or `branches`
27
+
-**THEN** the `ModifyL7AccRule` API SHALL be called with `request.Rule` containing the updated `Status`, `RuleName`, `Description`, and/or `Branches` fields
The `tencentcloud_teo_l7_acc_rule_v2` resource's Delete function SHALL map the `zone_id` to `request.ZoneId` and `rule_id` to `request.RuleIds` when calling the `DeleteL7AccRules` API.
31
+
32
+
#### Scenario: Delete maps zone_id to request.ZoneId
33
+
-**WHEN** a user deletes a `tencentcloud_teo_l7_acc_rule_v2` resource with composite ID `zone-abc#rule-xyz`
34
+
-**THEN** the `DeleteL7AccRules` API SHALL be called with `request.ZoneId = "zone-abc"`
35
+
36
+
#### Scenario: Delete maps rule_id to request.RuleIds
37
+
-**WHEN** a user deletes a resource with composite ID `zone-abc#rule-xyz`
38
+
-**THEN** the `DeleteL7AccRules` API SHALL be called with `request.RuleIds = ["rule-xyz"]`
The `tencentcloud_teo_l7_acc_rule_v2` resource's Read function SHALL use `Filters` with `Name: "rule-id"` and `Values: [ruleId]` derived from the `rule_id` parameter when calling the `DescribeL7AccRules` API.
42
+
43
+
#### Scenario: Read uses Filters with rule-id
44
+
-**WHEN** a user reads a `tencentcloud_teo_l7_acc_rule_v2` resource with composite ID `zone-abc#rule-xyz`
45
+
-**THEN** the `DescribeL7AccRules` API SHALL be called with `request.ZoneId = "zone-abc"` and `request.Filters` containing `{Name: "rule-id", Values: ["rule-xyz"]}`
0 commit comments