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
28 changes: 28 additions & 0 deletions .githooks/pre-commit-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
REQUIRED_GO_VERSION="1.18" # use the .go-version later

printf "==> Step 1: Gofmt Check...\n"
make fmt-faster
if [ $? -ne 0 ]; then
printf "COMMIT FAILED\n"
exit 1
fi

printf "==> Step 2: Generating docs...\n"
doc=$(make doc 2>&1)
if [ $? -ne 0 ]; then
echo "$doc" | tail -n 4 | head -n 2
printf "COMMIT FAILED\n"
exit 1
fi

printf "==> Step 2: Generating docs...\n"
go_version=$(go version | awk '{print $3}')
if [ $go_version -ne $REQUIRED_GO_VERSION* ]; then
echo "Go version is not compatible. Expected $REQUIRED_GO_VERSION.x"
printf "COMMIT FAILED\n"
exit 1
fi

printf "COMMIT READY\n"
exit 0
48 changes: 20 additions & 28 deletions examples/tencentcloud-tcaplus/main.tf
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
locals {
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
}

data "tencentcloud_vpc_subnets" "vpc" {
is_default = true
availability_zone = var.availability_zone
}

resource "tencentcloud_tcaplus_cluster" "test_cluster" {
resource "tencentcloud_tcaplus_cluster" "example" {
idl_type = "PROTO"
cluster_name = "tf_tcaplus_g_table"
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
password = "1qaA2k1wgvfa3ZZZ"
cluster_name = "tf_example_tcaplus_cluster"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
password = "your_pw_123111"
old_password_expire_last = 3600
}

resource "tencentcloud_tcaplus_idl" "test_idl" {
cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.test_tablegroup.id
file_name = "tf_idl_test_guagua"
resource "tencentcloud_tcaplus_tablegroup" "example" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_name = "tf_example_group_name"
}

resource "tencentcloud_tcaplus_idl" "main" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.example.id
file_name = "tf_example_tcaplus_idl"
file_type = "PROTO"
file_ext_type = "proto"
file_content = <<EOF
syntax = "proto2";
package myTcaplusTable;
import "tcaplusservice.optionv1.proto";
message tb_online_guagua {
message tb_online {
option(tcaplusservice.tcaplus_primary_key) = "uin,name,region";
required int64 uin = 1;
required string name = 2;
Expand All @@ -46,21 +56,3 @@ resource "tencentcloud_tcaplus_idl" "test_idl" {
}
EOF
}

resource "tencentcloud_tcaplus_tablegroup" "test_tablegroup" {
cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
tablegroup_name = "tf_test_tablegroup"
}

resource "tencentcloud_tcaplus_table" "test_table" {
cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.test_tablegroup.id
table_name = "tb_online_guagua"
table_type = "GENERIC"
description = "test"
idl_id = tencentcloud_tcaplus_idl.test_idl.id
table_idl_type = "PROTO"
reserved_read_cu = 1000
reserved_write_cu = 20
reserved_volume = 1
}
28 changes: 22 additions & 6 deletions tencentcloud/resource_tc_tcaplus_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,29 @@ Use this resource to create TcaplusDB cluster.

Example Usage

Create a new tcaplus cluster instance

```hcl
resource "tencentcloud_tcaplus_cluster" "test" {
locals {
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
}

variable "availability_zone" {
default = "ap-guangzhou-3"
}

data "tencentcloud_vpc_subnets" "vpc" {
is_default = true
availability_zone = var.availability_zone
}

resource "tencentcloud_tcaplus_cluster" "example" {
idl_type = "PROTO"
cluster_name = "tf_tcaplus_cluster_test"
vpc_id = "vpc-7k6gzox6"
subnet_id = "subnet-akwgvfa3"
password = "1qaA2k1wgvfa3ZZZ"
cluster_name = "tf_example_tcaplus_cluster"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
password = "your_pw_123111"
old_password_expire_last = 3600
}
```
Expand All @@ -21,7 +37,7 @@ Import
tcaplus cluster can be imported using the id, e.g.

```
$ terraform import tencentcloud_tcaplus_cluster.test 26655801
$ terraform import tencentcloud_tcaplus_cluster.example cluster_id
```

*/
Expand Down
41 changes: 29 additions & 12 deletions tencentcloud/resource_tc_tcaplus_idl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,43 @@ Use this resource to create TcaplusDB IDL file.

Example Usage

Create a tcaplus database idl file

The file will be with a specified cluster and tablegroup.

```hcl
resource "tencentcloud_tcaplus_cluster" "test" {
locals {
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
}

variable "availability_zone" {
default = "ap-guangzhou-3"
}

data "tencentcloud_vpc_subnets" "vpc" {
is_default = true
availability_zone = var.availability_zone
}

resource "tencentcloud_tcaplus_cluster" "example" {
idl_type = "PROTO"
cluster_name = "tf_tcaplus_cluster_test"
vpc_id = "vpc-7k6gzox6"
subnet_id = "subnet-akwgvfa3"
password = "1qaA2k1wgvfa3ZZZ"
cluster_name = "tf_example_tcaplus_cluster"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
password = "your_pw_123111"
old_password_expire_last = 3600
}

resource "tencentcloud_tcaplus_tablegroup" "tablegroup" {
cluster_id = tencentcloud_tcaplus_cluster.test.id
tablegroup_name = "tf_test_group_name"
resource "tencentcloud_tcaplus_tablegroup" "example" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_name = "tf_example_group_name"
}

resource "tencentcloud_tcaplus_idl" "main" {
cluster_id = tencentcloud_tcaplus_cluster.test.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.tablegroup.id
file_name = "tf_idl_test"
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.example.id
file_name = "tf_example_tcaplus_idl"
file_type = "PROTO"
file_ext_type = "proto"
file_content = <<EOF
Expand Down Expand Up @@ -52,7 +70,6 @@ resource "tencentcloud_tcaplus_idl" "main" {
}
EOF
}

```
*/
package tencentcloud
Expand Down
56 changes: 37 additions & 19 deletions tencentcloud/resource_tc_tcaplus_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,51 @@ Use this resource to create TcaplusDB table.

Example Usage

Create a tcaplus database table

The tcaplus database table should be pre-defined in the idl file.

```hcl
resource "tencentcloud_tcaplus_cluster" "test" {
locals {
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
}

variable "availability_zone" {
default = "ap-guangzhou-3"
}

data "tencentcloud_vpc_subnets" "vpc" {
is_default = true
availability_zone = var.availability_zone
}

resource "tencentcloud_tcaplus_cluster" "example" {
idl_type = "PROTO"
cluster_name = "tf_tcaplus_cluster_test"
vpc_id = "vpc-7k6gzox6"
subnet_id = "subnet-akwgvfa3"
password = "1qaA2k1wgvfa3ZZZ"
cluster_name = "tf_example_tcaplus_cluster"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
password = "your_pw_123111"
old_password_expire_last = 3600
}

resource "tencentcloud_tcaplus_tablegroup" "tablegroup" {
cluster_id = tencentcloud_tcaplus_cluster.test.id
tablegroup_name = "tf_test_group_name"
resource "tencentcloud_tcaplus_tablegroup" "example" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_name = "tf_example_group_name"
}

resource "tencentcloud_tcaplus_idl" "main" {
cluster_id = tencentcloud_tcaplus_cluster.test.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.tablegroup.id
file_name = "tf_idl_test_2"
resource "tencentcloud_tcaplus_idl" "example" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.example.id
file_name = "tf_example_tcaplus_idl"
file_type = "PROTO"
file_ext_type = "proto"
file_content = <<EOF
syntax = "proto2";
package myTcaplusTable;
import "tcaplusservice.optionv1.proto";
message tb_online {
option(tcaplusservice.tcaplus_primary_key) = "uin,name,region";
message example_table { # refer the table name
option(tcaplusservice.tcaplus_primary_key) = "uin,name,region";
required int64 uin = 1;
required string name = 2;
required int32 region = 3;
Expand All @@ -53,13 +71,13 @@ resource "tencentcloud_tcaplus_idl" "main" {
EOF
}

resource "tencentcloud_tcaplus_table" "table" {
cluster_id = tencentcloud_tcaplus_cluster.test.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.tablegroup.id
table_name = "tb_online"
resource "tencentcloud_tcaplus_table" "example" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_id = tencentcloud_tcaplus_tablegroup.example.id
table_name = "example_table"
table_type = "GENERIC"
description = "test"
idl_id = tencentcloud_tcaplus_idl.main.id
idl_id = tencentcloud_tcaplus_idl.example.id
table_idl_type = "PROTO"
reserved_read_cu = 1000
reserved_write_cu = 20
Expand Down
32 changes: 24 additions & 8 deletions tencentcloud/resource_tc_tcaplus_tablegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@ Use this resource to create TcaplusDB table group.

Example Usage

Create a tcaplusdb table group

```hcl
resource "tencentcloud_tcaplus_cluster" "test" {
locals {
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
}

variable "availability_zone" {
default = "ap-guangzhou-3"
}

data "tencentcloud_vpc_subnets" "vpc" {
is_default = true
availability_zone = var.availability_zone
}

resource "tencentcloud_tcaplus_cluster" "example" {
idl_type = "PROTO"
cluster_name = "tf_tcaplus_cluster_test"
vpc_id = "vpc-7k6gzox6"
subnet_id = "subnet-akwgvfa3"
password = "1qaA2k1wgvfa3ZZZ"
cluster_name = "tf_example_tcaplus_cluster"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
password = "your_pw_123111"
old_password_expire_last = 3600
}

resource "tencentcloud_tcaplus_tablegroup" "tablegroup" {
cluster_id = tencentcloud_tcaplus_cluster.test.id
tablegroup_name = "tf_test_group_name"
resource "tencentcloud_tcaplus_tablegroup" "example" {
cluster_id = tencentcloud_tcaplus_cluster.example.id
tablegroup_name = "tf_example_group_name"
}
```
*/
Expand Down
28 changes: 22 additions & 6 deletions website/docs/r/tcaplus_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ Use this resource to create TcaplusDB cluster.

## Example Usage

### Create a new tcaplus cluster instance

```hcl
resource "tencentcloud_tcaplus_cluster" "test" {
locals {
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
}

variable "availability_zone" {
default = "ap-guangzhou-3"
}

data "tencentcloud_vpc_subnets" "vpc" {
is_default = true
availability_zone = var.availability_zone
}

resource "tencentcloud_tcaplus_cluster" "example" {
idl_type = "PROTO"
cluster_name = "tf_tcaplus_cluster_test"
vpc_id = "vpc-7k6gzox6"
subnet_id = "subnet-akwgvfa3"
password = "1qaA2k1wgvfa3ZZZ"
cluster_name = "tf_example_tcaplus_cluster"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
password = "your_pw_123111"
old_password_expire_last = 3600
}
```
Expand Down Expand Up @@ -56,6 +72,6 @@ In addition to all arguments above, the following attributes are exported:
tcaplus cluster can be imported using the id, e.g.

```
$ terraform import tencentcloud_tcaplus_cluster.test 26655801
$ terraform import tencentcloud_tcaplus_cluster.example cluster_id
```

Loading