Skip to content

Commit 39ccc20

Browse files
committed
feat: support teo runtime_environment
1 parent b21571a commit 39ccc20

11 files changed

+465
-19
lines changed

tencentcloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,7 @@ func Provider() *schema.Provider {
17051705
"tencentcloud_teo_function": teo.ResourceTencentCloudTeoFunction(),
17061706
"tencentcloud_teo_function_rule": teo.ResourceTencentCloudTeoFunctionRule(),
17071707
"tencentcloud_teo_function_rule_priority": teo.ResourceTencentCloudTeoFunctionRulePriority(),
1708+
"tencentcloud_teo_function_runtime_environment": teo.ResourceTencentCloudTeoFunctionRuntimeEnvironment(),
17081709
"tencentcloud_tcm_mesh": tcm.ResourceTencentCloudTcmMesh(),
17091710
"tencentcloud_tcm_cluster_attachment": tcm.ResourceTencentCloudTcmClusterAttachment(),
17101711
"tencentcloud_tcm_prometheus_attachment": tcm.ResourceTencentCloudTcmPrometheusAttachment(),

tencentcloud/provider.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,10 @@ TencentCloud EdgeOne(TEO)
14331433
tencentcloud_teo_acceleration_domain
14341434
tencentcloud_teo_l4_proxy
14351435
tencentcloud_teo_realtime_log_delivery
1436+
tencentcloud_teo_function
1437+
tencentcloud_teo_function_rule
1438+
tencentcloud_teo_function_rule_priority
1439+
tencentcloud_teo_function_runtime_environment
14361440

14371441
TencentCloud ServiceMesh(TCM)
14381442
Data Source

tencentcloud/services/teo/resource_tc_teo_function_runtime_environment.go

Lines changed: 60 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/teo/resource_tc_teo_function_runtime_environment.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ Example Usage
44

55
```hcl
66
resource "tencentcloud_teo_function_runtime_environment" "teo_function_runtime_environment" {
7-
environment_variables = {
8-
}
7+
function_id = "ef-txx7fnua"
8+
zone_id = "zone-2qtuhspy7cr6"
9+
10+
environment_variables {
11+
key = "test-a"
12+
type = "string"
13+
value = "AAA"
14+
}
15+
environment_variables {
16+
key = "test-b"
17+
type = "string"
18+
value = "BBB"
19+
}
920
}
1021
```
1122

@@ -14,5 +25,5 @@ Import
1425
teo teo_function_runtime_environment can be imported using the id, e.g.
1526

1627
```
17-
terraform import tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment teo_function_runtime_environment_id
28+
terraform import tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment zone_id#function_id
1829
```

tencentcloud/services/teo/resource_tc_teo_function_runtime_environment_extension.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ import (
88
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
99
)
1010

11-
func resourceTencentCloudTeoFunctionRuntimeEnvironmentUpdatePostFillRequest0(ctx context.Context, req *teov20220901.HandleFunctionRuntimeEnvironmentRequest) error {
11+
func resourceTencentCloudTeoFunctionRuntimeEnvironmentCreatePostFillRequest0(ctx context.Context, req *teov20220901.HandleFunctionRuntimeEnvironmentRequest) error {
1212
req.Operation = helper.String("setEnvironmentVariable")
1313
return nil
1414
}
1515

16+
func resourceTencentCloudTeoFunctionRuntimeEnvironmentUpdatePostFillRequest0(ctx context.Context, req *teov20220901.HandleFunctionRuntimeEnvironmentRequest) error {
17+
req.Operation = helper.String("resetEnvironmentVariable")
18+
return nil
19+
}
20+
1621
func resourceTencentCloudTeoFunctionRuntimeEnvironmentDeletePostFillRequest0(ctx context.Context, req *teov20220901.HandleFunctionRuntimeEnvironmentRequest) error {
1722
req.Operation = helper.String("deleteEnvironmentVariable")
1823
return nil
Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package teo
1+
package teo_test
22

33
import (
44
"testing"
@@ -15,21 +15,79 @@ func TestAccTencentCloudTeoFunctionRuntimeEnvironmentResource_basic(t *testing.T
1515
tcacctest.AccPreCheck(t)
1616
},
1717
Providers: tcacctest.AccProviders,
18-
Steps: []resource.TestStep{{
19-
Config: testAccTeoFunctionRuntimeEnvironment,
20-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "id")),
21-
}, {
22-
ResourceName: "tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment",
23-
ImportState: true,
24-
ImportStateVerify: true,
25-
}},
18+
Steps: []resource.TestStep{
19+
{
20+
Config: testAccTeoFunctionRuntimeEnvironment,
21+
Check: resource.ComposeTestCheckFunc(
22+
resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "id"),
23+
resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "function_id"),
24+
resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "zone_id"),
25+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.#", "2"),
26+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.0.key", "test-a"),
27+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.0.type", "string"),
28+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.0.value", "AAA"),
29+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.1.key", "test-b"),
30+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.1.type", "string"),
31+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.1.value", "BBB"),
32+
),
33+
},
34+
{
35+
ResourceName: "tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment",
36+
ImportState: true,
37+
ImportStateVerify: true,
38+
},
39+
{
40+
Config: testAccTeoFunctionRuntimeEnvironmentUp,
41+
Check: resource.ComposeTestCheckFunc(
42+
resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "id"),
43+
resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "function_id"),
44+
resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "zone_id"),
45+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.#", "2"),
46+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.0.key", "test-b"),
47+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.0.type", "string"),
48+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.0.value", "BBB"),
49+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.1.key", "test-a"),
50+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.1.type", "string"),
51+
resource.TestCheckResourceAttr("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "environment_variables.1.value", "AAA"),
52+
),
53+
},
54+
},
2655
})
2756
}
2857

2958
const testAccTeoFunctionRuntimeEnvironment = `
3059
3160
resource "tencentcloud_teo_function_runtime_environment" "teo_function_runtime_environment" {
32-
environment_variables = {
33-
}
61+
function_id = "ef-txx7fnua"
62+
zone_id = "zone-2qtuhspy7cr6"
63+
64+
environment_variables {
65+
key = "test-a"
66+
type = "string"
67+
value = "AAA"
68+
}
69+
environment_variables {
70+
key = "test-b"
71+
type = "string"
72+
value = "BBB"
73+
}
74+
}
75+
`
76+
const testAccTeoFunctionRuntimeEnvironmentUp = `
77+
78+
resource "tencentcloud_teo_function_runtime_environment" "teo_function_runtime_environment" {
79+
function_id = "ef-txx7fnua"
80+
zone_id = "zone-2qtuhspy7cr6"
81+
82+
environment_variables {
83+
key = "test-b"
84+
type = "string"
85+
value = "BBB"
86+
}
87+
environment_variables {
88+
key = "test-a"
89+
type = "string"
90+
value = "AAA"
91+
}
3492
}
3593
`
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
subcategory: "TencentCloud EdgeOne(TEO)"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_teo_function"
5+
sidebar_current: "docs-tencentcloud-resource-teo_function"
6+
description: |-
7+
Provides a resource to create a teo teo_function
8+
---
9+
10+
# tencentcloud_teo_function
11+
12+
Provides a resource to create a teo teo_function
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "tencentcloud_teo_function" "teo_function" {
18+
content = <<-EOT
19+
addEventListener('fetch', e => {
20+
const response = new Response('Hello World!!');
21+
e.respondWith(response);
22+
});
23+
EOT
24+
name = "aaa-zone-2qtuhspy7cr6-1310708577"
25+
remark = "test"
26+
zone_id = "zone-2qtuhspy7cr6"
27+
}
28+
```
29+
30+
## Argument Reference
31+
32+
The following arguments are supported:
33+
34+
* `content` - (Required, String) Function content, currently only supports JavaScript code, with a maximum size of 5MB.
35+
* `name` - (Required, String) Function name. It can only contain lowercase letters, numbers, hyphens, must start and end with a letter or number, and can have a maximum length of 30 characters.
36+
* `zone_id` - (Required, String, ForceNew) ID of the site.
37+
* `remark` - (Optional, String) Function description, maximum support of 60 characters.
38+
39+
## Attributes Reference
40+
41+
In addition to all arguments above, the following attributes are exported:
42+
43+
* `id` - ID of the resource.
44+
* `create_time` - Creation time. The time is in Coordinated Universal Time (UTC) and follows the date and time format specified by the ISO 8601 standard.
45+
* `domain` - The default domain name for the function.
46+
* `function_id` - ID of the Function.
47+
* `update_time` - Modification time. The time is in Coordinated Universal Time (UTC) and follows the date and time format specified by the ISO 8601 standard.
48+
49+
50+
## Import
51+
52+
teo teo_function can be imported using the id, e.g.
53+
54+
```
55+
terraform import tencentcloud_teo_function.teo_function zone_id#function_id
56+
```
57+

0 commit comments

Comments
 (0)