Skip to content

Commit 1b1fabc

Browse files
gitmknanonymous
andauthored
fix: support IP query when modifying the type (#1520)
* fix: support IP query when modifying the type * fix: add changelog Co-authored-by: anonymous <anonymous@mail.org>
1 parent 7d6e76c commit 1b1fabc

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.changelog/1520.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_ckafka_instance: support IP query when modifying the type
3+
```

tencentcloud/resource_tc_tem_application_service.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,22 @@ func resourceTencentCloudTemApplicationServiceUpdate(d *schema.ResourceData, met
394394
return err
395395
}
396396

397+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
398+
service := TemService{client: meta.(*TencentCloudClient).apiV3Conn}
399+
err = resource.Retry(3*readRetryTimeout, func() *resource.RetryError {
400+
service, errRet := service.DescribeTemApplicationServiceById(ctx, environmentId, applicationId)
401+
if errRet != nil {
402+
return retryError(errRet, InternalError)
403+
}
404+
if *service.Result.AllIpDone {
405+
return nil
406+
}
407+
return resource.RetryableError(fmt.Errorf("service is not ready %v, retry...", *service.Result.AllIpDone))
408+
})
409+
if err != nil {
410+
return err
411+
}
412+
397413
return resourceTencentCloudTemApplicationServiceRead(d, meta)
398414
}
399415

tencentcloud/resource_tc_tem_application_service_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ func TestAccTencentCloudTemApplicationServiceResource_basic(t *testing.T) {
3030
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.#", "1"),
3131
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.type", "CLUSTER"),
3232
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.service_name", "terraform-test-0"),
33+
resource.TestCheckResourceAttrSet("tencentcloud_tem_application_service.application_service", "service.0.ip"),
34+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.#", "1"),
35+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.0.port", "80"),
36+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.0.target_port", "80"),
37+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.0.protocol", "TCP"),
38+
),
39+
},
40+
{
41+
Config: testAccTemApplicationServiceUp,
42+
Check: resource.ComposeTestCheckFunc(
43+
testAccCheckTemApplicationServiceExists("tencentcloud_tem_application_service.application_service"),
44+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "environment_id", defaultEnvironmentId),
45+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "application_id", defaultApplicationId),
46+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.#", "1"),
47+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.type", "EXTERNAL"),
48+
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.service_name", "terraform-test-0"),
49+
resource.TestCheckResourceAttrSet("tencentcloud_tem_application_service.application_service", "service.0.ip"),
3350
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.#", "1"),
3451
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.0.port", "80"),
3552
resource.TestCheckResourceAttr("tencentcloud_tem_application_service.application_service", "service.0.port_mapping_item_list.0.target_port", "80"),
@@ -143,3 +160,21 @@ resource "tencentcloud_tem_application_service" "application_service" {
143160
}
144161
145162
`
163+
164+
const testAccTemApplicationServiceUp = testAccTemApplicationServiceVar + `
165+
166+
resource "tencentcloud_tem_application_service" "application_service" {
167+
environment_id = var.environment_id
168+
application_id = var.application_id
169+
service {
170+
type = "EXTERNAL"
171+
service_name = "terraform-test-0"
172+
port_mapping_item_list {
173+
port = 80
174+
target_port = 80
175+
protocol = "TCP"
176+
}
177+
}
178+
}
179+
180+
`

0 commit comments

Comments
 (0)