Skip to content

Commit 30e167b

Browse files
authored
scf function add async_run_enable (#2300)
* scf function add async_run_enable * add changelog 2300.txt * modify scf function field async_run_enable type * modify async_run_enable verification method
1 parent 289c0ff commit 30e167b

9 files changed

+41
-0
lines changed

.changelog/2300.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
datasource/tencentcloud_scf_function: add async_run_enable
3+
```
4+
5+
```release-note:enhancement
6+
resource/tencentcloud_scf_function: add async_run_enable
7+
```

tencentcloud/data_source_tc_scf_functions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ func dataSourceTencentCloudScfFunctions() *schema.Resource {
153153
Computed: true,
154154
Description: "Tags of the SCF function.",
155155
},
156+
"async_run_enable": {
157+
Type: schema.TypeString,
158+
Computed: true,
159+
Description: "Whether asynchronous attribute is enabled.",
160+
},
156161
"create_time": {
157162
Type: schema.TypeString,
158163
Computed: true,
@@ -395,6 +400,7 @@ func dataSourceTencentCloudScfFunctionsRead(d *schema.ResourceData, m interface{
395400
fnTags[*tag.Key] = *tag.Value
396401
}
397402
m["tags"] = fnTags
403+
m["async_run_enable"] = resp.AsyncRunEnable
398404

399405
functions = append(functions, m)
400406
}

tencentcloud/data_source_tc_scf_functions_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestAccDataSourceTencentCloudScfFunctions_basic(t *testing.T) {
3434
resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.eips.#"),
3535
resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.l5_enable"),
3636
resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.trigger_info.#"),
37+
resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.async_run_enable"),
3738
),
3839
},
3940
},

tencentcloud/extension_scf.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const (
3737

3838
SCF_FUNCTION_DESCRIBE_LIMIT = 20
3939
SCF_NAMESPACE_DESCRIBE_LIMIT = 20
40+
41+
SCF_FUNCTION_OPEN = "TRUE"
42+
SCF_FUNCTION_CLOSE = "FALSE"
4043
)
4144

4245
var (

tencentcloud/resource_tc_scf_function.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@ func resourceTencentCloudScfFunction() *schema.Resource {
235235
Optional: true,
236236
Description: "Tags of the SCF function.",
237237
},
238+
"async_run_enable": {
239+
Type: schema.TypeString,
240+
Optional: true,
241+
ForceNew: true,
242+
Computed: true,
243+
ValidateFunc: validateAllowedStringValue([]string{SCF_FUNCTION_OPEN, SCF_FUNCTION_CLOSE}),
244+
Description: "Whether SCF function asynchronous attribute is enabled. `TRUE` is open, `FALSE` is close.",
245+
},
238246
"enable_public_net": {
239247
Type: schema.TypeBool,
240248
Optional: true,
@@ -732,6 +740,11 @@ func resourceTencentCloudScfFunctionCreate(d *schema.ResourceData, m interface{}
732740
functionInfo.tags = tags
733741
}
734742

743+
if v, ok := d.GetOk("async_run_enable"); ok && v != nil {
744+
enableStr := v.(string)
745+
functionInfo.asyncRunEnable = helper.String(enableStr)
746+
}
747+
735748
if err := scfService.CreateFunction(ctx, functionInfo); err != nil {
736749
log.Printf("[CRITAL]%s create function failed: %+v", logId, err)
737750
return err
@@ -850,6 +863,7 @@ func resourceTencentCloudScfFunctionRead(d *schema.ResourceData, m interface{})
850863
tags[*tag.Key] = *tag.Value
851864
}
852865
_ = d.Set("tags", tags)
866+
_ = d.Set("async_run_enable", resp.AsyncRunEnable)
853867

854868
_ = d.Set("modify_time", resp.ModTime)
855869
_ = d.Set("code_size", resp.CodeSize)

tencentcloud/resource_tc_scf_function_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func TestAccTencentCloudScfFunction_basic(t *testing.T) {
103103
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "host", ""),
104104
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "vip", ""),
105105
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "tags.test", "test"),
106+
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "async_run_enable", "FALSE"),
106107
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "trigger_info.#", "0"),
107108
),
108109
},
@@ -124,6 +125,7 @@ func TestAccTencentCloudScfFunction_basic(t *testing.T) {
124125
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "vip", ""),
125126
resource.TestCheckNoResourceAttr("tencentcloud_scf_function.foo", "tags.test"),
126127
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "tags.abc", "abc"),
128+
resource.TestCheckResourceAttr("tencentcloud_scf_function.foo", "async_run_enable", "FALSE"),
127129
),
128130
},
129131
{
@@ -539,6 +541,7 @@ resource "tencentcloud_scf_function" "foo" {
539541
handler = "first.do_it_first"
540542
runtime = "Python3.6"
541543
enable_public_net = true
544+
async_run_enable = "FALSE"
542545
543546
zip_file = "%s"
544547
@@ -554,6 +557,7 @@ resource "tencentcloud_scf_function" "foo" {
554557
handler = "second.do_it_second"
555558
runtime = "Python3.6"
556559
enable_public_net = true
560+
async_run_enable = "FALSE"
557561
558562
description = "test"
559563
mem_size = 1536

tencentcloud/service_tencentcloud_scf.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type scfFunctionInfo struct {
4444
cfsConfig *scf.CfsConfig
4545

4646
tags map[string]string
47+
48+
asyncRunEnable *string
4749
}
4850

4951
type scfTrigger struct {
@@ -112,6 +114,8 @@ func (me *ScfService) CreateFunction(ctx context.Context, info scfFunctionInfo)
112114
}
113115
}
114116

117+
request.AsyncRunEnable = info.asyncRunEnable
118+
115119
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
116120
ratelimit.Check(request.GetAction())
117121

website/docs/d/scf_functions.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ The following arguments are supported:
4444
In addition to all arguments above, the following attributes are exported:
4545

4646
* `functions` - An information list of functions. Each element contains the following attributes:
47+
* `async_run_enable` - Whether asynchronous attribute is enabled.
4748
* `cls_logset_id` - CLS logset ID of the SCF function.
4849
* `cls_topic_id` - CLS topic ID of the SCF function.
4950
* `code_error` - Code error of the SCF function.

website/docs/r/scf_function.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ resource "tencentcloud_scf_function" "foo" {
4949
The following arguments are supported:
5050

5151
* `name` - (Required, String, ForceNew) Name of the SCF function. Name supports 26 English letters, numbers, connectors, and underscores, it should start with a letter. The last character cannot be `-` or `_`. Available length is 2-60.
52+
* `async_run_enable` - (Optional, String, ForceNew) Whether SCF function asynchronous attribute is enabled. `TRUE` is open, `FALSE` is close.
5253
* `cfs_config` - (Optional, List) List of CFS configurations.
5354
* `cls_logset_id` - (Optional, String) cls logset id of the SCF function.
5455
* `cls_topic_id` - (Optional, String) cls topic id of the SCF function.

0 commit comments

Comments
 (0)