@@ -3,33 +3,51 @@ Use this resource to create TcaplusDB table.
33
44Example Usage
55
6+ Create a tcaplus database table
7+
8+ The tcaplus database table should be pre-defined in the idl file.
9+
610```hcl
7- resource "tencentcloud_tcaplus_cluster" "test" {
11+ locals {
12+ vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
13+ subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
14+ }
15+
16+ variable "availability_zone" {
17+ default = "ap-guangzhou-3"
18+ }
19+
20+ data "tencentcloud_vpc_subnets" "vpc" {
21+ is_default = true
22+ availability_zone = var.availability_zone
23+ }
24+
25+ resource "tencentcloud_tcaplus_cluster" "example" {
826 idl_type = "PROTO"
9- cluster_name = "tf_tcaplus_cluster_test "
10- vpc_id = "vpc-7k6gzox6"
11- subnet_id = "subnet-akwgvfa3"
12- password = "1qaA2k1wgvfa3ZZZ "
27+ cluster_name = "tf_example_tcaplus_cluster "
28+ vpc_id = local.vpc_id
29+ subnet_id = local.subnet_id
30+ password = "your_pw_123111 "
1331 old_password_expire_last = 3600
1432}
1533
16- resource "tencentcloud_tcaplus_tablegroup" "tablegroup " {
17- cluster_id = tencentcloud_tcaplus_cluster.test .id
18- tablegroup_name = "tf_test_group_name "
34+ resource "tencentcloud_tcaplus_tablegroup" "example " {
35+ cluster_id = tencentcloud_tcaplus_cluster.example .id
36+ tablegroup_name = "tf_example_group_name "
1937}
2038
21- resource "tencentcloud_tcaplus_idl" "main " {
22- cluster_id = tencentcloud_tcaplus_cluster.test .id
23- tablegroup_id = tencentcloud_tcaplus_tablegroup.tablegroup .id
24- file_name = "tf_idl_test_2 "
39+ resource "tencentcloud_tcaplus_idl" "example " {
40+ cluster_id = tencentcloud_tcaplus_cluster.example .id
41+ tablegroup_id = tencentcloud_tcaplus_tablegroup.example .id
42+ file_name = "tf_example_tcaplus_idl "
2543 file_type = "PROTO"
2644 file_ext_type = "proto"
2745 file_content = <<EOF
2846 syntax = "proto2";
2947 package myTcaplusTable;
3048 import "tcaplusservice.optionv1.proto";
31- message tb_online {
32- option(tcaplusservice.tcaplus_primary_key) = "uin,name,region";
49+ message example_table { # refer the table name
50+ option(tcaplusservice.tcaplus_primary_key) = "uin,name,region";
3351 required int64 uin = 1;
3452 required string name = 2;
3553 required int32 region = 3;
@@ -53,13 +71,13 @@ resource "tencentcloud_tcaplus_idl" "main" {
5371 EOF
5472}
5573
56- resource "tencentcloud_tcaplus_table" "table " {
57- cluster_id = tencentcloud_tcaplus_cluster.test .id
58- tablegroup_id = tencentcloud_tcaplus_tablegroup.tablegroup .id
59- table_name = "tb_online "
74+ resource "tencentcloud_tcaplus_table" "example " {
75+ cluster_id = tencentcloud_tcaplus_cluster.example .id
76+ tablegroup_id = tencentcloud_tcaplus_tablegroup.example .id
77+ table_name = "example_table "
6078 table_type = "GENERIC"
6179 description = "test"
62- idl_id = tencentcloud_tcaplus_idl.main .id
80+ idl_id = tencentcloud_tcaplus_idl.example .id
6381 table_idl_type = "PROTO"
6482 reserved_read_cu = 1000
6583 reserved_write_cu = 20
0 commit comments