|
| 1 | +## ADDED Requirements |
| 2 | + |
| 3 | +### Requirement: Create global accelerator instance |
| 4 | + |
| 5 | +The system SHALL provide a Terraform resource `tencentcloud_ga2_global_accelerator` that creates a GA2 global accelerator instance by calling the `CreateGlobalAccelerator` API with the following parameters: |
| 6 | +- `name` (Required, string): Instance name, max 60 bytes |
| 7 | +- `instance_charge_type` (Optional, string, ForceNew): Billing mode, valid values: `PREPAID`, `POSTPAID`. Default: `POSTPAID` |
| 8 | +- `description` (Optional, string): Description, max 100 bytes |
| 9 | +- `cross_border_type` (Optional, string): Cross-border type, valid values: `HighQuality`, `Unicom` |
| 10 | +- `cross_border_promise_flag` (Optional, bool): Cross-border service promise flag |
| 11 | +- `tags` (Optional, map of string, ForceNew): Tag information |
| 12 | + |
| 13 | +After successful creation, the system SHALL set the resource ID to the returned `GlobalAcceleratorId` and wait for the async task to complete by polling `DescribeTaskResult` until status is SUCCESS. |
| 14 | + |
| 15 | +#### Scenario: Successful creation with required parameters only |
| 16 | + |
| 17 | +- **WHEN** user provides a valid `name` in the Terraform configuration |
| 18 | +- **THEN** the system calls `CreateGlobalAccelerator` API, sets the resource ID to the returned `GlobalAcceleratorId`, waits for the task to complete, and reads back the resource state |
| 19 | + |
| 20 | +#### Scenario: Successful creation with all parameters |
| 21 | + |
| 22 | +- **WHEN** user provides `name`, `instance_charge_type`, `description`, `cross_border_type`, `cross_border_promise_flag`, and `tags` |
| 23 | +- **THEN** the system calls `CreateGlobalAccelerator` API with all provided parameters, sets the resource ID, waits for the task to complete, and reads back the resource state |
| 24 | + |
| 25 | +#### Scenario: Creation fails with nil response |
| 26 | + |
| 27 | +- **WHEN** the `CreateGlobalAccelerator` API returns a nil response or nil `GlobalAcceleratorId` |
| 28 | +- **THEN** the system returns a NonRetryableError |
| 29 | + |
| 30 | +### Requirement: Read global accelerator instance |
| 31 | + |
| 32 | +The system SHALL read the global accelerator instance state by calling `DescribeGlobalAccelerators` API with a `global-accelerator-id` filter. The system SHALL set the following computed attributes from the response: |
| 33 | +- `name` (string) |
| 34 | +- `description` (string) |
| 35 | +- `instance_charge_type` (string) |
| 36 | +- `cross_border_type` (string) |
| 37 | +- `create_time` (Computed, string) |
| 38 | +- `state` (Computed, string) |
| 39 | +- `status` (Computed, string) |
| 40 | +- `ddos_id` (Computed, string) |
| 41 | +- `cname` (Computed, string) |
| 42 | + |
| 43 | +#### Scenario: Successful read |
| 44 | + |
| 45 | +- **WHEN** the resource exists and `DescribeGlobalAccelerators` returns a matching instance |
| 46 | +- **THEN** the system sets all computed and configured attributes from the `GlobalAcceleratorSet` response |
| 47 | + |
| 48 | +#### Scenario: Resource not found |
| 49 | + |
| 50 | +- **WHEN** `DescribeGlobalAccelerators` returns an empty `GlobalAcceleratorSet` for the given ID |
| 51 | +- **THEN** the system removes the resource from state (calls `d.SetId("")`) |
| 52 | + |
| 53 | +### Requirement: Update global accelerator instance |
| 54 | + |
| 55 | +The system SHALL update the global accelerator instance by calling `ModifyGlobalAccelerator` API when any of the following fields change: `name`, `description`, `cross_border_type`, `cross_border_promise_flag`. After the API call, the system SHALL wait for the async task to complete. |
| 56 | + |
| 57 | +The fields `instance_charge_type` and `tags` are ForceNew and SHALL NOT be included in the update request. |
| 58 | + |
| 59 | +#### Scenario: Update name and description |
| 60 | + |
| 61 | +- **WHEN** user changes `name` or `description` in the Terraform configuration |
| 62 | +- **THEN** the system calls `ModifyGlobalAccelerator` with the new values and the `GlobalAcceleratorId`, waits for the task to complete, and reads back the resource state |
| 63 | + |
| 64 | +#### Scenario: Update cross-border settings |
| 65 | + |
| 66 | +- **WHEN** user changes `cross_border_type` or `cross_border_promise_flag` |
| 67 | +- **THEN** the system calls `ModifyGlobalAccelerator` with the updated values, waits for the task to complete, and reads back the resource state |
| 68 | + |
| 69 | +### Requirement: Delete global accelerator instance |
| 70 | + |
| 71 | +The system SHALL delete the global accelerator instance by calling `DeleteGlobalAccelerator` API with the `GlobalAcceleratorId`. After the API call, the system SHALL wait for the async task to complete. |
| 72 | + |
| 73 | +#### Scenario: Successful deletion |
| 74 | + |
| 75 | +- **WHEN** user destroys the Terraform resource |
| 76 | +- **THEN** the system calls `DeleteGlobalAccelerator` with the resource ID, waits for the task to complete |
| 77 | + |
| 78 | +#### Scenario: Resource already deleted |
| 79 | + |
| 80 | +- **WHEN** `DeleteGlobalAccelerator` returns a resource not found error |
| 81 | +- **THEN** the system treats the deletion as successful (no error) |
| 82 | + |
| 83 | +### Requirement: Import global accelerator instance |
| 84 | + |
| 85 | +The system SHALL support importing an existing global accelerator instance using its `GlobalAcceleratorId`. |
| 86 | + |
| 87 | +#### Scenario: Successful import |
| 88 | + |
| 89 | +- **WHEN** user runs `terraform import tencentcloud_ga2_global_accelerator.example <global_accelerator_id>` |
| 90 | +- **THEN** the system reads the instance state using `DescribeGlobalAccelerators` and populates all attributes |
| 91 | + |
| 92 | +### Requirement: Register resource in provider |
| 93 | + |
| 94 | +The system SHALL register `tencentcloud_ga2_global_accelerator` in `tencentcloud/provider.go` resource map and add the corresponding entry in `tencentcloud/provider.md`. |
| 95 | + |
| 96 | +#### Scenario: Resource is available after registration |
| 97 | + |
| 98 | +- **WHEN** the provider is initialized |
| 99 | +- **THEN** `tencentcloud_ga2_global_accelerator` is available as a valid resource type |
0 commit comments