### Install go-httpheader Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/mozillazg/go-httpheader/README.md Use 'go get' to install the go-httpheader library. ```bash go get github.com/mozillazg/go-httpheader ``` -------------------------------- ### Install contextcheck using go get Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/kkHAIKE/contextcheck/README.md Install the contextcheck tool using the `go get` command. This command fetches and installs the latest version of the tool. ```bash $ go get -u github.com/kkHAIKE/contextcheck ``` -------------------------------- ### Install go-version Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/hashicorp/go-version/README.md Install the go-version library using the standard go get command. ```bash $ go get github.com/hashicorp/go-version ``` -------------------------------- ### Install Gocognit using go get Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/uudashr/gocognit/README.md Installs the Gocognit command-line tool using the 'go get' command. This is an alternative method for obtaining the tool. ```bash $ go get github.com/uudashr/gocognit/cmd/gocognit ``` -------------------------------- ### Install Objx Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/stretchr/objx/README.md Use the go get command to install the Objx package. ```bash go get github.com/stretchr/objx ``` -------------------------------- ### Install Match Package Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/tidwall/match/README.md Use 'go get' to install the match package. This command fetches and installs the package and its dependencies. ```bash go get -u github.com/tidwall/match ``` -------------------------------- ### Install xstrings Go Package Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/huandu/xstrings/README.md Use 'go get' to install this library. This command fetches and installs the specified package. ```go go get github.com/huandu/xstrings ``` -------------------------------- ### Install go-isatty Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/mattn/go-isatty/README.md Install the go-isatty package using go get. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install Pretty Package Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/tidwall/pretty/README.md Install the Pretty package using go get. Ensure Go is installed on your system. ```sh go get -u github.com/tidwall/pretty ``` -------------------------------- ### Install go-header Linter Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/denis-tingaikin/go-header/README.md Use 'go get' to install the go-header command-line tool. This command fetches and installs the linter. ```bash go get github.com/denis-tingaikin/go-header/cmd/go-header ``` -------------------------------- ### Install asciicheck Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/tdakkota/asciicheck/README.md Install the asciicheck command-line tool using go get. ```bash go get -u github.com/tdakkota/asciicheck/cmd/asciicheck ``` -------------------------------- ### Install goconst Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/jgautheron/goconst/README.md Install the goconst command-line tool using go get. ```bash $ go get github.com/jgautheron/goconst/cmd/goconst $ goconst ./... ``` -------------------------------- ### Install copystructure Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/mitchellh/copystructure/README.md Use standard go get to install the copystructure library. ```bash go get github.com/mitchellh/copystructure ``` -------------------------------- ### Install OpenCensus Go Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/go.opencensus.io/README.md Use 'go get' to install the OpenCensus Go library. Dependency management tools are recommended. ```bash $ go get -u go.opencensus.io ``` -------------------------------- ### Install go-getter Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/hashicorp/go-getter/README.md Install the go-getter library using the standard go get command. ```bash go get github.com/hashicorp/go-getter ``` -------------------------------- ### Install Afero Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/spf13/afero/README.md Use 'go get' to install the latest version of the Afero library. ```bash $ go get github.com/spf13/afero ``` -------------------------------- ### Install msgpack/v5 Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/vmihailenco/msgpack/v5/README.md Install the msgpack/v5 library using go get. Ensure you have initialized a Go module first. ```shell go get github.com/vmihailenco/msgpack/v5 ``` -------------------------------- ### WeData Get Table Columns Example Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/wedata/data_source_tc_wedata_get_table_columns.md Example usage of the tencentcloud_wedata_get_table_columns data source to retrieve column information for a specific table GUID. ```hcl data "tencentcloud_wedata_get_table_columns" "example" { table_guid = "ktDR4ymhp2_nlfClXhwxRQ" } ``` -------------------------------- ### Create TencentCloud AS Start Instances Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/as/resource_tc_as_start_instances.md This example shows how to create a VPC, subnet, scaling configuration, scaling group, attach an instance, and then start instances within the scaling group. Ensure all prerequisite resources like VPC and subnet are defined before creating the scaling group and starting instances. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "as" } data "tencentcloud_images" "image" { image_type = ["PUBLIC_IMAGE"] os_name = "TencentOS Server 3.2 (Final)" } data "tencentcloud_instance_types" "instance_types" { filter { name = "zone" values = [data.tencentcloud_availability_zones_by_product.zones.zones.0.name] } filter { name = "instance-family" values = ["S5"] } cpu_core_count = 2 exclude_sold_out = true } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { vpc_id = tencentcloud_vpc.vpc.id name = "subnet-example" cidr_block = "10.0.0.0/16" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name } resource "tencentcloud_as_scaling_config" "example" { configuration_name = "tf-example" image_id = data.tencentcloud_images.image.images.0.image_id instance_types = ["SA1.SMALL1", "SA2.SMALL1", "SA2.SMALL2", "SA2.SMALL4"] instance_name_settings { instance_name = "test-ins-name" } } resource "tencentcloud_as_scaling_group" "example" { scaling_group_name = "tf-example" configuration_id = tencentcloud_as_scaling_config.example.id max_size = 1 min_size = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_ids = [tencentcloud_subnet.subnet.id] } resource "tencentcloud_instance" "example" { instance_name = "tf_example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name image_id = data.tencentcloud_images.image.images.0.image_id instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type system_disk_type = "CLOUD_PREMIUM" system_disk_size = 50 hostname = "user" project_id = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id } # Attachment Instance resource "tencentcloud_as_attachment" "attachment" { scaling_group_id = tencentcloud_as_scaling_group.example.id instance_ids = [tencentcloud_instance.example.id] } resource "tencentcloud_as_start_instances" "start_instances" { auto_scaling_group_id = tencentcloud_as_scaling_group.example.id instance_ids = tencentcloud_as_attachment.attachment.instance_ids } ``` -------------------------------- ### Install WSL via Go Get Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/bombsimon/wsl/v3/README.md Installs the WSL linter locally using the 'go get' command. Ensure you have Go installed and configured. ```sh go get -u github.com/bombsimon/wsl/v3/cmd/... ``` -------------------------------- ### Create SQL Server DB Instance and Database Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/sqlserver/resource_tc_sqlserver_db.md This example demonstrates how to provision a SQL Server basic instance and then create a database within it. It includes setting up VPC, subnet, and security group resources. Ensure the availability zone and product are correctly specified. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "sqlserver" } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name name = "subnet-example" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-example" description = "desc." } resource "tencentcloud_sqlserver_basic_instance" "example" { name = "tf-example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id project_id = 0 memory = 4 storage = 100 cpu = 2 machine_type = "CLOUD_PREMIUM" maintenance_week_set = [1, 2, 3] maintenance_start_time = "09:00" maintenance_time_span = 3 security_groups = [tencentcloud_security_group.security_group.id] tags = { "test" = "test" } } resource "tencentcloud_sqlserver_db" "example" { instance_id = tencentcloud_sqlserver_basic_instance.example.id name = "tf_example_db" charset = "Chinese_PRC_BIN" remark = "test-remark" } ``` -------------------------------- ### Create a MySQL instance and configure local binlog Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/cdb/resource_tc_mysql_local_binlog_config.md This example demonstrates how to provision a MySQL instance with specific configurations and then set up its local binlog retention period and maximum usage percentage. Ensure the necessary VPC, subnet, and security group resources are defined. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "cdb" } resource "tencentcloud_vpc" "vpc" { name = "vpc-mysql" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name name = "subnet-mysql" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-mysql" description = "mysql test" } resource "tencentcloud_mysql_instance" "example" { internet_service = 1 engine_version = "5.7" charge_type = "POSTPAID" root_password = "PassWord123" slave_deploy_mode = 0 availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name slave_sync_mode = 1 instance_name = "tf-example-mysql" mem_size = 4000 volume_size = 200 vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id intranet_port = 3306 security_groups = [tencentcloud_security_group.security_group.id] tags = { name = "test" } parameters = { character_set_server = "utf8" max_connections = "1000" } } resource "tencentcloud_mysql_local_binlog_config" "example" { instance_id = tencentcloud_mysql_instance.example.id save_hours = 140 max_usage = 50 } ``` -------------------------------- ### Install tparallel with go get Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/moricho/tparallel/README.md Install the tparallel command-line tool using 'go get'. Ensure your Go environment is set up correctly. ```sh $ go get -u github.com/moricho/tparallel/cmd/tparallel ``` -------------------------------- ### Install nestif with go get Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/nakabonne/nestif/README.md Use 'go get' to install the nestif command-line tool. This command fetches and installs the specified package, making the 'nestif' executable available in your Go bin directory. ```bash go get github.com/nakabonne/nestif/cmd/nestif ``` -------------------------------- ### Create an Auto Scaling Group and Protect Instances Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/website/docs/r/as_protect_instances.html.markdown This example demonstrates the full setup, including creating a VPC, subnet, scaling configuration, scaling group, an instance, and then attaching and protecting the instance from scale-in. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "as" } data "tencentcloud_images" "image" { image_type = ["PUBLIC_IMAGE"] os_name = "TencentOS Server 3.2 (Final)" } data "tencentcloud_instance_types" "instance_types" { filter { name = "zone" values = [data.tencentcloud_availability_zones_by_product.zones.zones.0.name] } filter { name = "instance-family" values = ["S5"] } cpu_core_count = 2 exclude_sold_out = true } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { vpc_id = tencentcloud_vpc.vpc.id name = "subnet-example" cidr_block = "10.0.0.0/16" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name } resource "tencentcloud_as_scaling_config" "example" { configuration_name = "tf-example" image_id = data.tencentcloud_images.image.images.0.image_id instance_types = ["SA1.SMALL1", "SA2.SMALL1", "SA2.SMALL2", "SA2.SMALL4"] instance_name_settings { instance_name = "test-ins-name" } } resource "tencentcloud_as_scaling_group" "example" { scaling_group_name = "tf-example" configuration_id = tencentcloud_as_scaling_config.example.id max_size = 1 min_size = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_ids = [tencentcloud_subnet.subnet.id] } resource "tencentcloud_instance" "example" { instance_name = "tf_example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name image_id = data.tencentcloud_images.image.images.0.image_id instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type system_disk_type = "CLOUD_PREMIUM" system_disk_size = 50 hostname = "user" project_id = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id } # Attachment Instance resource "tencentcloud_as_attachment" "attachment" { scaling_group_id = tencentcloud_as_scaling_group.example.id instance_ids = [tencentcloud_instance.example.id] } # Set protect resource "tencentcloud_as_protect_instances" "protect" { auto_scaling_group_id = tencentcloud_as_scaling_group.example.id instance_ids = tencentcloud_as_attachment.attachment.instance_ids protected_from_scale_in = true } ``` -------------------------------- ### Yamux Server Example Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/hashicorp/yamux/README.md Illustrates setting up a Yamux server to accept a connection, establish a session, and receive data on a stream. Assumes an active listener. ```go func server() { // Accept a TCP connection conn, err := listener.Accept() if err != nil { panic(err) } // Setup server side of yamux session, err := yamux.Server(conn, nil) if err != nil { panic(err) } // Accept a stream stream, err := session.Accept() if err != nil { panic(err) } // Listen for a message buf := make([]byte, 4) stream.Read(buf) } ``` -------------------------------- ### Install tagparser Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/vmihailenco/tagparser/v2/README.md Installs the tagparser library using go get. ```shell go get github.com/vmihailenco/tagparser/v2 ``` -------------------------------- ### SQL Server Basic Instance and DB Configuration Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/sqlserver/resource_tc_sqlserver_config_database_mdf.md This example demonstrates how to create a SQL Server basic instance, a database within that instance, and then configure the database's MDF settings. Ensure the availability zone, VPC, and subnet are correctly configured. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "sqlserver" } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name name = "subnet-example" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-example" description = "desc." } resource "tencentcloud_sqlserver_basic_instance" "example" { name = "tf-example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id project_id = 0 memory = 4 storage = 100 cpu = 2 machine_type = "CLOUD_PREMIUM" maintenance_week_set = [1, 2, 3] maintenance_start_time = "09:00" maintenance_time_span = 3 security_groups = [tencentcloud_security_group.security_group.id] tags = { "test" = "test" } } resource "tencentcloud_sqlserver_db" "example" { instance_id = tencentcloud_sqlserver_basic_instance.example.id name = "tf_example_db" charset = "Chinese_PRC_BIN" remark = "test-remark" } resource "tencentcloud_sqlserver_config_database_mdf" "example" { db_name = tencentcloud_sqlserver_db.example.name instance_id = tencentcloud_sqlserver_basic_instance.example.id } ``` -------------------------------- ### Creating Memory-Backed Filesystem Instance Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/spf13/afero/README.md This example demonstrates creating an in-memory filesystem using afero.NewMemMapFs(), suitable for mocking and speeding up I/O operations. ```go mm := afero.NewMemMapFs() mm.MkdirAll("src/a", 0755) ``` -------------------------------- ### Create a SQL Server Basic Instance and Terminate It Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/sqlserver/resource_tc_sqlserver_config_terminate_db_instance.md This example demonstrates how to create a SQL Server basic instance and then configure its termination. It requires setting up VPC, subnet, and security group resources first. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "sqlserver" } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name name = "subnet-example" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-example" description = "desc." } resource "tencentcloud_sqlserver_basic_instance" "example" { name = "tf-example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id project_id = 0 memory = 4 storage = 100 cpu = 2 machine_type = "CLOUD_PREMIUM" maintenance_week_set = [1, 2, 3] maintenance_start_time = "09:00" maintenance_time_span = 3 security_groups = [tencentcloud_security_group.security_group.id] tags = { "test" = "test" } } resource "tencentcloud_sqlserver_config_terminate_db_instance" "example" { instance_id = tencentcloud_sqlserver_basic_instance.example.id } ``` -------------------------------- ### Install gobwas/glob Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/gobwas/glob/readme.md Use 'go get' to install the glob library. ```shell go get github.com/gobwas/glob ``` -------------------------------- ### Yamux Client Example Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/hashicorp/yamux/README.md Demonstrates setting up a Yamux client to establish a connection, open a stream, and send data. Requires an established network connection. ```go func client() { // Get a TCP connection conn, err := net.Dial(...) if err != nil { panic(err) } // Setup client side of yamux session, err := yamux.Client(conn, nil) if err != nil { panic(err) } // Open a new stream stream, err := session.Open() if err != nil { panic(err) } // Stream implements net.Conn stream.Write([]byte("ping")) } ``` -------------------------------- ### Basic tencentcloud_as_start_instances Usage Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/website/docs/r/as_start_instances.html.markdown This example demonstrates how to start instances in an Auto Scaling group. It requires setting up availability zones, images, instance types, VPC, subnet, scaling configuration, scaling group, and an instance attachment. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "as" } data "tencentcloud_images" "image" { image_type = ["PUBLIC_IMAGE"] os_name = "TencentOS Server 3.2 (Final)" } data "tencentcloud_instance_types" "instance_types" { filter { name = "zone" values = [data.tencentcloud_availability_zones_by_product.zones.zones.0.name] } filter { name = "instance-family" values = ["S5"] } cpu_core_count = 2 exclude_sold_out = true } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { vpc_id = tencentcloud_vpc.vpc.id name = "subnet-example" cidr_block = "10.0.0.0/16" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name } resource "tencentcloud_as_scaling_config" "example" { configuration_name = "tf-example" image_id = data.tencentcloud_images.image.images.0.image_id instance_types = ["SA1.SMALL1", "SA2.SMALL1", "SA2.SMALL2", "SA2.SMALL4"] instance_name_settings { instance_name = "test-ins-name" } } resource "tencentcloud_as_scaling_group" "example" { scaling_group_name = "tf-example" configuration_id = tencentcloud_as_scaling_config.example.id max_size = 1 min_size = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_ids = [tencentcloud_subnet.subnet.id] } resource "tencentcloud_instance" "example" { instance_name = "tf_example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name image_id = data.tencentcloud_images.image.images.0.image_id instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type system_disk_type = "CLOUD_PREMIUM" system_disk_size = 50 hostname = "user" project_id = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id } # Attachment Instance resource "tencentcloud_as_attachment" "attachment" { scaling_group_id = tencentcloud_as_scaling_group.example.id instance_ids = [tencentcloud_instance.example.id] } resource "tencentcloud_as_start_instances" "start_instances" { auto_scaling_group_id = tencentcloud_as_scaling_group.example.id instance_ids = tencentcloud_as_attachment.attachment.instance_ids } ``` -------------------------------- ### Create a TencentCloud SQL Server Instance and Configure Parameters Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/sqlserver/resource_tc_sqlserver_config_instance_param.md This example demonstrates how to create a VPC, subnet, security group, and a basic SQL Server instance, then configure its parameters. Ensure the availability zone is correctly specified. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "sqlserver" } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name name = "subnet-example" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-example" description = "desc." } resource "tencentcloud_sqlserver_basic_instance" "example" { name = "tf-example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id project_id = 0 memory = 4 storage = 100 cpu = 2 machine_type = "CLOUD_PREMIUM" maintenance_week_set = [1, 2, 3] maintenance_start_time = "09:00" maintenance_time_span = 3 security_groups = [tencentcloud_security_group.security_group.id] tags = { "test" = "test" } } resource "tencentcloud_sqlserver_config_instance_param" "example" { instance_id = tencentcloud_sqlserver_basic_instance.example.id param_list { name = "fill factor(%)" current_value = "90" } } ``` -------------------------------- ### Install GJSON Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/tidwall/gjson/README.md Install the GJSON library using the go get command. ```sh go get -u github.com/tidwall/gjson ``` -------------------------------- ### Create and Query Direct Connect Gateway Instances Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/dcg/data_source_tc_dc_gateway_instances.md This example demonstrates how to create a Direct Connect Gateway and then query instances by name and ID. Note the comment about needing to sleep for a few seconds due to server-side caching. ```hcl resource "tencentcloud_ccn" "main" { name = "ci-temp-test-ccn" description = "ci-temp-test-ccn-des" qos = "AG" } resource "tencentcloud_dc_gateway" "ccn_main" { name = "ci-cdg-ccn-test" network_instance_id = tencentcloud_ccn.main.id network_type = "CCN" gateway_type = "NORMAL" } #You need to sleep for a few seconds because there is a cache on the server data "tencentcloud_dc_gateway_instances" "name_select" { name = tencentcloud_dc_gateway.ccn_main.name } data "tencentcloud_dc_gateway_instances" "id_select" { dcg_id = tencentcloud_dc_gateway.ccn_main.id } ``` -------------------------------- ### Full Example: VPC, NAT Gateway, and SNAT Rule Setup Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/website/docs/r/nat_gateway_snat.html.markdown This comprehensive example sets up a VPC, subnet, EIPs, a NAT Gateway, and then configures SNAT rules for both subnets and network interfaces. It includes data sources for availability zones, images, and instance types. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "nat" } data "tencentcloud_images" "image" { os_name = "centos" } data "tencentcloud_instance_types" "instance_types" { filter { name = "zone" values = [data.tencentcloud_availability_zones_by_product.zones.zones.0.name] } filter { name = "instance-family" values = ["S5"] } cpu_core_count = 2 exclude_sold_out = true } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { vpc_id = tencentcloud_vpc.vpc.id name = "subnet-example" cidr_block = "10.0.0.0/16" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name route_table_id = tencentcloud_route_table.route_table.id } resource "tencentcloud_eip" "eip_example1" { name = "eip_example1" } resource "tencentcloud_eip" "eip_example2" { name = "eip_example2" } # Create NAT Gateway resource "tencentcloud_nat_gateway" "my_nat" { vpc_id = tencentcloud_vpc.vpc.id name = "tf_example_nat_gateway" max_concurrent = 3000000 bandwidth = 500 assigned_eip_set = [ tencentcloud_eip.eip_example1.public_ip, tencentcloud_eip.eip_example2.public_ip, ] } # Create route_table and entry resource "tencentcloud_route_table" "route_table" { vpc_id = tencentcloud_vpc.vpc.id name = "tf_example" } resource "tencentcloud_route_table_entry" "route_entry" { route_table_id = tencentcloud_route_table.route_table.id destination_cidr_block = "10.0.0.0/8" next_type = "NAT" next_hub = tencentcloud_nat_gateway.my_nat.id } # Subnet Nat gateway snat resource "tencentcloud_nat_gateway_snat" "subnet_snat" { nat_gateway_id = tencentcloud_nat_gateway.my_nat.id resource_type = "SUBNET" subnet_id = tencentcloud_subnet.subnet.id subnet_cidr_block = tencentcloud_subnet.subnet.cidr_block description = "terraform test" public_ip_addr = [ tencentcloud_eip.eip_example1.public_ip, tencentcloud_eip.eip_example2.public_ip, ] } # Create instance resource "tencentcloud_instance" "example" { instance_name = "tf_example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name image_id = data.tencentcloud_images.image.images.0.image_id instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type system_disk_type = "CLOUD_PREMIUM" system_disk_size = 50 hostname = "user" project_id = 0 vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id } # NetWorkInterface Nat gateway snat resource "tencentcloud_nat_gateway_snat" "my_instance_snat" { nat_gateway_id = tencentcloud_nat_gateway.my_nat.id resource_type = "NETWORKINTERFACE" instance_id = tencentcloud_instance.example.id instance_private_ip_addr = tencentcloud_instance.example.private_ip description = "terraform test" public_ip_addr = [ tencentcloud_eip.eip_example1.public_ip, ] } ``` -------------------------------- ### Install Gocognit using go install Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/uudashr/gocognit/README.md Installs the Gocognit command-line tool using the 'go install' command, ensuring the latest version is fetched. ```bash $ go install github.com/uudashr/gocognit/cmd/gocognit@latest ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/json-iterator/go/README.md Use the go get command to install the json-iterator/go library. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Install Project Locally Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/katbyte/terrafmt/README.md Install the project locally using 'go install .'. ```console go install . ``` -------------------------------- ### Install multierr Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/go.uber.org/multierr/README.md Use `go get` to install the multierr library. This command fetches and installs the latest stable version. ```bash go get -u go.uber.org/multierr ``` -------------------------------- ### Create a basic SQL Server instance Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/website/docs/r/sqlserver_complete_expansion.html.markdown This snippet demonstrates how to create a basic SQL Server instance with specified configurations, including VPC, subnet, security group, memory, storage, and maintenance windows. Ensure the availability zone, VPC, subnet, and security group are pre-configured. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "sqlserver" } resource "tencentcloud_vpc" "vpc" { name = "example-vpc" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name name = "example-vpc" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "example-sg" description = "desc." } resource "tencentcloud_sqlserver_instance" "example" { name = "tf_example_sql" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id security_groups = [tencentcloud_security_group.security_group.id] project_id = 0 memory = 2 storage = 20 maintenance_week_set = [1, 2, 3] maintenance_start_time = "01:00" maintenance_time_span = 3 tags = { "createBy" = "tfExample" } } ``` -------------------------------- ### Install Levenshtein Package Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/agext/levenshtein/README.md Use 'go get' to install the Levenshtein package. This command fetches and installs the package and its dependencies. ```go go get github.com/agext/levenshtein ``` -------------------------------- ### Complete tencentcloud_vpc_resume_snapshot_instance Example Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/vpc/resource_tc_vpc_resume_snapshot_instance.md A complete example demonstrating the tencentcloud_vpc_resume_snapshot_instance resource, including data sources and other related resources like tencentcloud_cos_bucket and tencentcloud_vpc_snapshot_policy. This setup requires a snapshot policy, a COS bucket, and snapshot files. ```hcl data "tencentcloud_vpc_snapshot_files" "example" { business_type = "securitygroup" instance_id = "sg-902tl7t7" start_date = "2022-10-10 00:00:00" end_date = "2023-10-30 00:00:00" } resource "tencentcloud_cos_bucket" "example" { bucket = "tf-example-1308919341" acl = "private" } resource "tencentcloud_vpc_snapshot_policy" "example" { snapshot_policy_name = "tf-example" backup_type = "time" cos_bucket = tencentcloud_cos_bucket.example.bucket cos_region = "ap-guangzhou" create_new_cos = false keep_time = 2 backup_policies { backup_day = "monday" backup_time = "00:00:00" } backup_policies { backup_day = "tuesday" backup_time = "01:00:00" } backup_policies { backup_day = "wednesday" backup_time = "02:00:00" } } resource "tencentcloud_vpc_resume_snapshot_instance" "example" { snapshot_policy_id = tencentcloud_vpc_snapshot_policy.example.id snapshot_file_id = data.tencentcloud_vpc_snapshot_files.example.snapshot_file_set.0.snapshot_file_id instance_id = "policy-1t6cob" } ``` -------------------------------- ### Install err113 Linter Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/Djarvur/go-err113/README.adoc Use 'go get' to install the err113 linter. This command fetches and installs the linter executable. ```bash go get -u github.com/Djarvur/go-err113/cmd/err113 ``` -------------------------------- ### Example .go-header.yml Configuration Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/denis-tingaikin/go-header/README.md A complete example of a .go-header.yml configuration file. It includes a company constant and a detailed Apache 2.0 license template. ```yaml --- values: const: MY COMPANY: mycompany.com template: | {{ MY COMPANY }} SPDX-License-Identifier: Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Install uuid Package Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/google/uuid/README.md Install the uuid package using the go get command. ```shell go get github.com/google/uuid ``` -------------------------------- ### Create a SQL Server basic instance and a read-only instance group Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/sqlserver/resource_tc_sqlserver_config_instance_ro_group.md This example demonstrates the creation of a basic SQL Server instance and a read-only instance group. It requires setting up VPC, subnet, and security group resources first. Ensure the availability zone and product are correctly specified. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "sqlserver" } resource "tencentcloud_vpc" "vpc" { name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name name = "subnet-example" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-example" description = "desc." } resource "tencentcloud_sqlserver_basic_instance" "example" { name = "tf-example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id project_id = 0 memory = 4 storage = 100 cpu = 2 machine_type = "CLOUD_PREMIUM" maintenance_week_set = [1, 2, 3] maintenance_start_time = "09:00" maintenance_time_span = 3 security_groups = [tencentcloud_security_group.security_group.id] tags = { "test" = "test" } } resource "tencentcloud_sqlserver_readonly_instance" "example" { name = "tf_example" availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.4.name charge_type = "POSTPAID_BY_HOUR" vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id memory = 4 storage = 20 master_instance_id = tencentcloud_sqlserver_basic_instance.example.id readonly_group_type = 2 read_only_group_name = "tf_example_ro" is_offline_delay = 1 read_only_max_delay_time = 10 min_read_only_in_group = 0 force_upgrade = true } ``` -------------------------------- ### Install gookit/color Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/gookit/color/README.zh-CN.md Use 'go get' to install the gookit/color library for your Go project. ```bash go get github.com/gookit/color ``` -------------------------------- ### Install asasalint Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/alingse/asasalint/README.md Use 'go install' to install the asasalint linter. Ensure your Go environment is set up correctly. ```sh go install github.com/alingse/asasalint/cmd/asasalint@latest ``` -------------------------------- ### Install Godot Linter Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/tetafro/godot/README.md Install the Godot linter using go get. This command fetches and installs the latest version of the tool. ```sh go get -u github.com/tetafro/godot/cmd/godot ``` -------------------------------- ### Create a MySQL instance and attach a security group Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/tencentcloud/services/cdb/resource_tc_mysql_security_groups_attachment.md This example demonstrates how to create a VPC, subnet, security group, and a MySQL instance, and then attach the security group to the MySQL instance. Ensure that the availability zone and product are correctly specified. ```hcl data "tencentcloud_availability_zones_by_product" "zones" { product = "cdb" } resource "tencentcloud_vpc" "vpc" { name = "vpc-mysql" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name name = "subnet-mysql" vpc_id = tencentcloud_vpc.vpc.id cidr_block = "10.0.0.0/16" is_multicast = false } resource "tencentcloud_security_group" "security_group" { name = "sg-mysql" description = "mysql test" } resource "tencentcloud_mysql_instance" "example" { internet_service = 1 engine_version = "5.7" charge_type = "POSTPAID" root_password = "PassWord123" slave_deploy_mode = 0 availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name slave_sync_mode = 1 instance_name = "tf-example-mysql" mem_size = 4000 volume_size = 200 vpc_id = tencentcloud_vpc.vpc.id subnet_id = tencentcloud_subnet.subnet.id intranet_port = 3306 security_groups = [tencentcloud_security_group.security_group.id] tags = { name = "test" } parameters = { character_set_server = "utf8" max_connections = "1000" } } resource "tencentcloud_mysql_security_groups_attachment" "example" { security_group_id = tencentcloud_security_group.security_group.id instance_id = tencentcloud_mysql_instance.example.id } ``` -------------------------------- ### Install gocover-cobertura and dependencies Source: https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/vendor/github.com/t-yuki/gocover-cobertura/README.md Installs the gocover-cobertura tool and its dependencies using the go get command. Ensure you have the go.tools/cmd/cover package installed. ```bash $ go get code.google.com/p/go.tools/cmd/cover $ go get github.com/t-yuki/gocover-cobertura ```