Skip to content

Commit 3a5942e

Browse files
committed
redis support modify auth
1 parent c65eeaa commit 3a5942e

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

tencentcloud/resource_tc_redis_instance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ func resourceTencentCloudRedisInstance() *schema.Resource {
163163
"no_auth": {
164164
Type: schema.TypeBool,
165165
Optional: true,
166-
ForceNew: true,
167166
Description: "Indicates whether the redis instance support no-auth access. NOTE: Only available in private cloud environment.",
168167
},
169168
"replicas_read_only": {
@@ -753,16 +752,17 @@ func resourceTencentCloudRedisInstanceUpdate(d *schema.ResourceData, meta interf
753752
}
754753
}
755754

756-
if d.HasChange("password") {
755+
if d.HasChange("password") || d.HasChange("no_auth") {
757756
var (
758757
taskId int64
759758
password = d.Get("password").(string)
759+
noAuth = d.Get("no_auth").(bool)
760760
err error
761761
)
762762

763763
// After redis spec modified, reset password may not successfully response immediately.
764764
err = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
765-
taskId, err = redisService.ResetPassword(ctx, id, password)
765+
taskId, err = redisService.ResetPassword(ctx, id, password, noAuth)
766766
if err != nil {
767767
log.Printf("[CRITAL]%s redis change password error, reason:%s\n", logId, err.Error())
768768
return retryError(err, redis.FAILEDOPERATION_SYSTEMERROR)

tencentcloud/resource_tc_redis_instance_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ resource "tencentcloud_redis_instance" "redis_instance_test" {
562562
redis_replicas_num = 1
563563
vpc_id = var.vpc_id
564564
subnet_id = var.subnet_id
565+
no_auth = true
565566
security_groups = [var.sg_id]
566567
567568
tags = {

tencentcloud/service_tencentcloud_redis.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,12 +844,13 @@ func (me *RedisService) DescribeTaskInfo(ctx context.Context, redisId string, ta
844844
return
845845
}
846846

847-
func (me *RedisService) ResetPassword(ctx context.Context, redisId string, newPassword string) (taskId int64, errRet error) {
847+
func (me *RedisService) ResetPassword(ctx context.Context, redisId string, newPassword string, noAuth bool) (taskId int64, errRet error) {
848848
logId := getLogId(ctx)
849849

850850
request := redis.NewResetPasswordRequest()
851851
request.InstanceId = &redisId
852852
request.Password = &newPassword
853+
request.NoAuth = &noAuth
853854
defer func() {
854855
if errRet != nil {
855856
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",

website/docs/r/redis_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The following arguments are supported:
7777
* `charge_type` - (Optional, String, 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.
7878
* `force_delete` - (Optional, Bool) 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.
7979
* `name` - (Optional, String) Instance name.
80-
* `no_auth` - (Optional, Bool, ForceNew) Indicates whether the redis instance support no-auth access. NOTE: Only available in private cloud environment.
80+
* `no_auth` - (Optional, Bool) Indicates whether the redis instance support no-auth access. NOTE: Only available in private cloud environment.
8181
* `params_template_id` - (Optional, String) Specify params template id. If not set, will use default template.
8282
* `password` - (Optional, String) Password for a Redis user, which should be 8 to 16 characters. NOTE: Only `no_auth=true` specified can make password empty.
8383
* `port` - (Optional, Int, ForceNew) The port used to access a redis instance. The default value is 6379. And this value can't be changed after creation, or the Redis instance will be recreated.

0 commit comments

Comments
 (0)