Skip to content

Commit 45bdd3c

Browse files
tongyimingmikatong
andauthored
fix: redis support renew-flag (#872)
Co-authored-by: mikatong <[email protected]>
1 parent b727a5e commit 45bdd3c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

tencentcloud/resource_tc_redis_instance.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@ func resourceTencentCloudRedisInstance() *schema.Resource {
251251
Optional: true,
252252
Description: "Indicate whether to delete Redis instance directly or not. Default is false. If set true, the instance will be deleted instead of staying recycle bin. Note: only works for `PREPAID` instance.",
253253
},
254+
"auto_renew_flag": {
255+
Type: schema.TypeInt,
256+
Optional: true,
257+
ForceNew: true,
258+
ValidateFunc: validateAllowedIntValue([]int{0, 1, 2}),
259+
Default: 0,
260+
Description: "Auto-renew flag. 0 - default state (manual renewal); 1 - automatic renewal; 2 - explicit no automatic renewal.",
261+
},
254262
},
255263
}
256264
}
@@ -281,6 +289,7 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
281289
projectId := d.Get("project_id").(int)
282290
port := d.Get("port").(int)
283291
chargeType := d.Get("charge_type").(string)
292+
autoRenewFlag := d.Get("auto_renew_flag").(int)
284293
chargeTypeID := REDIS_CHARGE_TYPE_ID[chargeType]
285294
var chargePeriod uint64 = 1
286295
if chargeType == REDIS_CHARGE_TYPE_PREPAID {
@@ -417,6 +426,7 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
417426
chargePeriod,
418427
nodeInfo,
419428
noAuth,
429+
autoRenewFlag,
420430
)
421431

422432
if err != nil {
@@ -535,6 +545,7 @@ func resourceTencentCloudRedisInstanceRead(d *schema.ResourceData, meta interfac
535545
_ = d.Set("port", info.Port)
536546
_ = d.Set("ip", info.WanIp)
537547
_ = d.Set("create_time", info.Createtime)
548+
_ = d.Set("auto_renew_flag", info.AutoRenewFlag)
538549

539550
// only true or user explicit declared will set for import case.
540551
if _, ok := d.GetOk("no_auth"); ok || *info.NoAuth {

tencentcloud/service_tencentcloud_redis.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ func (me *RedisService) CreateInstances(ctx context.Context,
249249
chargePeriod uint64,
250250
nodeInfo []*redis.RedisNodeInfo,
251251
noAuth bool,
252+
autoRenewFlag int,
252253
) (instanceIds []*string, errRet error) {
253254

254255
logId := getLogId(ctx)
@@ -324,7 +325,9 @@ func (me *RedisService) CreateInstances(ctx context.Context,
324325
if noAuth {
325326
request.NoAuth = &noAuth
326327
}
327-
328+
if chargeTypeID == REDIS_CHARGE_TYPE_ID[REDIS_CHARGE_TYPE_PREPAID] {
329+
request.AutoRenew = helper.IntUint64(autoRenewFlag)
330+
}
328331
ratelimit.Check(request.GetAction())
329332
response, err := me.client.UseRedisClient().CreateInstances(request)
330333
if err != nil {

website/docs/r/redis_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ The following arguments are supported:
6969

7070
* `availability_zone` - (Required, ForceNew) The available zone ID of an instance to be created, please refer to `tencentcloud_redis_zone_config.list`.
7171
* `mem_size` - (Required) The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].mem_sizes`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.
72+
* `auto_renew_flag` - (Optional, ForceNew) Auto-renew flag. 0 - default state (manual renewal); 1 - automatic renewal; 2 - explicit no automatic renewal.
7273
* `charge_type` - (Optional, ForceNew) The charge type of instance. Valid values: `PREPAID` and `POSTPAID`. Default value is `POSTPAID`. Note: TencentCloud International only supports `POSTPAID`. Caution that update operation on this field will delete old instances and create new with new charge type.
7374
* `force_delete` - (Optional) Indicate whether to delete Redis instance directly or not. Default is false. If set true, the instance will be deleted instead of staying recycle bin. Note: only works for `PREPAID` instance.
7475
* `name` - (Optional) Instance name.

0 commit comments

Comments
 (0)