Skip to content

Commit 935c4fe

Browse files
authored
scf support set func (#1851)
* scf support set func * add changelog
1 parent f626635 commit 935c4fe

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.changelog/1851.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 set `func_type`
3+
```

tencentcloud/resource_tc_scf_function.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ func resourceTencentCloudScfFunction() *schema.Resource {
199199
Computed: true,
200200
Description: "cls topic id of the SCF function.",
201201
},
202+
"func_type": {
203+
Type: schema.TypeString,
204+
Optional: true,
205+
Computed: true,
206+
Description: "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.",
207+
},
202208
"l5_enable": {
203209
Type: schema.TypeBool,
204210
Optional: true,
@@ -550,6 +556,9 @@ func resourceTencentCloudScfFunctionCreate(d *schema.ResourceData, m interface{}
550556
if raw, ok := d.GetOk("cls_topic_id"); ok {
551557
functionInfo.clsTopicId = helper.String(raw.(string))
552558
}
559+
if raw, ok := d.GetOk("func_type"); ok {
560+
functionInfo.funcType = helper.String(raw.(string))
561+
}
553562
if err := helper.CheckIfSetTogether(d, "cls_logset_id", "cls_topic_id"); err != nil {
554563
return err
555564
}
@@ -829,6 +838,7 @@ func resourceTencentCloudScfFunctionRead(d *schema.ResourceData, m interface{})
829838
_ = d.Set("role", resp.Role)
830839
_ = d.Set("cls_logset_id", resp.ClsLogsetId)
831840
_ = d.Set("cls_topic_id", resp.ClsTopicId)
841+
_ = d.Set("func_type", resp.Type)
832842
_ = d.Set("l5_enable", *resp.L5Enable == "TRUE")
833843

834844
tags := make(map[string]string, len(resp.Tags))
@@ -931,6 +941,10 @@ func resourceTencentCloudScfFunctionUpdate(d *schema.ResourceData, m interface{}
931941
}
932942
namespace, name := split[0], split[1]
933943

944+
if d.HasChange("func_type") {
945+
return fmt.Errorf("`func_type` do not support change now.")
946+
}
947+
934948
d.Partial(true)
935949

936950
functionInfo := scfFunctionInfo{

tencentcloud/service_tencentcloud_scf.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type scfFunctionInfo struct {
2727
role *string
2828
clsLogsetId *string
2929
clsTopicId *string
30+
funcType *string
3031
namespace *string
3132
layers []*scf.LayerVersionSimple
3233
l5Enable *bool
@@ -88,7 +89,7 @@ func (me *ScfService) CreateFunction(ctx context.Context, info scfFunctionInfo)
8889
request.ClsLogsetId = info.clsLogsetId
8990
request.ClsTopicId = info.clsTopicId
9091
request.Layers = info.layers
91-
request.Type = helper.String(SCF_FUNCTION_TYPE_EVENT)
92+
request.Type = info.funcType
9293

9394
request.Code = &scf.Code{
9495
CosBucketName: info.cosBucketName,

website/docs/r/scf_function.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The following arguments are supported:
6161
* `enable_eip_config` - (Optional, Bool) Indicates whether EIP config set to `ENABLE` when `enable_public_net` was true. Default `false`.
6262
* `enable_public_net` - (Optional, Bool) Indicates whether public net config enabled. Default `false`. NOTE: only `vpc_id` specified can disable public net config.
6363
* `environment` - (Optional, Map) Environment of the SCF function.
64+
* `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.
6465
* `image_config` - (Optional, List) Image of the SCF function, conflict with ``.
6566
* `l5_enable` - (Optional, Bool) Enable L5 for SCF function, default is `false`.
6667
* `layers` - (Optional, List) The list of association layers.

0 commit comments

Comments
 (0)