From 11f80aa3ab210c260e068df2758b36a9c7119432 Mon Sep 17 00:00:00 2001 From: hellertang Date: Thu, 10 Jul 2025 11:45:04 +0800 Subject: [PATCH 1/2] add crs redis --- .../crs/resource_tc_redis_instance.go | 14 +++- .../crs/resource_tc_redis_instance.md | 79 ++++++++++++++++++ website/docs/r/redis_instance.html.markdown | 82 ++++++++++++++++++- 3 files changed, 173 insertions(+), 2 deletions(-) diff --git a/tencentcloud/services/crs/resource_tc_redis_instance.go b/tencentcloud/services/crs/resource_tc_redis_instance.go index ef898780a9..c454301776 100644 --- a/tencentcloud/services/crs/resource_tc_redis_instance.go +++ b/tencentcloud/services/crs/resource_tc_redis_instance.go @@ -57,7 +57,19 @@ func ResourceTencentCloudRedisInstance() *schema.Resource { Type: schema.TypeInt, Optional: true, ValidateFunc: tccommon.ValidateIntegerMin(2), - Description: "Instance type. Available values reference data source `tencentcloud_redis_zone_config` or [document](https://intl.cloud.tencent.com/document/product/239/32069), toggle immediately when modified.", + Description: "Instance type. Available values reference data source `tencentcloud_redis_zone_config` or [document](https://intl.cloud.tencent.com/document/product/239/32069), toggle immediately when modified." + + ".", }, "redis_shard_num": { Type: schema.TypeInt, diff --git a/tencentcloud/services/crs/resource_tc_redis_instance.md b/tencentcloud/services/crs/resource_tc_redis_instance.md index 3ad34e2380..1688185bf6 100644 --- a/tencentcloud/services/crs/resource_tc_redis_instance.md +++ b/tencentcloud/services/crs/resource_tc_redis_instance.md @@ -223,6 +223,85 @@ resource "tencentcloud_redis_instance" "example" { } ``` +Create a memcached instance +```hcl +data "tencentcloud_redis_zone_config" "zone" { + type_id = 200 + region = "ap-guangzhou" +} + +variable "replica_zone_ids" { + default = [100004, 100006] +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_redis_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = data.tencentcloud_redis_zone_config.zone.list[2].zone + name = "tf_redis_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_security_group" "security_group" { + name = "tf-redis-sg" +} + +resource "tencentcloud_security_group_rule_set" "sg_rule" { + security_group_id = tencentcloud_security_group.security_group.id + + ingress { + action = "ACCEPT" + cidr_block = "10.0.0.0/22" + protocol = "TCP" + port = "80-90" + description = "A:Allow Ips and 80-90" + } + + ingress { + action = "ACCEPT" + cidr_block = "10.0.2.1" + protocol = "UDP" + port = "8080" + description = "B:Allow UDP 8080" + } + + egress { + action = "DROP" + cidr_block = "10.0.0.0/16" + protocol = "ICMP" + description = "A:Block ping3" + } + + egress { + action = "DROP" + cidr_block = "0.0.0.0/0" + protocol = "ALL" + description = "A:Block ping3" + } +} + +resource "tencentcloud_redis_instance" "example" { + availability_zone = data.tencentcloud_redis_zone_config.zone.list[2].zone + type_id = data.tencentcloud_redis_zone_config.zone.list[2].type_id + mem_size = 8192 + redis_shard_num = data.tencentcloud_redis_zone_config.zone.list[2].redis_shard_nums[0] + redis_replicas_num = 2 + no_auth = true + replica_zone_ids = var.replica_zone_ids + name = "tf-example" + port = 6379 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + security_groups = [tencentcloud_security_group.security_group.id] + + force_delete = true +} +``` + Create a CDC scenario instance ```hcl diff --git a/website/docs/r/redis_instance.html.markdown b/website/docs/r/redis_instance.html.markdown index 049fade4b7..6a8e5b7c5b 100644 --- a/website/docs/r/redis_instance.html.markdown +++ b/website/docs/r/redis_instance.html.markdown @@ -234,6 +234,86 @@ resource "tencentcloud_redis_instance" "example" { } ``` +### Create a memcached instance + +```hcl +data "tencentcloud_redis_zone_config" "zone" { + type_id = 200 + region = "ap-guangzhou" +} + +variable "replica_zone_ids" { + default = [100004, 100006] +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_redis_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = data.tencentcloud_redis_zone_config.zone.list[2].zone + name = "tf_redis_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_security_group" "security_group" { + name = "tf-redis-sg" +} + +resource "tencentcloud_security_group_rule_set" "sg_rule" { + security_group_id = tencentcloud_security_group.security_group.id + + ingress { + action = "ACCEPT" + cidr_block = "10.0.0.0/22" + protocol = "TCP" + port = "80-90" + description = "A:Allow Ips and 80-90" + } + + ingress { + action = "ACCEPT" + cidr_block = "10.0.2.1" + protocol = "UDP" + port = "8080" + description = "B:Allow UDP 8080" + } + + egress { + action = "DROP" + cidr_block = "10.0.0.0/16" + protocol = "ICMP" + description = "A:Block ping3" + } + + egress { + action = "DROP" + cidr_block = "0.0.0.0/0" + protocol = "ALL" + description = "A:Block ping3" + } +} + +resource "tencentcloud_redis_instance" "example" { + availability_zone = data.tencentcloud_redis_zone_config.zone.list[2].zone + type_id = data.tencentcloud_redis_zone_config.zone.list[2].type_id + mem_size = 8192 + redis_shard_num = data.tencentcloud_redis_zone_config.zone.list[2].redis_shard_nums[0] + redis_replicas_num = 2 + no_auth = true + replica_zone_ids = var.replica_zone_ids + name = "tf-example" + port = 6379 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + security_groups = [tencentcloud_security_group.security_group.id] + + force_delete = true +} +``` + ### Create a CDC scenario instance ```hcl @@ -310,7 +390,7 @@ The following arguments are supported: * `security_groups` - (Optional, Set: [`String`]) ID of security group. If both vpc_id and subnet_id are not set, this argument should not be set either. * `subnet_id` - (Optional, String) Specifies which subnet the instance should belong to. When the `operation_network` is `changeVpc` or `changeBaseToVpc`, this parameter needs to be configured. * `tags` - (Optional, Map) Instance tags. -* `type_id` - (Optional, Int) Instance type. Available values reference data source `tencentcloud_redis_zone_config` or [document](https://intl.cloud.tencent.com/document/product/239/32069), toggle immediately when modified. +* `type_id` - (Optional, Int) Instance type. Available values reference data source `tencentcloud_redis_zone_config` or [document](https://intl.cloud.tencent.com/document/product/239/32069), toggle immediately when modified.. * `type` - (Optional, String, ForceNew, **Deprecated**) It has been deprecated from version 1.33.1. Please use 'type_id' instead. Instance type. Available values: `cluster_ckv`,`cluster_redis5.0`,`cluster_redis`,`master_slave_ckv`,`master_slave_redis4.0`,`master_slave_redis5.0`,`master_slave_redis`,`standalone_redis`, specific region support specific types, need to refer data `tencentcloud_redis_zone_config`. * `vpc_id` - (Optional, String) ID of the vpc with which the instance is to be associated. When the `operation_network` is `changeVpc` or `changeBaseToVpc`, this parameter needs to be configured. * `wait_switch` - (Optional, Int) Switching mode: `1`-maintenance time window switching, `2`-immediate switching, default value `2`. From db9a078f8161a0db497a264f5aea414251bf3204 Mon Sep 17 00:00:00 2001 From: hellertang Date: Thu, 10 Jul 2025 11:47:11 +0800 Subject: [PATCH 2/2] add Memcached redis --- .changelog/3438.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3438.txt diff --git a/.changelog/3438.txt b/.changelog/3438.txt new file mode 100644 index 0000000000..4a951f2a76 --- /dev/null +++ b/.changelog/3438.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_redis_instance: suuport create memcached redis +```