Skip to content

Commit b46dd83

Browse files
committed
add
1 parent c3b478b commit b46dd83

File tree

9 files changed

+3793
-1812
lines changed

9 files changed

+3793
-1812
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ require (
4646
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.961
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
4848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.970
49-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.971
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.973
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
@@ -73,7 +73,7 @@ require (
7373
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres v1.0.873
7474
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.859
7575
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.762
76-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.657
76+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.973
7777
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/rum v1.0.744
7878
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.807
7979
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses v1.0.748

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.970 h1:IsF+
970970
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.970/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
971971
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.971 h1:T5zEH1QM1XX+hJoAe4krnSjrnsTgHv1KfGC4Sos0Y4M=
972972
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.971/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
973+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.973 h1:XtrGe/XEyusLgGiv1DpEg9SRR7sxsSbIgAhMxcEVbjY=
974+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.973/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
973975
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
974976
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860/go.mod h1:NZo1WplQcC314kMlCRUoy8NQju2BnolIJj7NAWgsuhY=
975977
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=
@@ -1046,6 +1048,10 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.762 h1:rZDKucV
10461048
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.762/go.mod h1:QB/XcdVZ8mhRgk90XuXd+2Smfo8emTo0wHIUsygEaKs=
10471049
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.657 h1:9p/4/qXtnBIYkz5b5mYAhp1XhnIn5jUkxxfllF8hMMM=
10481050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.657/go.mod h1:CPc7SSKl8I21UmhTf2AVYZqZfy8MbDr/RrMsSqMkOAM=
1051+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.971 h1:G8+MTbUpCxB1XambBBCWbhxvSXAd6nSHC0p/gONaCDw=
1052+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.971/go.mod h1:dZboVm97Cz4p3ARJAx+08LQOYYNKI8fKCIhJd9xdMLw=
1053+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.973 h1:DsSTfkZQ5cPeVwol8zo4kYg57AFFHqEr0fdpke0eRtI=
1054+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.973/go.mod h1:Z+EvpolXVYJ8/VbdCLUen73PfwFAqIWHCOV5xrkFnPA=
10491055
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/region v1.0.920 h1:Kaab57oHrhiagHURsTNU/XfRFWXXSWxOXoix+YvLHrY=
10501056
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/region v1.0.920/go.mod h1:AhvwfhTo0JOz2FG4FcmVVdxJ73NpPAQ7rzjjWoEYFOw=
10511057
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/rum v1.0.744 h1:Z6xqpgnVPQfw2Yx/c2z6n30LfNodK4JEgMca1WpfOrY=

tencentcloud/services/crs/resource_tc_redis_instance.go

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,42 +161,48 @@ func ResourceTencentCloudRedisInstance() *schema.Resource {
161161
Optional: true,
162162
Description: "Specify params template id. If not set, will use default template.",
163163
},
164-
165164
"operation_network": {
166165
Type: schema.TypeString,
167166
Optional: true,
168167
ValidateFunc: tccommon.ValidateAllowedStringValue(REDIS_MODIFY_NETWORK_CONFIG),
169168
Description: "Refers to the category of the pre-modified network, including: `changeVip`: refers to switching the private network, including its intranet IPv4 address and port; `changeVpc`: refers to switching the subnet to which the private network belongs; `changeBaseToVpc`: refers to switching the basic network to a private network; `changeVPort`: refers to only modifying the instance network port.",
170169
},
171-
172170
"recycle": {
173171
Type: schema.TypeInt,
174172
Optional: true,
175173
ValidateFunc: tccommon.ValidateAllowedIntValue(REDIS_RECYCLE_TIME),
176174
Description: "Original intranet IPv4 address retention time: unit: day, value range: `0`, `1`, `2`, `3`, `7`, `15`.",
177175
},
178-
179176
"ip": {
180177
Type: schema.TypeString,
181178
Optional: true,
182179
Computed: true,
183180
Description: "IP address of an instance. When the `operation_network` is `changeVip`, this parameter needs to be configured.",
184181
},
185-
186182
"wait_switch": {
187183
Type: schema.TypeInt,
188184
Optional: true,
189185
Description: "Switching mode: `1`-maintenance time window switching, `2`-immediate switching, default value `2`.",
190186
},
191-
187+
"product_version": {
188+
Type: schema.TypeString,
189+
Optional: true,
190+
Computed: true,
191+
Description: "Specify the product version of the instance. `local`: Local disk version, `cloud`: Cloud disk version, `cdc`: Exclusive cluster version. Default is `local`.",
192+
},
193+
"redis_cluster_id": {
194+
Type: schema.TypeString,
195+
Optional: true,
196+
Computed: true,
197+
Description: "Exclusive cluster ID. When the `product_version` is set to `cdc`, this parameter must be set.",
198+
},
192199
"tags": {
193200
Type: schema.TypeMap,
194201
Optional: true,
195202
//internal version: replace tagComputed begin, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
196203
//internal version: replace tagComputed end, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
197204
Description: "Instance tags.",
198205
},
199-
200206
// Computed values
201207
"status": {
202208
Type: schema.TypeString,
@@ -267,15 +273,17 @@ func ResourceTencentCloudRedisInstance() *schema.Resource {
267273
func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interface{}) error {
268274
defer tccommon.LogElapsed("resource.tencentcloud_redis_instance.create")()
269275

270-
logId := tccommon.GetLogId(tccommon.ContextNil)
271-
ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
276+
var (
277+
logId = tccommon.GetLogId(tccommon.ContextNil)
278+
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
279+
client = meta.(tccommon.ProviderMeta).GetAPIV3Conn()
280+
redisService = RedisService{client: client}
281+
tagService = svctag.NewTagService(client)
282+
region = client.Region
283+
)
272284

273-
client := meta.(tccommon.ProviderMeta).GetAPIV3Conn()
274-
redisService := RedisService{client: client}
275-
tagService := svctag.NewTagService(client)
276285
//internal version: replace clientCreate begin, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
277286
//internal version: replace clientCreate end, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
278-
region := client.Region
279287

280288
availabilityZone := d.Get("availability_zone").(string)
281289
redisName := d.Get("name").(string)
@@ -285,6 +293,7 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
285293
if v, ok := d.GetOk("redis_shard_num"); ok {
286294
redisShardNum = v.(int)
287295
}
296+
288297
redisReplicasNum := d.Get("redis_replicas_num").(int)
289298
password := d.Get("password").(string)
290299
noAuth := d.Get("no_auth").(bool)
@@ -298,11 +307,18 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
298307
autoRenewFlag := d.Get("auto_renew_flag").(int)
299308
paramsTemplateId := d.Get("params_template_id").(string)
300309
operation := d.Get("operation_network").(string)
310+
productVersion := d.Get("product_version").(string)
311+
redisClusterId := d.Get("redis_cluster_id").(string)
312+
if productVersion == "cdc" && redisClusterId == "" {
313+
return fmt.Errorf("If `product_version` is set to `cdc`, params `redis_cluster_id` must be set\n.")
314+
}
315+
301316
chargeTypeID := REDIS_CHARGE_TYPE_ID[chargeType]
302317
var replicasReadonly bool
303318
if v, ok := d.GetOk("replicas_read_only"); ok {
304319
replicasReadonly = v.(bool)
305320
}
321+
306322
var chargePeriod uint64 = 1
307323
if chargeType == REDIS_CHARGE_TYPE_PREPAID {
308324
if period, ok := d.GetOk("prepaid_period"); ok {
@@ -335,6 +351,7 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
335351
if err != nil {
336352
return fmt.Errorf("api[DescribeRedisZoneConfig]fail, return %s", err.Error())
337353
}
354+
338355
var regionItem *redis.RegionConf
339356
var zoneItem *redis.ZoneCapacityConf
340357
var redisItem *redis.ProductConf
@@ -343,18 +360,22 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
343360
break
344361
}
345362
}
363+
346364
if regionItem == nil {
347365
return fmt.Errorf("all redis in this region `%s` be sold out", region)
348366
}
367+
349368
for _, zones := range regionItem.ZoneSet {
350369
if *zones.IsSaleout {
351370
continue
352371
}
372+
353373
if *zones.ZoneName == availabilityZone {
354374
zoneItem = zones
355375
break
356376
}
357377
}
378+
358379
if zoneItem == nil {
359380
return fmt.Errorf("all redis in this zone `%s` be sold out", availabilityZone)
360381
}
@@ -365,18 +386,22 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
365386
break
366387
}
367388
}
389+
368390
if redisItem == nil {
369391
return fmt.Errorf("redis type_id `%d` be sold out or this type_id is not supports", typeId)
370392
}
393+
371394
var redisShardNums []string
372395
var redisReplicasNums []string
373396
var numErrors []string
374397
for _, v := range redisItem.ShardNum {
375398
redisShardNums = append(redisShardNums, *v)
376399
}
400+
377401
for _, v := range redisItem.ReplicaNum {
378402
redisReplicasNums = append(redisReplicasNums, *v)
379403
}
404+
380405
if !tccommon.IsContains(redisShardNums, fmt.Sprintf("%d", redisShardNum)) {
381406
numErrors = append(numErrors, fmt.Sprintf("redis_shard_num : %s", strings.Join(redisShardNums, ",")))
382407
}
@@ -449,7 +474,10 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
449474
autoRenewFlag,
450475
replicasReadonly,
451476
paramsTemplateId,
477+
productVersion,
478+
redisClusterId,
452479
)
480+
453481
//internal version: replace varId begin, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
454482
//internal version: replace varId end, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
455483
if err != nil {
@@ -476,6 +504,7 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
476504
log.Printf("[CRITAL]%s create redis task fail, reason:%s\n", logId, err.Error())
477505
return err
478506
}
507+
479508
d.SetId(redisId)
480509
//internal version: replace queryAndSetId end, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
481510

@@ -582,6 +611,8 @@ func resourceTencentCloudRedisInstanceRead(d *schema.ResourceData, meta interfac
582611
_ = d.Set("ip", info.WanIp)
583612
_ = d.Set("create_time", info.Createtime)
584613
_ = d.Set("auto_renew_flag", info.AutoRenewFlag)
614+
_ = d.Set("product_version", info.)
615+
_ = d.Set("redis_cluster_id", info.)
585616
slaveReadWeight := *info.SlaveReadWeight
586617
if slaveReadWeight == 0 {
587618
_ = d.Set("replicas_read_only", false)

tencentcloud/services/crs/service_tencentcloud_redis.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ func (me *RedisService) CreateInstances(ctx context.Context,
263263
autoRenewFlag int,
264264
replicasReadonly bool,
265265
paramsTemplateId string,
266+
productVersion string,
267+
redisClusterId string,
266268
) (instanceIds []*string, errRet error) {
267269

268270
logId := tccommon.GetLogId(ctx)
@@ -347,6 +349,12 @@ func (me *RedisService) CreateInstances(ctx context.Context,
347349
if paramsTemplateId != "" {
348350
request.TemplateId = &paramsTemplateId
349351
}
352+
if productVersion != "" {
353+
request.ProductVersion = &productVersion
354+
}
355+
if redisClusterId != "" {
356+
request.RedisClusterId = &redisClusterId
357+
}
350358
ratelimit.Check(request.GetAction())
351359
response, err := me.client.UseRedisClient().CreateInstances(request)
352360
if err != nil {

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)