Skip to content

Commit 6caabb6

Browse files
committed
feat(teo): add new parameters for tencentcloud_teo_l7_acc_rule_v2 resource
1 parent 5c4d2af commit 6caabb6

15 files changed

Lines changed: 825 additions & 271 deletions

File tree

.changelog/4251.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_teo_l7_acc_rule_v2: add new parameters for L7 acceleration rule configuration
3+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ require (
9393
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdcpg v1.0.533
9494
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.3.113
9595
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578
96-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.3.113
96+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.3.121
9797
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.3.107
9898
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.1.0
9999
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857

go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.112/go.mod
10031003
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.113/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10041004
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.115/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10051005
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.118/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
1006+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.121/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10061007
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.122 h1:jBKY11xe4t9284+OQPIA5v1wVwbp0Vton1UiXp2ar9c=
10071008
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.122/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10081009
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/config v1.3.80 h1:chnsNBeJn3MieFLki4hpbzoml5NiTvLVzOTqYRVxQho=
@@ -1120,8 +1121,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.3.113 h1:2sulWz
11201121
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.3.113/go.mod h1:uCUT6rfNap46k8JHzdPIz3WvYjiQPDkOBZ+b2GrIpUE=
11211122
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578 h1:vBpQhUroO+FAslUmsDWGi8nvczsqZBWVgQwlnyT0Aj8=
11221123
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578/go.mod h1:UlojGQh/9wb7/uXPNi7PvMral1CNAskVDNgqJEV83l0=
1123-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.3.113 h1:xt2M4V6RH44/EnM3B/3U62StvetV56i0LKIIphpMp4c=
1124-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.3.113/go.mod h1:CVqu/hQhzYGDc312djRPNvEyhmUSZ4gywcBDWv1DGAM=
1124+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.3.121 h1:SdW1CsEOUSABdz3YHXSw7nESExvD4fR43ZfBFYaD2OQ=
1125+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.3.121/go.mod h1:r8LzDVp59qZs+Pe65TiXnGKZSu05QB7cYd6XpK6XZ0s=
11251126
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc v1.0.998 h1:f4/n0dVKQTD06xJ84B5asHViNJHrZmGojdAWEPIsITM=
11261127
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc v1.0.998/go.mod h1:fyi/HUwCwVe2NCCCjz8k/C5GwPu3QazCZO+OBJ3MhLk=
11271128
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.3.107 h1:Yky7eL8FnkO89MvxERN3tniBQjstZzjIX8I91A4la/k=
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-06-25
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Context
2+
3+
The `tencentcloud_teo_l7_acc_rule_v2` resource already exists at `tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2.go` with the following schema fields: `zone_id`, `status`, `rule_name`, `description`, `branches`, `rule_id` (Computed), `rule_priority` (Computed).
4+
5+
The resource uses the TEO v20220901 SDK APIs:
6+
- **Create**: `CreateL7AccRules` - takes `ZoneId` and `Rules` ([]*RuleEngineItem)
7+
- **Read**: `DescribeL7AccRules` - takes `ZoneId` and `Filters` (with rule-id filter)
8+
- **Update**: `ModifyL7AccRule` - takes `ZoneId` and `Rule` (*RuleEngineItem)
9+
- **Delete**: `DeleteL7AccRules` - takes `ZoneId` and `RuleIds`
10+
11+
The `RuleEngineItem` struct contains: `Status`, `RuleId`, `RuleName`, `Description`, `Branches`, `RulePriority`.
12+
13+
The resource uses a composite ID format: `{zone_id}#{rule_id}` with `tccommon.FILED_SP` as separator.
14+
15+
## Goals / Non-Goals
16+
17+
**Goals:**
18+
- Ensure the `tencentcloud_teo_l7_acc_rule_v2` resource has complete parameter coverage matching the cloud API
19+
- Maintain backward compatibility with existing Terraform configurations
20+
- Follow established patterns in the codebase (retry logic, error handling, composite IDs)
21+
22+
**Non-Goals:**
23+
- Changing the existing schema structure or field types
24+
- Adding support for batch rule operations (the resource manages a single rule)
25+
- Modifying the `tencentcloud_teo_l7_acc_rule` (v1) resource
26+
27+
## Decisions
28+
29+
1. **Schema Design**: Use flat schema with individual fields (`zone_id`, `status`, `rule_name`, `description`, `branches`) rather than a nested `rules` block. This matches the existing implementation pattern and is more user-friendly for a single-rule resource.
30+
- Alternative: Nested `rules` block wrapping all fields - rejected because it adds unnecessary nesting for a single-rule resource and would break backward compatibility.
31+
32+
2. **Composite ID**: Use `{zone_id}#FILED_SP#{rule_id}` format for resource ID, enabling import support.
33+
- This is the established pattern in the codebase for resources with multiple identifying fields.
34+
35+
3. **Create API Mapping**: Construct a single `RuleEngineItem` from individual schema fields and wrap in a slice for the `CreateL7AccRules` API's `Rules` parameter.
36+
- The API accepts a list but we only create one rule per resource instance.
37+
38+
4. **Read API Mapping**: Use `DescribeL7AccRules` with `Filters` containing `rule-id` filter to fetch the specific rule by ID.
39+
40+
5. **Error Handling**: Use `tccommon.RetryError()` for all API calls with appropriate retry timeouts (`WriteRetryTimeout` for CUD, `ReadRetryTimeout` for R).
41+
42+
## Risks / Trade-offs
43+
44+
- [Risk] API returns empty response during transient failures → Mitigation: Check for nil response and empty rules list before setting ID to empty; log the resource ID before clearing it.
45+
- [Risk] Create API returns empty RuleIds → Mitigation: Check response, RuleIds length, and nil pointer before using the returned ID; return NonRetryableError if empty.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Why
2+
3+
The `tencentcloud_teo_l7_acc_rule_v2` resource needs to be fully implemented as a RESOURCE_KIND_GENERAL resource for the TEO (TencentCloud EdgeOne) product. This resource manages L7 acceleration rules with full CRUD lifecycle operations (CreateL7AccRules, DescribeL7AccRules, ModifyL7AccRule, DeleteL7AccRules), enabling users to create, read, update, and delete L7 acceleration rules within a TEO zone.
4+
5+
## What Changes
6+
7+
- Add the `tencentcloud_teo_l7_acc_rule_v2` resource with full CRUD support:
8+
- `zone_id` (Required, ForceNew): Zone ID for the TEO site
9+
- `rules` (Required): Rule content list containing rule engine items with status, rule_name, description, and branches
10+
- `rule_id` (Computed): Rule ID returned after creation, used for update/delete/read operations
11+
- `status` (Optional): Rule status (enable/disable)
12+
- `rule_name` (Optional): Rule name with 255 character limit
13+
- `description` (Optional): Rule annotations, supports multiple entries
14+
- `branches` (Optional): Sub-rule branches for rule conditions and actions
15+
- `rule_priority` (Computed): Rule priority, output only
16+
- Register the resource in `provider.go` and `provider.md`
17+
- Add service layer function `DescribeTeoL7AccRuleById` for reading rule details
18+
- Add documentation and unit tests
19+
20+
## Capabilities
21+
22+
### New Capabilities
23+
- `teo-l7-acc-rule-v2-resource`: Full CRUD lifecycle management for TEO L7 acceleration rules via CreateL7AccRules, ModifyL7AccRule, DeleteL7AccRules, and DescribeL7AccRules APIs
24+
25+
### Modified Capabilities
26+
27+
## Impact
28+
29+
- **Code**: `tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2.go`, `tencentcloud/services/teo/service_tencentcloud_teo.go`, `tencentcloud/provider.go`, `tencentcloud/provider.md`
30+
- **APIs**: Uses `teo/v20220901` package APIs: `CreateL7AccRules`, `ModifyL7AccRule`, `DeleteL7AccRules`, `DescribeL7AccRules`
31+
- **Dependencies**: `github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901` (already in vendor)
32+
- **Documentation**: `tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2.md`, `website/docs/r/teo_l7_acc_rule_v2.html.markdown`
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## ADDED Requirements
2+
3+
### Requirement: Resource manages TEO L7 acceleration rule lifecycle
4+
5+
The `tencentcloud_teo_l7_acc_rule_v2` resource SHALL manage the full CRUD lifecycle of a TEO L7 acceleration rule using the following APIs:
6+
- Create: `CreateL7AccRules` with `ZoneId` and `Rules` parameters
7+
- Read: `DescribeL7AccRules` with `ZoneId` and `Filters` (rule-id filter using `Values`)
8+
- Update: `ModifyL7AccRule` with `ZoneId` and `Rule` (containing `RuleId`, `Status`, `RuleName`, `Description`, `Branches`)
9+
- Delete: `DeleteL7AccRules` with `ZoneId` and `RuleIds`
10+
11+
The resource SHALL use a composite ID format `{zone_id}#{rule_id}` with `tccommon.FILED_SP` as separator.
12+
13+
#### Scenario: Create a new L7 acceleration rule
14+
- **WHEN** user applies a Terraform configuration with `tencentcloud_teo_l7_acc_rule_v2` resource specifying `zone_id`, `status`, `rule_name`, `description`, and `branches`
15+
- **THEN** the resource SHALL call `CreateL7AccRules` API with the zone ID and a single `RuleEngineItem` containing the specified fields, and store the returned `rule_id` in state with composite ID format
16+
17+
#### Scenario: Read an existing L7 acceleration rule
18+
- **WHEN** Terraform performs a refresh on the resource
19+
- **THEN** the resource SHALL call `DescribeL7AccRules` API with `zone_id` and a filter for `rule-id` with the stored `rule_id` as the filter value, and update state with the returned `status`, `rule_name`, `description`, `branches`, and `rule_priority`
20+
21+
#### Scenario: Update an existing L7 acceleration rule
22+
- **WHEN** user modifies `status`, `rule_name`, `description`, or `branches` in the Terraform configuration
23+
- **THEN** the resource SHALL call `ModifyL7AccRule` API with `zone_id` and a `RuleEngineItem` containing the `rule_id` and updated fields
24+
25+
#### Scenario: Delete an L7 acceleration rule
26+
- **WHEN** user destroys the resource
27+
- **THEN** the resource SHALL call `DeleteL7AccRules` API with `zone_id` and `rule_id`
28+
29+
#### Scenario: Import an existing rule
30+
- **WHEN** user imports a resource using `terraform import` with ID format `{zone_id}#{rule_id}`
31+
- **THEN** the resource SHALL parse the composite ID and read the rule details from the API
32+
33+
### Requirement: Resource schema defines correct field types and constraints
34+
35+
The resource schema SHALL define the following fields:
36+
- `zone_id`: TypeString, Required, ForceNew - Zone ID for the TEO site
37+
- `status`: TypeString, Optional - Rule status (enable/disable)
38+
- `rule_name`: TypeString, Optional - Rule name (max 255 characters)
39+
- `description`: TypeList of TypeString, Optional - Rule annotations
40+
- `branches`: TypeList of Resource, Optional - Sub-rule branches with conditions and actions
41+
- `rule_id`: TypeString, Computed - Rule ID returned by the API
42+
- `rule_priority`: TypeInt, Computed - Rule priority (output only)
43+
44+
#### Scenario: Zone ID is immutable after creation
45+
- **WHEN** user attempts to change `zone_id` after resource creation
46+
- **THEN** Terraform SHALL plan to destroy and recreate the resource (ForceNew behavior)
47+
48+
#### Scenario: Optional fields can be omitted
49+
- **WHEN** user creates a resource without specifying `status`, `rule_name`, `description`, or `branches`
50+
- **THEN** the resource SHALL be created successfully with API defaults for those fields
51+
52+
### Requirement: Error handling follows provider patterns
53+
54+
The resource SHALL implement proper error handling:
55+
- All API calls MUST be wrapped with retry logic using `tccommon.RetryError()`
56+
- Create MUST verify the response is not nil and `RuleIds` is not empty before storing the ID
57+
- Read MUST check for nil response and empty rules list, logging the resource ID before clearing state
58+
59+
#### Scenario: Create API returns empty response
60+
- **WHEN** the `CreateL7AccRules` API returns a nil response or empty `RuleIds`
61+
- **THEN** the resource SHALL return a `NonRetryableError` with a descriptive message
62+
63+
#### Scenario: Read API returns no matching rule
64+
- **WHEN** the `DescribeL7AccRules` API returns an empty rules list
65+
- **THEN** the resource SHALL log the resource ID for debugging and set the ID to empty string to remove from state
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## 1. Resource Implementation
2+
3+
- [x] 1.1 Update resource schema in `tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2.go` to ensure all parameters are correctly defined with proper types, constraints (Required/Optional/Computed/ForceNew), and descriptions
4+
- [x] 1.2 Update Create function to properly validate API response (check nil response, empty RuleIds) and return NonRetryableError on empty ID
5+
- [x] 1.3 Update Read function to log resource ID before clearing state when API returns empty response
6+
- [x] 1.4 Verify Update function correctly handles HasChange detection and passes all modified fields to ModifyL7AccRule API
7+
- [x] 1.5 Verify Delete function correctly passes zone_id and rule_id to DeleteL7AccRules API
8+
9+
## 2. Provider Registration
10+
11+
- [x] 2.1 Verify resource is registered in `tencentcloud/provider.go`
12+
- [x] 2.2 Verify resource is listed in `tencentcloud/provider.md`
13+
14+
## 3. Testing
15+
16+
- [x] 3.1 Add unit tests in `tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2_test.go` using gomonkey to mock cloud API calls, covering Create/Read/Update/Delete operations
17+
18+
## 4. Documentation
19+
20+
- [x] 4.1 Update `tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2.md` with example usage showing all parameters including zone_id, status, rule_name, description, and branches
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## ADDED Requirements
2+
3+
### Requirement: Resource manages TEO L7 acceleration rule lifecycle
4+
5+
The `tencentcloud_teo_l7_acc_rule_v2` resource SHALL manage the full CRUD lifecycle of a TEO L7 acceleration rule using the following APIs:
6+
- Create: `CreateL7AccRules` with `ZoneId` and `Rules` parameters
7+
- Read: `DescribeL7AccRules` with `ZoneId` and `Filters` (rule-id filter using `Values`)
8+
- Update: `ModifyL7AccRule` with `ZoneId` and `Rule` (containing `RuleId`, `Status`, `RuleName`, `Description`, `Branches`)
9+
- Delete: `DeleteL7AccRules` with `ZoneId` and `RuleIds`
10+
11+
The resource SHALL use a composite ID format `{zone_id}#{rule_id}` with `tccommon.FILED_SP` as separator.
12+
13+
#### Scenario: Create a new L7 acceleration rule
14+
- **WHEN** user applies a Terraform configuration with `tencentcloud_teo_l7_acc_rule_v2` resource specifying `zone_id`, `status`, `rule_name`, `description`, and `branches`
15+
- **THEN** the resource SHALL call `CreateL7AccRules` API with the zone ID and a single `RuleEngineItem` containing the specified fields, and store the returned `rule_id` in state with composite ID format
16+
17+
#### Scenario: Read an existing L7 acceleration rule
18+
- **WHEN** Terraform performs a refresh on the resource
19+
- **THEN** the resource SHALL call `DescribeL7AccRules` API with `zone_id` and a filter for `rule-id` with the stored `rule_id` as the filter value, and update state with the returned `status`, `rule_name`, `description`, `branches`, and `rule_priority`
20+
21+
#### Scenario: Update an existing L7 acceleration rule
22+
- **WHEN** user modifies `status`, `rule_name`, `description`, or `branches` in the Terraform configuration
23+
- **THEN** the resource SHALL call `ModifyL7AccRule` API with `zone_id` and a `RuleEngineItem` containing the `rule_id` and updated fields
24+
25+
#### Scenario: Delete an L7 acceleration rule
26+
- **WHEN** user destroys the resource
27+
- **THEN** the resource SHALL call `DeleteL7AccRules` API with `zone_id` and `rule_id`
28+
29+
#### Scenario: Import an existing rule
30+
- **WHEN** user imports a resource using `terraform import` with ID format `{zone_id}#{rule_id}`
31+
- **THEN** the resource SHALL parse the composite ID and read the rule details from the API
32+
33+
### Requirement: Resource schema defines correct field types and constraints
34+
35+
The resource schema SHALL define the following fields:
36+
- `zone_id`: TypeString, Required, ForceNew - Zone ID for the TEO site
37+
- `status`: TypeString, Optional - Rule status (enable/disable)
38+
- `rule_name`: TypeString, Optional - Rule name (max 255 characters)
39+
- `description`: TypeList of TypeString, Optional - Rule annotations
40+
- `branches`: TypeList of Resource, Optional - Sub-rule branches with conditions and actions
41+
- `rule_id`: TypeString, Computed - Rule ID returned by the API
42+
- `rule_priority`: TypeInt, Computed - Rule priority (output only)
43+
44+
#### Scenario: Zone ID is immutable after creation
45+
- **WHEN** user attempts to change `zone_id` after resource creation
46+
- **THEN** Terraform SHALL plan to destroy and recreate the resource (ForceNew behavior)
47+
48+
#### Scenario: Optional fields can be omitted
49+
- **WHEN** user creates a resource without specifying `status`, `rule_name`, `description`, or `branches`
50+
- **THEN** the resource SHALL be created successfully with API defaults for those fields
51+
52+
### Requirement: Error handling follows provider patterns
53+
54+
The resource SHALL implement proper error handling:
55+
- All API calls MUST be wrapped with retry logic using `tccommon.RetryError()`
56+
- Create MUST verify the response is not nil and `RuleIds` is not empty before storing the ID
57+
- Read MUST check for nil response and empty rules list, logging the resource ID before clearing state
58+
59+
#### Scenario: Create API returns empty response
60+
- **WHEN** the `CreateL7AccRules` API returns a nil response or empty `RuleIds`
61+
- **THEN** the resource SHALL return a `NonRetryableError` with a descriptive message
62+
63+
#### Scenario: Read API returns no matching rule
64+
- **WHEN** the `DescribeL7AccRules` API returns an empty rules list
65+
- **THEN** the resource SHALL log the resource ID for debugging and set the ID to empty string to remove from state

tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_v2.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,19 @@ func ResourceTencentCloudTeoL7AccRuleV2Create(d *schema.ResourceData, meta inter
106106
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTeoV20220901Client().CreateL7AccRules(request)
107107
if e != nil {
108108
return tccommon.RetryError(e)
109-
} else {
110-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
111109
}
112-
if result.Response != nil && len(result.Response.RuleIds) > 0 && result.Response.RuleIds[0] != nil {
113-
ruleId = *result.Response.RuleIds[0]
110+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
111+
if result.Response == nil || len(result.Response.RuleIds) == 0 || result.Response.RuleIds[0] == nil || *result.Response.RuleIds[0] == "" {
112+
return resource.NonRetryableError(fmt.Errorf("api[%s] returned empty rule id, response: %s", request.GetAction(), result.ToJsonString()))
114113
}
114+
ruleId = *result.Response.RuleIds[0]
115115
return nil
116116
})
117117
if err != nil {
118118
return err
119119
}
120120

121+
log.Printf("[DEBUG]%s teo_l7_acc_rule_v2 created, logId: %s, id: %s\n", logId, logId, zoneId+tccommon.FILED_SP+ruleId)
121122
d.SetId(zoneId + tccommon.FILED_SP + ruleId)
122123

123124
return ResourceTencentCloudTeoL7AccRuleV2Read(d, meta)
@@ -149,16 +150,25 @@ func ResourceTencentCloudTeoL7AccRuleV2Read(d *schema.ResourceData, meta interfa
149150
}
150151

151152
if respData == nil || len(respData.Rules) == 0 {
153+
log.Printf("[WARN]%s resource `teo_l7_acc_rule_v2` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
152154
d.SetId("")
153-
log.Printf("[WARN]%s resource `teo_l7_acc_rule` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
154155
return nil
155156
}
156-
if len(respData.Rules) > 0 {
157-
rule := respData.Rules[0]
157+
158+
rule := respData.Rules[0]
159+
if rule.Status != nil {
158160
_ = d.Set("status", rule.Status)
161+
}
162+
if rule.RuleName != nil {
159163
_ = d.Set("rule_name", rule.RuleName)
164+
}
165+
if rule.Description != nil {
160166
_ = d.Set("description", rule.Description)
167+
}
168+
if rule.RulePriority != nil {
161169
_ = d.Set("rule_priority", rule.RulePriority)
170+
}
171+
if rule.Branches != nil {
162172
_ = d.Set("branches", resourceTencentCloudTeoL7AccRuleSetBranchs(rule.Branches))
163173
}
164174

0 commit comments

Comments
 (0)