Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tencentcloud/data_source_tc_redis_instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ resource "tencentcloud_redis_instance" "redis_instance_test" {
mem_size = 8192
name = "terraform_test"
port = 6379

tags = {
"test" = "test"
}
Expand Down
10 changes: 6 additions & 4 deletions tencentcloud/resource_tc_redis_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ func resourceTencentCloudRedisInstance() *schema.Resource {
"redis_shard_num": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: 1,
Description: "The number of instance shard. This is not required for standalone and master slave versions.",
Computed: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有看到change方法?

Description: "The number of instance shard, default is 1. This is not required for standalone and master slave versions.",
},
"redis_replicas_num": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -283,7 +282,10 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf
redisName := d.Get("name").(string)
redisType := d.Get("type").(string)
typeId := int64(d.Get("type_id").(int))
redisShardNum := d.Get("redis_shard_num").(int)
var redisShardNum int = 1
if v, ok := d.GetOk("redis_shard_num"); ok {
redisShardNum = v.(int)
}
redisReplicasNum := d.Get("redis_replicas_num").(int)
password := d.Get("password").(string)
noAuth := d.Get("no_auth").(bool)
Expand Down
58 changes: 58 additions & 0 deletions tencentcloud/resource_tc_redis_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,30 @@ func TestAccTencentCloudRedisInstance_Maz(t *testing.T) {
})
}

func TestAccTencentCloudRedisInstance_Cluster(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccTencentCloudRedisInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccRedisInstanceCluster(),
Check: resource.ComposeAggregateTestCheckFunc(
testAccTencentCloudRedisInstanceExists("tencentcloud_redis_instance.redis_cluster"),
resource.TestCheckResourceAttr("tencentcloud_redis_instance.redis_cluster", "redis_shard_num", "1"),
),
},
{
Config: testAccRedisInstanceClusterUpdateShard(),
Check: resource.ComposeAggregateTestCheckFunc(
testAccTencentCloudRedisInstanceExists("tencentcloud_redis_instance.redis_cluster"),
resource.TestCheckResourceAttr("tencentcloud_redis_instance.redis_cluster", "redis_shard_num", "3"),
),
},
},
})
}

func TestAccTencentCloudRedisInstance_Prepaid(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Expand Down Expand Up @@ -488,6 +512,40 @@ resource "tencentcloud_redis_instance" "redis_maz" {
}`
}

func testAccRedisInstanceCluster() string {
return defaultVpcVariable + `
resource "tencentcloud_redis_instance" "redis_cluster" {
availability_zone = "ap-guangzhou-3"
type_id = 7
password = "AAA123456BBB"
mem_size = 4096
name = "terraform_cluster"
port = 6379
redis_shard_num = 1
redis_replicas_num = 2
replica_zone_ids = [100003, 100004]
vpc_id = var.vpc_id
subnet_id = var.subnet_id
}`
}

func testAccRedisInstanceClusterUpdateShard() string {
return defaultVpcVariable + `
resource "tencentcloud_redis_instance" "redis_cluster" {
availability_zone = "ap-guangzhou-3"
type_id = 7
password = "AAA123456BBB"
mem_size = 4096
name = "terraform_cluster"
port = 6379
redis_shard_num = 3
redis_replicas_num = 2
replica_zone_ids = [100003, 100004]
vpc_id = var.vpc_id
subnet_id = var.subnet_id
}`
}

func testAccRedisInstancePrepaidBasic() string {
return `
resource "tencentcloud_redis_instance" "redis_prepaid_instance_test" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/redis_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The following arguments are supported:
* `prepaid_period` - (Optional) The tenancy (time unit is month) of the prepaid instance, NOTE: it only works when charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`.
* `project_id` - (Optional) Specifies which project the instance should belong to.
* `redis_replicas_num` - (Optional) The number of instance copies. This is not required for standalone and master slave versions.
* `redis_shard_num` - (Optional, ForceNew) The number of instance shard. This is not required for standalone and master slave versions.
* `redis_shard_num` - (Optional) The number of instance shard, default is 1. This is not required for standalone and master slave versions.
* `replica_zone_ids` - (Optional) ID of replica nodes available zone. This is not required for standalone and master slave versions.
* `replicas_read_only` - (Optional, ForceNew) Whether copy read-only is supported, Redis 2.8 Standard Edition and CKV Standard Edition do not support replica read-only, turn on replica read-only, the instance will automatically read and write separate, write requests are routed to the primary node, read requests are routed to the replica node, if you need to open replica read-only, the recommended number of replicas >=2.
* `security_groups` - (Optional, ForceNew) ID of security group. If both vpc_id and subnet_id are not set, this argument should not be set either.
Expand Down