Skip to content

Commit 0fb34ae

Browse files
committed
feat/apigw
2 parents 0738321 + eeb98cb commit 0fb34ae

25 files changed

+1512
-318
lines changed

.changelog/2071.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_trigger_config: support new para, update api UpdateTrigger
3+
```

.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+
```

.changelog/2094.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-data-source
2+
tencentcloud_eb_event_rules
3+
```

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ require (
6363
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.535
6464
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.0.672
6565
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.0.651
66-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.616
66+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.734
6767
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.0.584
6868
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.0.540
6969
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres v1.0.676
7070
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.290
7171
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.533
7272
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.657
7373
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/rum v1.0.542
74-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.664
74+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.729
7575
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses v1.0.529
7676
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.486
7777
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sqlserver v1.0.689

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.0.651 h1:Ohb
921921
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.0.651/go.mod h1:HLqsSgUnwgkE+XecQajekinjz1B7S+1U1J66puH4jpQ=
922922
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.616 h1:+4NM1Repe514qc4H9qFuDS0IEe0TBmC5snea//YL7Kk=
923923
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.616/go.mod h1:n7vl5IwlMQS/XzBzj3UEkp1dvQorzuAMq6RYNgl/MjM=
924+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.734 h1:VJli3mzhAiwmA949M0eIgp6KLJsPuCtpQ20UBdNI9mY=
925+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.734/go.mod h1:H2gtCj02D5k7h0JttS9RMoRgkJ8m9qia/9RlMjbvT0o=
924926
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.0.584 h1:FJxYOAolkBhXjQMWoiTek9Ag0bslcKFHyrM7w2Jsxos=
925927
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.0.584/go.mod h1:CY/hEcXbaOZBU9Qm/MMIctafi8FFJaMIGTlGUjnymW0=
926928
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.0.540 h1:gUVuwcjt9baj+/5LFafjdR53/xSdQxfA45Vp6E65rXU=
@@ -937,6 +939,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/rum v1.0.542 h1:/U0rTVK
937939
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/rum v1.0.542/go.mod h1:QF1J13hmuMY5gMrBopRFmHWFs/KsLr5uCNBRJt5aA1M=
938940
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.664 h1:57r4xDd0t9zQw8tLO9k13gYy/EYYGtFV3fMPx1BJinY=
939941
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.664/go.mod h1:dFFSCohvDzW2jidqjb5GFDhQD/2AfM1tZ8ijkuJUr9Y=
942+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.729 h1:UWTpLpN3UngFNTuMosxSMCcmuoLksvuc9tt7ulCe0D8=
943+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.729/go.mod h1:P5cLcaPdmOiRhv79OAvAKf+9JTg/64N7ZxwZHBW2mZA=
940944
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses v1.0.529 h1:NezuBQEG7ihXbwueREo4qavBAo6ZcHuWGZt1dR+VdKc=
941945
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses v1.0.529/go.mod h1:Xfmf4Rq4J2ukz6NoEwpADQS5ws3By3KDPemCQeeMF+M=
942946
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.486 h1:eHLaL+hl5X5f8Apuf2SGVclO3MRev/E3AfA/0aZQGUA=
Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
/*
2+
Use this data source to query detailed information of eb event_rules
3+
Example Usage
4+
```hcl
5+
resource "tencentcloud_eb_event_bus" "foo" {
6+
event_bus_name = "tf-event_bus_rule"
7+
description = "event bus desc"
8+
enable_store = false
9+
save_days = 1
10+
tags = {
11+
"createdBy" = "terraform"
12+
}
13+
}
14+
resource "tencentcloud_eb_event_rule" "event_rule" {
15+
event_bus_id = tencentcloud_eb_event_bus.foo.id
16+
rule_name = "tf-event_rule"
17+
description = "event rule desc"
18+
enable = true
19+
event_pattern = jsonencode(
20+
{
21+
source = "apigw.cloud.tencent"
22+
type = [
23+
"connector:apigw",
24+
]
25+
}
26+
)
27+
tags = {
28+
"createdBy" = "terraform"
29+
}
30+
}
31+
data "tencentcloud_eb_event_rules" "event_rules" {
32+
event_bus_id = tencentcloud_eb_event_bus.foo.id
33+
order_by = "AddTime"
34+
order = "DESC"
35+
depends_on = [tencentcloud_eb_event_rule.event_rule]
36+
}
37+
```
38+
*/
39+
package tencentcloud
40+
41+
import (
42+
"context"
43+
44+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
45+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
46+
eb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/eb/v20210416"
47+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
48+
)
49+
50+
func dataSourceTencentCloudEbEventRules() *schema.Resource {
51+
return &schema.Resource{
52+
Read: dataSourceTencentCloudEbEventRulesRead,
53+
Schema: map[string]*schema.Schema{
54+
"event_bus_id": {
55+
Required: true,
56+
Type: schema.TypeString,
57+
Description: "event bus Id.",
58+
},
59+
60+
"order_by": {
61+
Optional: true,
62+
Type: schema.TypeString,
63+
Description: "According to which field to sort the returned results, the following fields are supported: AddTime (creation time), ModTime (modification time).",
64+
},
65+
66+
"order": {
67+
Optional: true,
68+
Type: schema.TypeString,
69+
Description: "Return results in ascending or descending order, optional values ASC (ascending) and DESC (descending).",
70+
},
71+
72+
"rules": {
73+
Computed: true,
74+
Type: schema.TypeList,
75+
Description: "Event rule information.",
76+
Elem: &schema.Resource{
77+
Schema: map[string]*schema.Schema{
78+
"status": {
79+
Type: schema.TypeString,
80+
Computed: true,
81+
Description: "Status.",
82+
},
83+
"mod_time": {
84+
Type: schema.TypeString,
85+
Computed: true,
86+
Description: "modify time.",
87+
},
88+
"enable": {
89+
Type: schema.TypeBool,
90+
Computed: true,
91+
Description: "enable switch.",
92+
},
93+
"description": {
94+
Type: schema.TypeString,
95+
Computed: true,
96+
Description: "description.",
97+
},
98+
"rule_id": {
99+
Type: schema.TypeString,
100+
Computed: true,
101+
Description: "rule Id.",
102+
},
103+
"add_time": {
104+
Type: schema.TypeString,
105+
Computed: true,
106+
Description: "create time.",
107+
},
108+
"event_bus_id": {
109+
Type: schema.TypeString,
110+
Computed: true,
111+
Description: "event bus Id.",
112+
},
113+
"rule_name": {
114+
Type: schema.TypeString,
115+
Computed: true,
116+
Description: "rule name.",
117+
},
118+
"targets": {
119+
Type: schema.TypeList,
120+
Computed: true,
121+
Description: "Target brief information, note: this field may return null, indicating that no valid value can be obtained.",
122+
Elem: &schema.Resource{
123+
Schema: map[string]*schema.Schema{
124+
"target_id": {
125+
Type: schema.TypeString,
126+
Computed: true,
127+
Description: "target Id.",
128+
},
129+
"type": {
130+
Type: schema.TypeString,
131+
Computed: true,
132+
Description: "target type.",
133+
},
134+
},
135+
},
136+
},
137+
"dead_letter_config": {
138+
Type: schema.TypeList,
139+
Computed: true,
140+
Description: "The dlq rule set by rule. It may be null. Note: this field may return null, indicating that no valid value can be obtained.",
141+
Elem: &schema.Resource{
142+
Schema: map[string]*schema.Schema{
143+
"dispose_method": {
144+
Type: schema.TypeString,
145+
Computed: true,
146+
Description: "Support three modes of dlq, discarding, ignoring errors and continuing to pass, corresponding to: DLQ, DROP, IGNORE_ERROR.",
147+
},
148+
"ckafka_delivery_params": {
149+
Type: schema.TypeList,
150+
Computed: true,
151+
Description: "After setting the DLQ mode, this option is required. The error message will be delivered to the corresponding kafka topic Note: This field may return null, indicating that no valid value can be obtained.",
152+
Elem: &schema.Resource{
153+
Schema: map[string]*schema.Schema{
154+
"topic_name": {
155+
Type: schema.TypeString,
156+
Computed: true,
157+
Description: "ckafka topic name.",
158+
},
159+
"resource_description": {
160+
Type: schema.TypeString,
161+
Computed: true,
162+
Description: "ckafka resource qcs six-segment.",
163+
},
164+
},
165+
},
166+
},
167+
},
168+
},
169+
},
170+
},
171+
},
172+
},
173+
174+
"result_output_file": {
175+
Type: schema.TypeString,
176+
Optional: true,
177+
Description: "Used to save results.",
178+
},
179+
},
180+
}
181+
}
182+
183+
func dataSourceTencentCloudEbEventRulesRead(d *schema.ResourceData, meta interface{}) error {
184+
defer logElapsed("data_source.tencentcloud_eb_event_rules.read")()
185+
defer inconsistentCheck(d, meta)()
186+
187+
logId := getLogId(contextNil)
188+
189+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
190+
191+
paramMap := make(map[string]interface{})
192+
if v, ok := d.GetOk("event_bus_id"); ok {
193+
paramMap["EventBusId"] = helper.String(v.(string))
194+
}
195+
196+
if v, ok := d.GetOk("order_by"); ok {
197+
paramMap["OrderBy"] = helper.String(v.(string))
198+
}
199+
200+
if v, ok := d.GetOk("order"); ok {
201+
paramMap["Order"] = helper.String(v.(string))
202+
}
203+
204+
service := EbService{client: meta.(*TencentCloudClient).apiV3Conn}
205+
206+
var rules []*eb.Rule
207+
208+
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
209+
result, e := service.DescribeEbEventRulesByFilter(ctx, paramMap)
210+
if e != nil {
211+
return retryError(e)
212+
}
213+
rules = result
214+
return nil
215+
})
216+
if err != nil {
217+
return err
218+
}
219+
220+
ids := make([]string, 0, len(rules))
221+
tmpList := make([]map[string]interface{}, 0, len(rules))
222+
223+
if rules != nil {
224+
for _, rule := range rules {
225+
ruleMap := map[string]interface{}{}
226+
227+
if rule.Status != nil {
228+
ruleMap["status"] = rule.Status
229+
}
230+
231+
if rule.ModTime != nil {
232+
ruleMap["mod_time"] = rule.ModTime
233+
}
234+
235+
if rule.Enable != nil {
236+
ruleMap["enable"] = rule.Enable
237+
}
238+
239+
if rule.Description != nil {
240+
ruleMap["description"] = rule.Description
241+
}
242+
243+
if rule.RuleId != nil {
244+
ruleMap["rule_id"] = rule.RuleId
245+
}
246+
247+
if rule.AddTime != nil {
248+
ruleMap["add_time"] = rule.AddTime
249+
}
250+
251+
if rule.EventBusId != nil {
252+
ruleMap["event_bus_id"] = rule.EventBusId
253+
}
254+
255+
if rule.RuleName != nil {
256+
ruleMap["rule_name"] = rule.RuleName
257+
}
258+
259+
if rule.Targets != nil {
260+
targetsList := []interface{}{}
261+
for _, targets := range rule.Targets {
262+
targetsMap := map[string]interface{}{}
263+
264+
if targets.TargetId != nil {
265+
targetsMap["target_id"] = targets.TargetId
266+
}
267+
268+
if targets.Type != nil {
269+
targetsMap["type"] = targets.Type
270+
}
271+
272+
targetsList = append(targetsList, targetsMap)
273+
}
274+
275+
ruleMap["targets"] = []interface{}{targetsList}
276+
}
277+
278+
if rule.DeadLetterConfig != nil {
279+
deadLetterConfigMap := map[string]interface{}{}
280+
281+
if rule.DeadLetterConfig.DisposeMethod != nil {
282+
deadLetterConfigMap["dispose_method"] = rule.DeadLetterConfig.DisposeMethod
283+
}
284+
285+
if rule.DeadLetterConfig.CkafkaDeliveryParams != nil {
286+
ckafkaDeliveryParamsMap := map[string]interface{}{}
287+
288+
if rule.DeadLetterConfig.CkafkaDeliveryParams.TopicName != nil {
289+
ckafkaDeliveryParamsMap["topic_name"] = rule.DeadLetterConfig.CkafkaDeliveryParams.TopicName
290+
}
291+
292+
if rule.DeadLetterConfig.CkafkaDeliveryParams.ResourceDescription != nil {
293+
ckafkaDeliveryParamsMap["resource_description"] = rule.DeadLetterConfig.CkafkaDeliveryParams.ResourceDescription
294+
}
295+
296+
deadLetterConfigMap["ckafka_delivery_params"] = []interface{}{ckafkaDeliveryParamsMap}
297+
}
298+
299+
ruleMap["dead_letter_config"] = []interface{}{deadLetterConfigMap}
300+
}
301+
302+
ids = append(ids, *rule.EventBusId)
303+
tmpList = append(tmpList, ruleMap)
304+
}
305+
306+
_ = d.Set("rules", tmpList)
307+
}
308+
309+
d.SetId(helper.DataResourceIdsHash(ids))
310+
output, ok := d.GetOk("result_output_file")
311+
if ok && output.(string) != "" {
312+
if e := writeToFile(output.(string), tmpList); e != nil {
313+
return e
314+
}
315+
}
316+
return nil
317+
}

0 commit comments

Comments
 (0)