Skip to content

Commit 6c21551

Browse files
authored
Merge pull request #2091 from tencentcloudstack/fix/scf_parm
Fix/scf parm
2 parents 3afb812 + ce4bcdb commit 6c21551

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.changelog/2091.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_scf_function: support `handler` and `runtime` optional
3+
```

tencentcloud/resource_tc_scf_function.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func resourceTencentCloudScfFunction() *schema.Resource {
119119
},
120120
"handler": {
121121
Type: schema.TypeString,
122-
Required: true,
122+
Optional: true,
123123
ValidateFunc: helper.ComposeValidateFunc(
124124
validateStringLengthInRange(2, 60),
125125
scfFunctionValidate(true),
@@ -162,7 +162,7 @@ func resourceTencentCloudScfFunction() *schema.Resource {
162162
},
163163
"runtime": {
164164
Type: schema.TypeString,
165-
Required: true,
165+
Optional: true,
166166
Description: "Runtime of the SCF function, only supports `Python2.7`, `Python3.6`, `Nodejs6.10`, `Nodejs8.9`, `Nodejs10.15`, `PHP5`, `PHP7`, `Golang1`, and `Java8`.",
167167
},
168168
"vpc_id": {
@@ -528,14 +528,18 @@ func resourceTencentCloudScfFunctionCreate(d *schema.ResourceData, m interface{}
528528
var functionInfo scfFunctionInfo
529529

530530
functionInfo.name = d.Get("name").(string)
531-
functionInfo.handler = helper.String(d.Get("handler").(string))
532531
functionInfo.desc = helper.String(d.Get("description").(string))
533532
functionInfo.memSize = helper.Int(d.Get("mem_size").(int))
534533
functionInfo.timeout = helper.Int(d.Get("timeout").(int))
535534
functionInfo.environment = helper.GetTags(d, "environment")
536-
functionInfo.runtime = helper.String(d.Get("runtime").(string))
537535
functionInfo.namespace = helper.String(d.Get("namespace").(string))
538536

537+
if raw, ok := d.GetOk("handler"); ok {
538+
functionInfo.handler = helper.String(raw.(string))
539+
}
540+
if raw, ok := d.GetOk("runtime"); ok {
541+
functionInfo.runtime = helper.String(raw.(string))
542+
}
539543
if raw, ok := d.GetOk("vpc_id"); ok {
540544
functionInfo.vpcId = helper.String(raw.(string))
541545
}

website/docs/r/scf_function.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ resource "tencentcloud_scf_function" "foo" {
4848

4949
The following arguments are supported:
5050

51-
* `handler` - (Required, String) Handler of the SCF function. The format of name is `<filename>.<method_name>`, and it 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.
5251
* `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.
53-
* `runtime` - (Required, String) Runtime of the SCF function, only supports `Python2.7`, `Python3.6`, `Nodejs6.10`, `Nodejs8.9`, `Nodejs10.15`, `PHP5`, `PHP7`, `Golang1`, and `Java8`.
5452
* `cfs_config` - (Optional, List) List of CFS configurations.
5553
* `cls_logset_id` - (Optional, String) cls logset id of the SCF function.
5654
* `cls_topic_id` - (Optional, String) cls topic id of the SCF function.
@@ -62,12 +60,14 @@ The following arguments are supported:
6260
* `enable_public_net` - (Optional, Bool) Indicates whether public net config enabled. Default `false`. NOTE: only `vpc_id` specified can disable public net config.
6361
* `environment` - (Optional, Map) Environment of the SCF function.
6462
* `func_type` - (Optional, String) Function type. The default value is Event. Enter Event if you need to create a trigger function. Enter HTTP if you need to create an HTTP function service.
63+
* `handler` - (Optional, String) Handler of the SCF function. The format of name is `<filename>.<method_name>`, and it 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.
6564
* `image_config` - (Optional, List) Image of the SCF function, conflict with ``.
6665
* `l5_enable` - (Optional, Bool) Enable L5 for SCF function, default is `false`.
6766
* `layers` - (Optional, List) The list of association layers.
6867
* `mem_size` - (Optional, Int) Memory size of the SCF function, unit is MB. The default is `128`MB. The ladder is 128M.
6968
* `namespace` - (Optional, String, ForceNew) Namespace of the SCF function, default is `default`.
7069
* `role` - (Optional, String) Role of the SCF function.
70+
* `runtime` - (Optional, String) Runtime of the SCF function, only supports `Python2.7`, `Python3.6`, `Nodejs6.10`, `Nodejs8.9`, `Nodejs10.15`, `PHP5`, `PHP7`, `Golang1`, and `Java8`.
7171
* `subnet_id` - (Optional, String) Subnet ID of the SCF function.
7272
* `tags` - (Optional, Map) Tags of the SCF function.
7373
* `timeout` - (Optional, Int) Timeout of the SCF function, unit is second. Default `3`. Available value is 1-900.

0 commit comments

Comments
 (0)