diff --git a/examples/tencentcloud-as/main.tf b/examples/tencentcloud-as/main.tf index 8847153913..fd97c50a81 100644 --- a/examples/tencentcloud-as/main.tf +++ b/examples/tencentcloud-as/main.tf @@ -1,19 +1,12 @@ -resource "tencentcloud_vpc" "vpc" { - name = "tf-as-vpc" - cidr_block = "10.2.0.0/16" +data "tencentcloud_images" "example" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" } -resource "tencentcloud_subnet" "subnet" { - vpc_id = tencentcloud_vpc.vpc.id - name = "tf-as-subnet" - cidr_block = "10.2.11.0/24" - availability_zone = var.availability_zone -} - -resource "tencentcloud_as_scaling_config" "launch_configuration" { - configuration_name = "tf-as-configuration" - image_id = "img-9qabwvbn" - instance_types = [var.instance_type] +resource "tencentcloud_as_scaling_config" "example" { + configuration_name = "example-launch-configuration" + image_id = data.tencentcloud_images.example.images.0.image_id + instance_types = ["SA1.SMALL1"] project_id = 0 system_disk_type = "CLOUD_PREMIUM" system_disk_size = "50" @@ -26,76 +19,12 @@ resource "tencentcloud_as_scaling_config" "launch_configuration" { internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR" internet_max_bandwidth_out = 10 public_ip_assigned = true - password = "test123#" + password = "Test@123#" enhanced_security_service = false enhanced_monitor_service = false - user_data = "test" + user_data = "dGVzdA==" instance_tags = { - tag = "as" + tag = "example" } -} - -resource "tencentcloud_as_scaling_group" "scaling_group" { - scaling_group_name = "tf-as-scaling-group" - configuration_id = tencentcloud_as_scaling_config.launch_configuration.id - max_size = var.max_size - min_size = var.min_size - vpc_id = tencentcloud_vpc.vpc.id - subnet_ids = [tencentcloud_subnet.subnet.id] - project_id = 0 - default_cooldown = 400 - desired_capacity = var.desired_capacity - termination_policies = ["NEWEST_INSTANCE"] - retry_policy = "INCREMENTAL_INTERVALS" - - tags = { - "test" = "test" - } -} - -resource "tencentcloud_as_scaling_policy" "scaling_policy" { - scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - policy_name = "tf-as-scaling-policy" - adjustment_type = "EXACT_CAPACITY" - adjustment_value = 2 - comparison_operator = "GREATER_THAN" - metric_name = "CPU_UTILIZATION" - threshold = 80 - period = 300 - continuous_time = 10 - statistic = "AVERAGE" - cooldown = 360 -} - -resource "tencentcloud_as_schedule" "schedule" { - scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - schedule_action_name = "tf-as-schedule" - max_size = var.max_size - min_size = var.min_size - desired_capacity = var.desired_capacity - start_time = "2020-01-01T00:00:00+08:00" - end_time = "2020-12-01T00:00:00+08:00" - recurrence = "0 0 */1 * *" -} - -resource "tencentcloud_as_lifecycle_hook" "lifecycle_hook" { - scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - lifecycle_hook_name = "tf-as-lifecycle" - lifecycle_transition = "INSTANCE_TERMINATING" - default_result = "ABANDON" - heartbeat_timeout = 300 - notification_metadata = "tf lifecycle test" - notification_target_type = "CMQ_QUEUE" - notification_queue_name = "notification" -} - -resource "tencentcloud_as_notification" "notification" { - scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - notification_types = ["SCALE_OUT_FAILED"] - notification_user_group_ids = ["76955"] -} - -data "tencentcloud_as_scaling_groups" "scaling_groups_tags" { - tags = tencentcloud_as_scaling_group.scaling_group.tags -} +} \ No newline at end of file diff --git a/examples/tencentcloud-as/variables.tf b/examples/tencentcloud-as/variables.tf index bda5f0d8f9..e69de29bb2 100644 --- a/examples/tencentcloud-as/variables.tf +++ b/examples/tencentcloud-as/variables.tf @@ -1,23 +0,0 @@ -variable "availability_zone" { - default = "ap-guangzhou-3" -} - -variable "instance_type" { - default = "SA1.SMALL1" -} - -variable "min_size" { - default = 0 -} - -variable "max_size" { - default = 5 -} - -variable "desired_capacity" { - default = 0 -} - -variable "cvm_product" { - default = "cvm" -} diff --git a/examples/tencentcloud-mysql/main.tf b/examples/tencentcloud-mysql/main.tf index 56ceedf191..533a76b195 100644 --- a/examples/tencentcloud-mysql/main.tf +++ b/examples/tencentcloud-mysql/main.tf @@ -1,84 +1,46 @@ -resource "tencentcloud_mysql_instance" "main" { - mem_size = 1000 - volume_size = 50 - instance_name = "testAccMysql" - engine_version = "5.7" - root_password = "test1234" - availability_zone = var.availability_zone - internet_service = 1 - slave_sync_mode = 1 - intranet_port = 3360 - - tags = { - purpose = "for test" - } - - parameters = { - max_connections = "1000" - } -} - -resource "tencentcloud_mysql_readonly_instance" "readonly" { - master_instance_id = tencentcloud_mysql_instance.main.id - mem_size = 1000 - volume_size = 50 - instance_name = "testAccMysql_readonly" - intranet_port = 3360 +data "tencentcloud_availability_zones" "zones" {} - tags = { - purpose = "for test" - } +resource "tencentcloud_vpc" "vpc" { + name = "vpc-mysql" + cidr_block = var.vpc_cidr } -data "tencentcloud_mysql_parameter_list" "mysql" { - mysql_id = tencentcloud_mysql_instance.main.id +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-mysql" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = var.subnet_cidr + is_multicast = false } -resource "tencentcloud_mysql_account" "mysql_account" { - mysql_id = tencentcloud_mysql_instance.main.id - name = "test" - password = "test1234" - description = "for test" +resource "tencentcloud_security_group" "security_group" { + name = "sg-mysql" + description = "mysql test" } -resource "tencentcloud_mysql_privilege" "privilege" { - mysql_id = tencentcloud_mysql_instance.main.id - account_name = tencentcloud_mysql_account.mysql_account.name - global = ["TRIGGER"] - database { - privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE"] - database_name = "sys" - } - database { - privileges = ["SELECT"] - database_name = "performance_schema" - } - - table { - privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE"] - database_name = "mysql" - table_name = "slow_log" - } +resource "tencentcloud_mysql_instance" "example" { + internet_service = 1 + engine_version = "5.7" + charge_type = "POSTPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones.zones.zones.1.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] - table { - privileges = ["SELECT", "INSERT", "UPDATE"] - database_name = "mysql" - table_name = "user" + tags = { + name = "test" } - column { - privileges = ["SELECT", "INSERT", "UPDATE", "REFERENCES"] - database_name = "mysql" - table_name = "user" - column_name = "host" + parameters = { + character_set_server = "utf8" + max_connections = "1000" } -} - -resource "tencentcloud_mysql_backup_policy" "mysql_backup_policy" { - mysql_id = tencentcloud_mysql_instance.main.id - retention_period = 56 - backup_model = "physical" - backup_time = "10:00-14:00" -} - - +} \ No newline at end of file diff --git a/examples/tencentcloud-mysql/variables.tf b/examples/tencentcloud-mysql/variables.tf index 8c0f4e325c..9cdcb4845c 100644 --- a/examples/tencentcloud-mysql/variables.tf +++ b/examples/tencentcloud-mysql/variables.tf @@ -1,3 +1,7 @@ -variable "availability_zone" { - default = "ap-guangzhou-3" +variable "vpc_cidr" { + default = "10.0.0.0/16" +} + +variable "subnet_cidr" { + default = "10.0.0.0/16" } diff --git a/examples/tencentcloud-nat-gateway/main.tf b/examples/tencentcloud-nat-gateway/main.tf new file mode 100644 index 0000000000..97c5d4f527 --- /dev/null +++ b/examples/tencentcloud-nat-gateway/main.tf @@ -0,0 +1,26 @@ +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_nat_gateway_vpc" +} + +resource "tencentcloud_eip" "eip_example1" { + name = "tf_nat_gateway_eip1" +} + +resource "tencentcloud_eip" "eip_example2" { + name = "tf_nat_gateway_eip2" +} + +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 + assigned_eip_set = [ + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, + ] + tags = { + tf_tag_key = "tf_tag_value" + } +} diff --git a/examples/tencentcloud-security-group-lite-rule/version.tf b/examples/tencentcloud-nat-gateway/version.tf similarity index 93% rename from examples/tencentcloud-security-group-lite-rule/version.tf rename to examples/tencentcloud-nat-gateway/version.tf index 133d0d73e7..d9b6f790b9 100644 --- a/examples/tencentcloud-security-group-lite-rule/version.tf +++ b/examples/tencentcloud-nat-gateway/version.tf @@ -1,3 +1,3 @@ -terraform { - required_version = ">= 0.12" -} \ No newline at end of file +terraform { + required_version = ">= 0.12" +} diff --git a/examples/tencentcloud-nat/main.tf b/examples/tencentcloud-nat/main.tf index 80127c638c..a945dc9b2a 100644 --- a/examples/tencentcloud-nat/main.tf +++ b/examples/tencentcloud-nat/main.tf @@ -1,117 +1,26 @@ -data "tencentcloud_availability_zones" "my_zones" {} - -data "tencentcloud_vpc" "my_vpc" { - name = "Default-VPC" -} - -data "tencentcloud_images" "my_image" { - os_name = "centos" +resource "tencentcloud_vpc" "vpc" { + cidr_block = var.vpc_cidr + name = "tf_nat_gateway_vpc" } -data "tencentcloud_instance_types" "my_instance_types" { - cpu_core_count = 1 - memory_size = 1 +resource "tencentcloud_eip" "eip_example1" { + name = "tf_nat_gateway_eip1" } -# Create EIP -resource "tencentcloud_eip" "eip_dev_dnat" { - name = "terraform_test" +resource "tencentcloud_eip" "eip_example2" { + name = "tf_nat_gateway_eip2" } -resource "tencentcloud_eip" "eip_test_dnat" { - name = "terraform_test" -} - -# Create NAT Gateway -resource "tencentcloud_nat_gateway" "my_nat" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" - max_concurrent = 3000000 - bandwidth = 500 +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = var.bandwidth + max_concurrent = var.max_concurrent assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] -} - -# Create route_table and entry -resource "tencentcloud_route_table" "my_route_table" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" -} -resource "tencentcloud_route_table_entry" "my_route_entry" { - route_table_id = tencentcloud_route_table.my_route_table.id - destination_cidr_block = "10.0.0.0/8" - next_type = "NAT" - next_hub = tencentcloud_nat_gateway.my_nat.id -} - -# Create Subnet -resource "tencentcloud_subnet" "my_subnet" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" - cidr_block = "172.29.23.0/24" - availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name - route_table_id = tencentcloud_route_table.my_route_table.id -} - -# Create instance -resource "tencentcloud_instance" "my_instance" { - instance_name = "terraform test" - availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name - image_id = data.tencentcloud_images.my_image.images.0.image_id - instance_type = data.tencentcloud_instance_types.my_instance_types.instance_types.0.instance_type - system_disk_type = "CLOUD_PREMIUM" - system_disk_size = 50 - hostname = "user" - project_id = 0 - vpc_id = data.tencentcloud_vpc.my_vpc.id - subnet_id = tencentcloud_subnet.my_subnet.id - internet_max_bandwidth_out = 20 -} - -# Add DNAT Entry -resource "tencentcloud_dnat" "dev_dnat" { - vpc_id = tencentcloud_nat_gateway.my_nat.vpc_id - nat_id = tencentcloud_nat_gateway.my_nat.id - protocol = "TCP" - elastic_ip = tencentcloud_eip.eip_dev_dnat.public_ip - elastic_port = "80" - private_ip = tencentcloud_instance.my_instance.private_ip - private_port = "9001" -} - -resource "tencentcloud_dnat" "test_dnat" { - vpc_id = tencentcloud_nat_gateway.my_nat.vpc_id - nat_id = tencentcloud_nat_gateway.my_nat.id - protocol = "UDP" - elastic_ip = tencentcloud_eip.eip_test_dnat.public_ip - elastic_port = "8080" - private_ip = tencentcloud_instance.my_instance.private_ip - private_port = "9002" -} - -# Subnet Nat gateway snat -resource "tencentcloud_nat_gateway_snat" "my_subnet_snat" { - nat_gateway_id = tencentcloud_nat_gateway.my_nat.id - resource_type = "SUBNET" - subnet_id = tencentcloud_subnet.my_subnet.id - subnet_cidr_block = tencentcloud_subnet.my_subnet.cidr_block - description = "terraform test" - public_ip_addr = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, - ] -} - -# 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.my_instance.id - instance_private_ip_addr = tencentcloud_instance.my_instance.private_ip - description = "terraform test" - public_ip_addr = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - ] -} + tags = { + tf_tag_key = "tf_tag_value" + } +} \ No newline at end of file diff --git a/examples/tencentcloud-nat/variables.tf b/examples/tencentcloud-nat/variables.tf index 0f229c10fb..eaf5628165 100644 --- a/examples/tencentcloud-nat/variables.tf +++ b/examples/tencentcloud-nat/variables.tf @@ -1,7 +1,11 @@ -variable "short_name" { - default = "tc" -} - variable "vpc_cidr" { default = "10.1.0.0/21" } + +variable "bandwidth" { + default = 100 +} + +variable "max_concurrent" { + default = 1000000 +} diff --git a/examples/tencentcloud-security-group-lite-rule/main.tf b/examples/tencentcloud-security-group-lite-rule/main.tf deleted file mode 100644 index 387e3134c2..0000000000 --- a/examples/tencentcloud-security-group-lite-rule/main.tf +++ /dev/null @@ -1,35 +0,0 @@ -resource "tencentcloud_security_group" "foo" { - name = "ci-temp-test-sg" -} - -resource "tencentcloud_security_group_lite_rule" "lite-rule" { - security_group_id = tencentcloud_security_group.foo.id - - ingress = [ - "ACCEPT#192.168.1.0/24#80#TCP", - "DROP#8.8.8.8#80,90#UDP", - "ACCEPT#0.0.0.0/0#80-90#TCP", - ] - - egress = [ - "ACCEPT#192.168.0.0/16#ALL#TCP", - "ACCEPT#10.0.0.0/8#ALL#ICMP", - "DROP#0.0.0.0/0#ALL#ALL", - ] -} - -resource "tencentcloud_security_group_lite_rule" "lite-rule-ingress" { - security_group_id = tencentcloud_security_group.foo.id - - ingress = [ - "ACCEPT#192.168.1.0/24#80#TCP", - ] -} - -resource "tencentcloud_security_group_lite_rule" "lite-rule-egress" { - security_group_id = tencentcloud_security_group.foo.id - - egress = [ - "ACCEPT#192.168.0.0/16#ALL#TCP", - ] -} \ No newline at end of file diff --git a/examples/tencentcloud-security-group-rule-set/main.tf b/examples/tencentcloud-security-group-rule-set/main.tf new file mode 100644 index 0000000000..9851a17aca --- /dev/null +++ b/examples/tencentcloud-security-group-rule-set/main.tf @@ -0,0 +1,82 @@ +resource "tencentcloud_security_group" "base" { + name = "test-set-sg" + description = "Testing Rule Set Security" +} + +resource "tencentcloud_security_group" "relative" { + name = "for-relative" + description = "Used for attach security policy" +} + +resource "tencentcloud_address_template" "foo" { + name = "test-set-aTemp" + addresses = ["10.0.0.1", "10.0.1.0/24", "10.0.0.1-10.0.0.100"] +} + +resource "tencentcloud_address_template_group" "foo" { + name = "test-set-atg" + template_ids = [tencentcloud_address_template.foo.id] +} + +resource "tencentcloud_security_group_rule_set" "base" { + security_group_id = tencentcloud_security_group.base.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" + } + + ingress { + action = "ACCEPT" + cidr_block = "10.0.2.1" + protocol = "UDP" + port = "8080" + description = "C:Allow UDP 8080" + } + + ingress { + action = "ACCEPT" + cidr_block = "172.18.1.2" + protocol = "ALL" + port = "ALL" + description = "D:Allow ALL" + } + + ingress { + action = "DROP" + protocol = "TCP" + port = "80" + source_security_id = tencentcloud_security_group.relative.id + description = "E:Block relative" + } + + egress { + action = "DROP" + cidr_block = "10.0.0.0/16" + protocol = "ICMP" + description = "A:Block ping3" + } + + egress { + action = "DROP" + address_template_id = tencentcloud_address_template.foo.id + description = "B:Allow template" + } + + egress { + action = "DROP" + address_template_group = tencentcloud_address_template_group.foo.id + description = "C:DROP template group" + } +} \ No newline at end of file diff --git a/examples/tencentcloud-security-group-rule-set/variables.tf b/examples/tencentcloud-security-group-rule-set/variables.tf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/tencentcloud-security-group-rule/version.tf b/examples/tencentcloud-security-group-rule-set/version.tf similarity index 95% rename from examples/tencentcloud-security-group-rule/version.tf rename to examples/tencentcloud-security-group-rule-set/version.tf index 133d0d73e7..ee0f9705a2 100644 --- a/examples/tencentcloud-security-group-rule/version.tf +++ b/examples/tencentcloud-security-group-rule-set/version.tf @@ -1,3 +1,3 @@ -terraform { - required_version = ">= 0.12" +terraform { + required_version = ">= 0.12" } \ No newline at end of file diff --git a/examples/tencentcloud-security-group-rule/main.tf b/examples/tencentcloud-security-group-rule/main.tf deleted file mode 100644 index 68481c8a20..0000000000 --- a/examples/tencentcloud-security-group-rule/main.tf +++ /dev/null @@ -1,45 +0,0 @@ -resource "tencentcloud_security_group" "default" { - name = var.security_group_name - description = "New security group" -} - -resource "tencentcloud_security_group" "default2" { - name = var.security_group_name - description = "Anthor security group" -} - -resource "tencentcloud_security_group_rule" "http-in" { - security_group_id = tencentcloud_security_group.default.id - type = "ingress" - cidr_ip = "0.0.0.0/0" - ip_protocol = "tcp" - port_range = "80,8080" - policy = "accept" -} - -resource "tencentcloud_security_group_rule" "ssh-in" { - security_group_id = tencentcloud_security_group.default.id - type = "ingress" - cidr_ip = "0.0.0.0/0" - ip_protocol = "tcp" - port_range = "22" - policy = "accept" -} - -resource "tencentcloud_security_group_rule" "egress-drop" { - security_group_id = tencentcloud_security_group.default.id - type = "egress" - cidr_ip = "10.2.3.0/24" - ip_protocol = "udp" - port_range = "3000-4000" - policy = "drop" -} - -resource "tencentcloud_security_group_rule" "sourcesgid-in" { - security_group_id = tencentcloud_security_group.default.id - type = "ingress" - source_sgid = tencentcloud_security_group.default2.id - ip_protocol = "tcp" - port_range = "80,8080" - policy = "accept" -} diff --git a/examples/tencentcloud-security-group-rule/variables.tf b/examples/tencentcloud-security-group-rule/variables.tf deleted file mode 100644 index 091086f699..0000000000 --- a/examples/tencentcloud-security-group-rule/variables.tf +++ /dev/null @@ -1,3 +0,0 @@ -variable "security_group_name" { - default = "default-sg" -} diff --git a/examples/tencentcloud-security-group/main.tf b/examples/tencentcloud-security-group/main.tf index b52a15aba2..677dafc414 100644 --- a/examples/tencentcloud-security-group/main.tf +++ b/examples/tencentcloud-security-group/main.tf @@ -1,8 +1,9 @@ -resource "tencentcloud_security_group" "group" { - name = var.short_name - description = "New security group" +resource "tencentcloud_security_group" "example" { + name = "tf-example-sg" + description = "sg test" + project_id = 0 tags = { - "test" = "test" + "example" = "test" } -} +} \ No newline at end of file diff --git a/examples/tencentcloud-security-group/variables.tf b/examples/tencentcloud-security-group/variables.tf index a5f2ddc4bc..e69de29bb2 100644 --- a/examples/tencentcloud-security-group/variables.tf +++ b/examples/tencentcloud-security-group/variables.tf @@ -1,3 +0,0 @@ -variable "short_name" { - default = "tf test" -} diff --git a/examples/tencentcloud-ssl/main.tf b/examples/tencentcloud-ssl/main.tf index 6a14aa2537..abb117dbe2 100644 --- a/examples/tencentcloud-ssl/main.tf +++ b/examples/tencentcloud-ssl/main.tf @@ -1,20 +1,10 @@ -resource "tencentcloud_ssl_certificate" "ca" { - name = "ssl-ca" - type = "CA" - cert = var.ca +data "tencentcloud_ssl_certificates" "svr" { + name = tencentcloud_ssl_certificate.example.name } -resource "tencentcloud_ssl_certificate" "svr" { +resource "tencentcloud_ssl_certificate" "example" { name = "ssl-svr" type = "SVR" cert = var.cert key = var.key } - -data "tencentcloud_ssl_certificates" "ca" { - name = tencentcloud_ssl_certificate.ca.name -} - -data "tencentcloud_ssl_certificates" "svr" { - type = tencentcloud_ssl_certificate.svr.type -} \ No newline at end of file diff --git a/examples/tencentcloud-ssl/variables.tf b/examples/tencentcloud-ssl/variables.tf index f56f8f6288..90ac6185cb 100644 --- a/examples/tencentcloud-ssl/variables.tf +++ b/examples/tencentcloud-ssl/variables.tf @@ -1,7 +1,3 @@ -variable "ca" { - default = "-----BEGIN CERTIFICATE-----\nMIIEDjCCAnagAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzA4MjBaFw0yOTA4\nMTAwMzA4MjBaMCgxDTALBgNVBAMTBHRlc3QxFzAVBgNVBAoTDnRlcnJhZm9ybSB0\nZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0k2vqg/GHtFP5P7r\ndbzswfx1jSHeK9r4StV4mGOAoKyzvAJA5BvYbAHpSrL2ZAd6ShjHgRVU1qEroeFn\n8fwTrAVQttMltBFABx7G4iN4Zf6EUXzhhFN6vVVbWaqhYhrdMoPvZxgGSA/4hG4W\nGIr8MXZzXbKLoRoz4Bvq1Ymg5eO14KLJFSTahvIkG60egGN5pmi4czxWy2U7ycA5\nQ5TuQBnF0rKQJW5XKIV3kr5YrzDdJK7up9E6Od4T5jz+qY97KAjIpWD/pTAsc7+6\nfPBpY7NHT9Bw0fDmvsWO/PtswY4hW02n86b5eWA9sfKJGphhsBxgpuuhmxYHS6pA\nB+C7IkyxcADNT5u9tEo2JGOj+/veXKrEhZin7inKsQLD0WOobcg1Rh/3NSWD7geF\nTJBRnzgplaN7cK6c/utEAAnngS38q4DGBR/jHmkWjAeQPZj1eLLBk686HEEbKeU+\n9yAVcPRhA9tuL7wMeSX32VunWZunoA/f8iuGZYJlZsNBqyJbAgMBAAGjQzBBMA8G\nA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAweGADAdBgNVHQ4EFgQUKwfrmq79\n1mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAInM+aeaHoZdw9B9nAH2\nHscEoOulF+RxnysSXTTRLd2VQph4+ynlfRZT4evLBBj/ppmqjp8F7/OcRiiZwSXl\nnamyP/UUINtHfgDM0kll/5Za0aYzMhrORNw+3ythIv2yPJX8t4LmsG1L4PMO8ZU8\nN0K9XyKRaL/tq6rw1gQM152OmNgTzfAQoKYxrvbftOZz4J0ZACctuBmwtp5upKvJ\n36aQ4wJLUzOt69mnW+AaL5EPA37mwtzdnzTTxd3SBfOYXjsflc3l2raljJznnqU2\nySynjb6L3D3L/pObL1Uu7nQBy8CazJBsBsVFK/pr61vcllm8lG7vOhHOUSFUeezq\nFWukAolm9/cagmD6IhNishM3Uzng+UYyCC8uQq3Z7FGqJpXSI79wZYjudnCLPVCg\nOIfJHQeJFLryn6GxiSYmYs6dgUJiiTV+I/2Y5X7ZFdb5FC1J/WmvoCv6yO7NiirY\nBSgfV0lp5CuV8SfiSClpYfrM28NbNgxveUqET642BJOPLQ==\n-----END CERTIFICATE-----" -} - variable "cert" { default = "-----BEGIN CERTIFICATE-----\nMIIERzCCAq+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzE5MzlaFw0yOTA4\nMTAwMzE5MzlaMC4xEzARBgNVBAMTCnNlcnZlciBzc2wxFzAVBgNVBAoTDnRlcnJh\nZm9ybS10ZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1Ryp+DKK\nSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8YgpolenbmeEPrzT87tunFD7G9f6ALG\nND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqNAhGLaxWiEB/hy5WOiwxDrGei\ngQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVRopZuCe/RMPNusNVZaIi+qcEf\nfsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWCF97qy8TNYk94K/1tq3zyhVzR\nZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8IslgnqJW4izIXZqgIKmHaRZtM\nN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88aC8HnMqJJ3kScGCL36GYG+Kaw\n5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJyxAXyiX49LQ0v7f9qzwc/0JiD\nbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xlYP6l1SoJG3GgZ8dbAgMBAAGj\ndjB0MAwGA1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/\nBAUDAweAADAdBgNVHQ4EFgQULwWKBQNLL9s3cb3tTnyPVg+mpCMwHwYDVR0jBBgw\nFoAUKwfrmq791mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAMo5RglS\nAHdPgaicWJvmvjjexjF/42b7Rz4pPfMjYw6uYO8He/f4UZWv5CZLrbEe7MywaK3y\n0OsfH8AhyN29pv2x8g9wbmq7omZIOZ0oCAGduEXs/A/qY/hFaCohdkz/IN8qi6JW\nVXreGli3SrpcHFchSwHTyJEXgkutcGAsOvdsOuVSmplOyrkLHc8uUe8SG4j8kGyg\nEzaszFjHkR7g1dVyDVUedc588mjkQxYeAamJgfkgIhljWKMa2XzkVMcVfQHfNpM1\nn+bu8SmqRt9Wma2bMijKRG/Blm756LoI+skY+WRZmlDnq8zj95TT0vceGP0FUWh5\nhKyiocABmpQs9OK9HMi8vgSWISP+fYgkm/bKtKup2NbZBoO5/VL2vCEPInYzUhBO\njCbLMjNjtM5KriCaR7wDARgHiG0gBEPOEW1PIjZ9UOH+LtIxbNZ4eEIIINLHnBHf\nL+doVeZtS/gJc4G4Adr5HYuaS9ZxJ0W2uy0eQlOHzjyxR6Mf/rpnilJlcQ==\n-----END CERTIFICATE-----" } diff --git a/examples/tencentcloud-ssl/version.tf b/examples/tencentcloud-ssl/version.tf index 133d0d73e7..702e739ff9 100644 --- a/examples/tencentcloud-ssl/version.tf +++ b/examples/tencentcloud-ssl/version.tf @@ -1,3 +1,3 @@ terraform { required_version = ">= 0.12" -} \ No newline at end of file +} diff --git a/examples/tencentcloud-vpc/main.tf b/examples/tencentcloud-vpc/main.tf index 1b6b9af25f..0763011321 100644 --- a/examples/tencentcloud-vpc/main.tf +++ b/examples/tencentcloud-vpc/main.tf @@ -1,31 +1,93 @@ -resource "tencentcloud_vpc" "main" { - name = var.short_name - cidr_block = var.vpc_cidr +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +data "tencentcloud_instance_types" "instance_types" { + filter { + name = "zone" + values = [data.tencentcloud_availability_zones.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} - tags = { +resource "tencentcloud_cls_logset" "logset" { + logset_name = "delogsetmo" + tags = { "test" = "test" } } -data "tencentcloud_vpc_instances" "tags_instances" { - name = tencentcloud_vpc.main.name - tags = tencentcloud_vpc.main.tags +resource "tencentcloud_cls_topic" "topic" { + topic_name = "topic" + logset_id = tencentcloud_cls_logset.logset.id + auto_split = false + max_split_partitions = 20 + partition_count = 1 + period = 10 + storage_type = "hot" + tags = { + "test" = "test", + } +} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-flow-log-vpc" + cidr_block = var.vpc_cidr } -data "tencentcloud_vpc_instances" "default" {} +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "vpc-flow-log-subnet" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = var.subnet_cidr + is_multicast = false +} + +resource "tencentcloud_eni" "example" { + name = "vpc-flow-log-eni" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc" + ipv4_count = 1 +} -resource "tencentcloud_vpc_acl" "default" { - vpc_id = data.tencentcloud_vpc_instances.default.instance_list.0.vpc_id - name = "test_acl_update" - ingress = ["ACCEPT#192.168.1.0/24#800#TCP", "ACCEPT#192.168.1.0/24#800-900#TCP",] - egress = ["ACCEPT#192.168.1.0/24#800#TCP", "ACCEPT#192.168.1.0/24#800-900#TCP",] +resource "tencentcloud_instance" "example" { + instance_name = "ci-test-eni-attach" + availability_zone = data.tencentcloud_availability_zones.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" + disable_security_service = true + disable_monitor_service = true + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id } -resource "tencentcloud_vpc_acl_attachment" "example" { - acl_id = tencentcloud_vpc_acl.default.id - subnet_id = data.tencentcloud_vpc_instances.default.instance_list[0].subnet_ids[0] +resource "tencentcloud_eni_attachment" "example" { + eni_id = tencentcloud_eni.example.id + instance_id = tencentcloud_instance.example.id } -data "tencentcloud_vpc_acls" "default" { - name = "test_acl" +resource "tencentcloud_vpc_flow_log" "example" { + flow_log_name = "tf-example-vpc-flow-log" + resource_type = "NETWORKINTERFACE" + resource_id = tencentcloud_eni_attachment.example.eni_id + traffic_type = "ACCEPT" + vpc_id = tencentcloud_vpc.vpc.id + flow_log_description = "this is a testing flow log" + cloud_log_id = tencentcloud_cls_topic.topic.id + storage_type = "cls" + tags = { + "testKey" = "testValue" + } } diff --git a/examples/tencentcloud-vpc/variables.tf b/examples/tencentcloud-vpc/variables.tf index 0f229c10fb..9cdcb4845c 100644 --- a/examples/tencentcloud-vpc/variables.tf +++ b/examples/tencentcloud-vpc/variables.tf @@ -1,7 +1,7 @@ -variable "short_name" { - default = "tc" +variable "vpc_cidr" { + default = "10.0.0.0/16" } -variable "vpc_cidr" { - default = "10.1.0.0/21" +variable "subnet_cidr" { + default = "10.0.0.0/16" } diff --git a/tencentcloud/resource_tc_as_attachment.go b/tencentcloud/resource_tc_as_attachment.go index d5f82e425a..f73944f872 100644 --- a/tencentcloud/resource_tc_as_attachment.go +++ b/tencentcloud/resource_tc_as_attachment.go @@ -4,9 +4,76 @@ Provides a resource to attach or detach CVM instances to a specified scaling gro Example Usage ```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_instance" + 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 + allocate_public_ip = true + internet_max_bandwidth_out = 10 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + resource "tencentcloud_as_attachment" "attachment" { - scaling_group_id = "sg-afasfa" - instance_ids = ["ins-01", "ins-02"] + scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = [tencentcloud_instance.example.id] } ``` */ diff --git a/tencentcloud/resource_tc_as_complete_lifecycle.go b/tencentcloud/resource_tc_as_complete_lifecycle.go index b53a14d170..cda7a181f2 100644 --- a/tencentcloud/resource_tc_as_complete_lifecycle.go +++ b/tencentcloud/resource_tc_as_complete_lifecycle.go @@ -4,10 +4,86 @@ Provides a resource to create a as complete_lifecycle Example Usage ```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_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + lifecycle_hook_name = "tf-as-lifecycle-hook" + lifecycle_transition = "INSTANCE_LAUNCHING" + default_result = "CONTINUE" + heartbeat_timeout = 500 + notification_metadata = "tf test" +} + +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 +} + resource "tencentcloud_as_complete_lifecycle" "complete_lifecycle" { - lifecycle_hook_id = "ash-xxxxxxxx" + lifecycle_hook_id = tencentcloud_as_lifecycle_hook.example.id + instance_id = tencentcloud_instance.example.id lifecycle_action_result = "CONTINUE" - instance_id = "ins-xxxxxxxx" } ``` */ diff --git a/tencentcloud/resource_tc_as_execute_scaling_policy.go b/tencentcloud/resource_tc_as_execute_scaling_policy.go index c9450b4722..d737bbfcdd 100644 --- a/tencentcloud/resource_tc_as_execute_scaling_policy.go +++ b/tencentcloud/resource_tc_as_execute_scaling_policy.go @@ -4,10 +4,64 @@ Provides a resource to create a as execute_scaling_policy Example Usage ```hcl -resource "tencentcloud_as_execute_scaling_policy" "execute_scaling_policy" { - auto_scaling_policy_id = "asp-519acdug" - honor_cooldown = false - trigger_source = "API" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "as" +} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +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 = 4 + min_size = 1 + desired_capacity = 2 + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] +} + +resource "tencentcloud_as_scaling_policy" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + policy_name = "tf-as-scaling-policy" + adjustment_type = "EXACT_CAPACITY" + adjustment_value = 0 + comparison_operator = "GREATER_THAN" + metric_name = "CPU_UTILIZATION" + threshold = 80 + period = 300 + continuous_time = 10 + statistic = "AVERAGE" + cooldown = 360 +} + +resource "tencentcloud_as_execute_scaling_policy" "example" { + auto_scaling_policy_id = tencentcloud_as_scaling_policy.example.id + honor_cooldown = false + trigger_source = "API" } ``` diff --git a/tencentcloud/resource_tc_as_lifecycle_hook.go b/tencentcloud/resource_tc_as_lifecycle_hook.go index b47c9c3a68..963a1a5fe8 100644 --- a/tencentcloud/resource_tc_as_lifecycle_hook.go +++ b/tencentcloud/resource_tc_as_lifecycle_hook.go @@ -3,9 +3,63 @@ Provides a resource for an AS (Auto scaling) lifecycle hook. Example Usage +Create a basic LifecycleHook + +```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)" +} + +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_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + lifecycle_hook_name = "tf-as-lifecycle-hook" + lifecycle_transition = "INSTANCE_LAUNCHING" + default_result = "CONTINUE" + heartbeat_timeout = 500 + notification_metadata = "tf test" +} +``` + +If `notification_target_type` is `CMQ_QUEUE` + ```hcl -resource "tencentcloud_as_lifecycle_hook" "lifecycle_hook" { - scaling_group_id = "sg-12af45" +resource "tencentcloud_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id lifecycle_hook_name = "tf-as-lifecycle-hook" lifecycle_transition = "INSTANCE_LAUNCHING" default_result = "CONTINUE" @@ -15,6 +69,22 @@ resource "tencentcloud_as_lifecycle_hook" "lifecycle_hook" { notification_queue_name = "lifcyclehook" } ``` + +Or `notification_target_type` is `CMQ_TOPIC` + +```hcl +resource "tencentcloud_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + lifecycle_hook_name = "tf-as-lifecycle-hook" + lifecycle_transition = "INSTANCE_LAUNCHING" + default_result = "CONTINUE" + heartbeat_timeout = 500 + notification_metadata = "tf test" + notification_target_type = "CMQ_TOPIC" + notification_topic_name = "lifcyclehook" +} +``` + */ package tencentcloud diff --git a/tencentcloud/resource_tc_as_load_balancer.go b/tencentcloud/resource_tc_as_load_balancer.go index 3f18991f0c..14cc11786e 100644 --- a/tencentcloud/resource_tc_as_load_balancer.go +++ b/tencentcloud/resource_tc_as_load_balancer.go @@ -1,20 +1,100 @@ /* Provides a resource to create a as load_balancer +~> **NOTE:** `load_balancer_ids` A list of traditional load balancer IDs, with a maximum of 20 traditional load balancers bound to each scaling group. Only one LoadBalancerIds and ForwardLoadBalancers can be specified simultaneously. +~> **NOTE:** `forward_load_balancers` List of application type load balancers, with a maximum of 100 bound application type load balancers for each scaling group. Only one LoadBalancerIds and ForwardLoadBalancers can be specified simultaneously. + Example Usage +If use `load_balancer_ids` + +```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)" +} + +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_clb_instance" "example" { + network_type = "INTERNAL" + clb_name = "clb-example" + project_id = 0 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + + tags = { + test = "tf" + } +} + +resource "tencentcloud_clb_listener" "example" { + clb_id = tencentcloud_clb_instance.example.id + listener_name = "listener-example" + port = 80 + protocol = "HTTP" +} + +resource "tencentcloud_clb_listener_rule" "example" { + listener_id = tencentcloud_clb_listener.example.listener_id + clb_id = tencentcloud_clb_instance.example.id + domain = "foo.net" + url = "/bar" +} + +resource "tencentcloud_as_load_balancer" "example" { + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + load_balancer_ids = [tencentcloud_clb_instance.example.id] +} +``` + +If use `forward_load_balancers` + ```hcl -resource "tencentcloud_as_load_balancer" "load_balancer" { - auto_scaling_group_id = "asg-12wjuh0s" +resource "tencentcloud_as_load_balancer" "example" { + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + forward_load_balancers { - load_balancer_id = "lb-d8u76te5" - listener_id = "lbl-s8dh4y75" + load_balancer_id = tencentcloud_clb_instance.example.id + listener_id = tencentcloud_clb_listener.example.listener_id + location_id = tencentcloud_clb_listener_rule.example.rule_id + target_attributes { port = 8080 weight = 20 } - location_id = "loc-fsa87u6d" - region = "ap-guangzhou" } } ``` diff --git a/tencentcloud/resource_tc_as_notification.go b/tencentcloud/resource_tc_as_notification.go index 4c490828c5..d03b0a1688 100644 --- a/tencentcloud/resource_tc_as_notification.go +++ b/tencentcloud/resource_tc_as_notification.go @@ -4,10 +4,56 @@ Provides a resource for an AS (Auto scaling) notification. Example Usage ```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)" +} + +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_cam_group" "example" { + name = "tf-example" + remark = "desc." +} + resource "tencentcloud_as_notification" "as_notification" { - scaling_group_id = "sg-12af45" - notification_types = ["SCALE_OUT_FAILED", "SCALE_IN_SUCCESSFUL", "SCALE_IN_FAILED", "REPLACE_UNHEALTHY_INSTANCE_FAILED"] - notification_user_group_ids = ["76955"] + scaling_group_id = tencentcloud_as_scaling_group.example.id + notification_types = [ + "SCALE_OUT_SUCCESSFUL", "SCALE_OUT_FAILED", "SCALE_IN_FAILED", "REPLACE_UNHEALTHY_INSTANCE_SUCCESSFUL", "REPLACE_UNHEALTHY_INSTANCE_FAILED" + ] + notification_user_group_ids = [tencentcloud_cam_group.example.id] } ``` */ @@ -114,7 +160,7 @@ func resourceTencentCloudAsNotificationRead(d *schema.ResourceData, meta interfa return nil } _ = d.Set("scaling_group_id", *notification.AutoScalingGroupId) - _ = d.Set("notification_type", helper.StringsInterfaces(notification.NotificationTypes)) + _ = d.Set("notification_types", helper.StringsInterfaces(notification.NotificationTypes)) _ = d.Set("notification_user_group_ids", helper.StringsInterfaces(notification.NotificationUserGroupIds)) return nil }) @@ -132,7 +178,7 @@ func resourceTencentCloudAsNotificationUpdate(d *schema.ResourceData, meta inter request := as.NewModifyNotificationConfigurationRequest() notificationId := d.Id() request.AutoScalingNotificationId = ¬ificationId - if d.HasChange("notification_type") { + if d.HasChange("notification_types") { notificationTypes := d.Get("notification_types").([]interface{}) request.NotificationTypes = make([]*string, 0, len(notificationTypes)) for _, value := range notificationTypes { diff --git a/tencentcloud/resource_tc_as_protect_instances.go b/tencentcloud/resource_tc_as_protect_instances.go index c3d0fe290e..404f6bf2ac 100644 --- a/tencentcloud/resource_tc_as_protect_instances.go +++ b/tencentcloud/resource_tc_as_protect_instances.go @@ -4,13 +4,97 @@ Provides a resource to create a as protect_instances Example Usage ```hcl -resource "tencentcloud_as_protect_instances" "protect_instances" { - auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - instance_ids = ["ins-xxxxx"] +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 } ``` +Or close protect + +```hcl +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 = false +} +``` + */ package tencentcloud diff --git a/tencentcloud/resource_tc_as_remove_instances.go b/tencentcloud/resource_tc_as_remove_instances.go index 38d1669333..864ec0741a 100644 --- a/tencentcloud/resource_tc_as_remove_instances.go +++ b/tencentcloud/resource_tc_as_remove_instances.go @@ -4,9 +4,83 @@ Provides a resource to create a as remove_instances Example Usage ```hcl -resource "tencentcloud_as_remove_instances" "remove_instances" { - auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - instance_ids = ["ins-xxxxxx"] +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] +} + +# Remove Instance +resource "tencentcloud_as_remove_instances" "remove" { + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = tencentcloud_as_attachment.attachment.instance_ids } ``` */ diff --git a/tencentcloud/resource_tc_as_scale_in_instances.go b/tencentcloud/resource_tc_as_scale_in_instances.go index ee5d42fb24..1b17fe3541 100644 --- a/tencentcloud/resource_tc_as_scale_in_instances.go +++ b/tencentcloud/resource_tc_as_scale_in_instances.go @@ -4,9 +4,49 @@ Provides a resource to create a as scale_in_instances Example Usage ```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)" +} + +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 = 4 + min_size = 1 + desired_capacity = 2 + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] +} + resource "tencentcloud_as_scale_in_instances" "scale_in_instances" { - auto_scaling_group_id = "asg-519acdug" - scale_in_number = 1 + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + scale_in_number = 1 } ``` diff --git a/tencentcloud/resource_tc_as_scale_out_instances.go b/tencentcloud/resource_tc_as_scale_out_instances.go index 9aed0560d3..e0f23d7647 100644 --- a/tencentcloud/resource_tc_as_scale_out_instances.go +++ b/tencentcloud/resource_tc_as_scale_out_instances.go @@ -4,9 +4,49 @@ Provides a resource to create a as scale_out_instances Example Usage ```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)" +} + +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 = 4 + min_size = 0 + desired_capacity = 2 + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] +} + resource "tencentcloud_as_scale_out_instances" "scale_out_instances" { - auto_scaling_group_id = "asg-519acdug" - scale_out_number = 1 + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + scale_out_number = 2 } ``` diff --git a/tencentcloud/resource_tc_as_scaling_config.go b/tencentcloud/resource_tc_as_scaling_config.go index 4a03d16a69..aef09afa0e 100644 --- a/tencentcloud/resource_tc_as_scaling_config.go +++ b/tencentcloud/resource_tc_as_scaling_config.go @@ -3,13 +3,17 @@ Provides a resource to create a configuration for an AS (Auto scaling) instance. ~> **NOTE:** In order to ensure the integrity of customer data, if the cvm instance was destroyed due to shrinking, it will keep the cbs associate with cvm by default. If you want to destroy together, please set `delete_with_instance` to `true`. - Example Usage ```hcl -resource "tencentcloud_as_scaling_config" "launch_configuration" { - configuration_name = "launch-configuration" - image_id = "img-9qabwvbn" +data "tencentcloud_images" "example" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +resource "tencentcloud_as_scaling_config" "example" { + configuration_name = "example-launch-configuration" + image_id = data.tencentcloud_images.example.images.0.image_id instance_types = ["SA1.SMALL1"] project_id = 0 system_disk_type = "CLOUD_PREMIUM" @@ -23,26 +27,32 @@ resource "tencentcloud_as_scaling_config" "launch_configuration" { internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR" internet_max_bandwidth_out = 10 public_ip_assigned = true - password = "test123#" + password = "Test@123#" enhanced_security_service = false enhanced_monitor_service = false user_data = "dGVzdA==" instance_tags = { - tag = "as" + tag = "example" } } ``` -Using SPOT charge type +Using `SPOTPAID` charge type + ``` -resource "tencentcloud_as_scaling_config" "launch_configuration" { - configuration_name = "launch-configuration" - image_id = "img-9qabwvbn" - instance_types = ["SA1.SMALL1"] +data "tencentcloud_images" "example" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +resource "tencentcloud_as_scaling_config" "example" { + configuration_name = "launch-configuration" + image_id = data.tencentcloud_images.example.images.0.image_id + instance_types = ["SA1.SMALL1"] instance_charge_type = "SPOTPAID" - spot_instance_type = "one-time" - spot_max_price = "1000" + spot_instance_type = "one-time" + spot_max_price = "1000" } ``` diff --git a/tencentcloud/resource_tc_as_scaling_group.go b/tencentcloud/resource_tc_as_scaling_group.go index f2224b528b..afce21fb6a 100644 --- a/tencentcloud/resource_tc_as_scaling_group.go +++ b/tencentcloud/resource_tc_as_scaling_group.go @@ -3,14 +3,85 @@ Provides a resource to create a group of AS (Auto scaling) instances. Example Usage +Create a basic Scaling Group + +```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)" +} + +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] +} +``` + +Create a complete Scaling Group + ```hcl -resource "tencentcloud_as_scaling_group" "scaling_group" { - scaling_group_name = "tf-as-scaling-group" - configuration_id = "asc-oqio4yyj" +resource "tencentcloud_clb_instance" "example" { + network_type = "INTERNAL" + clb_name = "clb-example" + project_id = 0 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + + tags = { + test = "tf" + } +} + +resource "tencentcloud_clb_listener" "example" { + clb_id = tencentcloud_clb_instance.example.id + listener_name = "listener-example" + port = 80 + protocol = "HTTP" +} + +resource "tencentcloud_clb_listener_rule" "example" { + listener_id = tencentcloud_clb_listener.example.listener_id + clb_id = tencentcloud_clb_instance.example.id + domain = "foo.net" + url = "/bar" +} + +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 = "vpc-3efmz0z" - subnet_ids = ["subnet-mc3egos"] + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] project_id = 0 default_cooldown = 400 desired_capacity = 1 @@ -18,15 +89,19 @@ resource "tencentcloud_as_scaling_group" "scaling_group" { retry_policy = "INCREMENTAL_INTERVALS" forward_balancer_ids { - load_balancer_id = "lb-hk693b1l" - listener_id = "lbl-81wr497k" - rule_id = "loc-kiodx943" + load_balancer_id = tencentcloud_clb_instance.example.id + listener_id = tencentcloud_clb_listener.example.listener_id + rule_id = tencentcloud_clb_listener_rule.example.rule_id target_attribute { port = 80 weight = 90 } } + + tags = { + "createBy" = "tfExample" + } } ``` diff --git a/tencentcloud/resource_tc_as_scaling_group_status.go b/tencentcloud/resource_tc_as_scaling_group_status.go index 95a3f7b99c..cbd16e6755 100644 --- a/tencentcloud/resource_tc_as_scaling_group_status.go +++ b/tencentcloud/resource_tc_as_scaling_group_status.go @@ -3,13 +3,63 @@ Provides a resource to set as scaling_group status Example Usage +Deactivate Scaling Group + ```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)" +} + +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_as_scaling_group_status" "scaling_group_status" { - auto_scaling_group_id = "asg-519acdug" + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id enable = false } ``` +Enable Scaling Group + +```hcl +resource "tencentcloud_as_scaling_group_status" "scaling_group_status" { + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + enable = true +} +``` + Import as scaling_group_status can be imported using the id, e.g. diff --git a/tencentcloud/resource_tc_as_scaling_policy.go b/tencentcloud/resource_tc_as_scaling_policy.go index 3c83c39b37..5e00f741eb 100644 --- a/tencentcloud/resource_tc_as_scaling_policy.go +++ b/tencentcloud/resource_tc_as_scaling_policy.go @@ -4,8 +4,47 @@ Provides a resource for an AS (Auto scaling) policy. Example Usage ```hcl -resource "tencentcloud_as_scaling_policy" "scaling_policy" { - scaling_group_id = "asg-n32ymck2" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "as" +} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +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_as_scaling_policy" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id policy_name = "tf-as-scaling-policy" adjustment_type = "EXACT_CAPACITY" adjustment_value = 0 diff --git a/tencentcloud/resource_tc_as_schedule.go b/tencentcloud/resource_tc_as_schedule.go index a1d9889b72..d4964c5c4f 100644 --- a/tencentcloud/resource_tc_as_schedule.go +++ b/tencentcloud/resource_tc_as_schedule.go @@ -4,8 +4,47 @@ Provides a resource for an AS (Auto scaling) schedule. Example Usage ```hcl -resource "tencentcloud_as_schedule" "schedule" { - scaling_group_id = "sg-12af45" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "as" +} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +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_as_schedule" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id schedule_action_name = "tf-as-schedule" max_size = 10 min_size = 0 diff --git a/tencentcloud/resource_tc_as_start_instances.go b/tencentcloud/resource_tc_as_start_instances.go index b7d3e1170a..d36c78c3a1 100644 --- a/tencentcloud/resource_tc_as_start_instances.go +++ b/tencentcloud/resource_tc_as_start_instances.go @@ -4,10 +4,84 @@ Provides a resource to create a as start_instances Example Usage ```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.scaling_group.id - instance_ids = ["ins-xxxxx"] + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = tencentcloud_as_attachment.attachment.instance_ids } + ``` */ diff --git a/tencentcloud/resource_tc_as_stop_instances.go b/tencentcloud/resource_tc_as_stop_instances.go index 75675b0a8d..763da8aa7c 100644 --- a/tencentcloud/resource_tc_as_stop_instances.go +++ b/tencentcloud/resource_tc_as_stop_instances.go @@ -4,10 +4,83 @@ Provides a resource to create a as stop_instances Example Usage ```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_stop_instances" "stop_instances" { - auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - instance_ids = ["ins-xxxx"] - stopped_mode = "STOP_CHARGING" + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = tencentcloud_as_attachment.attachment.instance_ids + stopped_mode = "STOP_CHARGING" } ``` diff --git a/tencentcloud/resource_tc_dnat.go b/tencentcloud/resource_tc_dnat.go index 929148423a..a06c660042 100644 --- a/tencentcloud/resource_tc_dnat.go +++ b/tencentcloud/resource_tc_dnat.go @@ -4,15 +4,80 @@ Provides a resource to create a NAT forwarding. Example Usage ```hcl -resource "tencentcloud_dnat" "foo" { - vpc_id = "vpc-asg3sfa3" - nat_id = "nat-2515tdg" - protocol = "tcp" - elastic_ip = "139.199.232.238" +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "example" { + 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.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" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "example-vpc" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eip" "eip_example" { + name = "tf_nat_gateway_eip" +} + +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 + assigned_eip_set = [ + tencentcloud_eip.eip_example.public_ip, + ] + tags = { + tf_tag_key = "tf_tag_value" + } +} + +resource "tencentcloud_instance" "example" { + instance_name = "tf_example_instance" + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + image_id = data.tencentcloud_images.example.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 + allocate_public_ip = true + internet_max_bandwidth_out = 10 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + +resource "tencentcloud_dnat" "example" { + vpc_id = tencentcloud_vpc.vpc.id + nat_id = tencentcloud_nat_gateway.example.id + protocol = "TCP" + elastic_ip = tencentcloud_eip.eip_example.public_ip elastic_port = 80 - private_ip = "10.0.0.1" - private_port = 22 - description = "test" + private_ip = tencentcloud_instance.example.private_ip + private_port = 9090 + description = "desc." } ``` diff --git a/tencentcloud/resource_tc_mysql_account.go b/tencentcloud/resource_tc_mysql_account.go index 016fb3022a..4fc9f5feea 100644 --- a/tencentcloud/resource_tc_mysql_account.go +++ b/tencentcloud/resource_tc_mysql_account.go @@ -4,11 +4,59 @@ Provides a MySQL account resource for database management. A MySQL instance supp Example Usage ```hcl -resource "tencentcloud_mysql_account" "default" { - mysql_id = "terraform-test-local-database" - name = "tf_test" - password = "********" - description = "My test account" +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_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." max_user_connections = 10 } ``` diff --git a/tencentcloud/resource_tc_mysql_account_privilege.go b/tencentcloud/resource_tc_mysql_account_privilege.go index e092cf6515..e12d522a03 100644 --- a/tencentcloud/resource_tc_mysql_account_privilege.go +++ b/tencentcloud/resource_tc_mysql_account_privilege.go @@ -6,11 +6,67 @@ Provides a mysql account privilege resource to grant different access privilege Example Usage ```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_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." + max_user_connections = 10 +} + resource "tencentcloud_mysql_account_privilege" "default" { - mysql_id = "terraform-test-local-database" - account_name = "tf_account" - privileges = ["SELECT"] - database_names = ["instance.name"] + mysql_id = tencentcloud_mysql_instance.example.id + account_name = tencentcloud_mysql_account.example.name + privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"] + database_names = ["dbname1", "dbname2"] } ``` */ diff --git a/tencentcloud/resource_tc_mysql_audit_log_file.go b/tencentcloud/resource_tc_mysql_audit_log_file.go index 257a306adb..9e10aacb2d 100644 --- a/tencentcloud/resource_tc_mysql_audit_log_file.go +++ b/tencentcloud/resource_tc_mysql_audit_log_file.go @@ -4,12 +4,73 @@ Provides a resource to create a mysql audit_log_file Example Usage ```hcl -resource "tencentcloud_mysql_audit_log_file" "audit_log_file" { - instance_id = "cdb-fitq5t9h" - start_time = "2023-03-28 20:14:00" - end_time = "2023-03-29 20:14:00" +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_audit_log_file" "example" { + instance_id = tencentcloud_mysql_instance.example.id + start_time = "2023-07-01 00:00:00" + end_time = "2023-10-01 00:00:00" + order = "ASC" + order_by = "timestamp" +} +``` + +Add filter + +```hcl +resource "tencentcloud_mysql_audit_log_file" "example" { + instance_id = tencentcloud_mysql_instance.example.id + start_time = "2023-07-01 00:00:00" + end_time = "2023-10-01 00:00:00" order = "ASC" order_by = "timestamp" + filter { host = ["30.50.207.46"] user = ["keep_dbbrain"] diff --git a/tencentcloud/resource_tc_mysql_backup_download_restriction.go b/tencentcloud/resource_tc_mysql_backup_download_restriction.go index 0aa08d08a5..b87d1dfc68 100644 --- a/tencentcloud/resource_tc_mysql_backup_download_restriction.go +++ b/tencentcloud/resource_tc_mysql_backup_download_restriction.go @@ -4,15 +4,15 @@ Provides a resource to create a mysql backup_download_restriction Example Usage ```hcl -resource "tencentcloud_mysql_backup_download_restriction" "backup_download_restriction" { - limit_type = "Customize" - vpc_comparison_symbol = "In" - ip_comparison_symbol = "In" - limit_vpc { - region = "ap-guangzhou" - vpc_list = ["vpc-4owdpnwr"] - } - limit_ip = ["127.0.0.1"] +resource "tencentcloud_mysql_backup_download_restriction" "example" { + limit_type = "Customize" + vpc_comparison_symbol = "In" + ip_comparison_symbol = "In" + limit_vpc { + region = "ap-guangzhou" + vpc_list = ["vpc-4owdpnwr"] + } + limit_ip = ["127.0.0.1"] } ``` diff --git a/tencentcloud/resource_tc_mysql_backup_encryption_status.go b/tencentcloud/resource_tc_mysql_backup_encryption_status.go index 4d6af7e0d3..6397fc7163 100644 --- a/tencentcloud/resource_tc_mysql_backup_encryption_status.go +++ b/tencentcloud/resource_tc_mysql_backup_encryption_status.go @@ -3,13 +3,72 @@ Provides a resource to create a mysql backup_encryption_status Example Usage +Enable encryption + ```hcl -resource "tencentcloud_mysql_backup_encryption_status" "backup_encryption_status" { - instance_id = "cdb-c1nl9rpv" +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_backup_encryption_status" "example" { + instance_id = tencentcloud_mysql_instance.example.id encryption_status = "on" } ``` +Disable encryption + +```hcl +resource "tencentcloud_mysql_backup_encryption_status" "example" { + instance_id = tencentcloud_mysql_instance.example.id + encryption_status = "off" +} +``` + Import mysql backup_encryption_status can be imported using the id, e.g. diff --git a/tencentcloud/resource_tc_mysql_backup_policy.go b/tencentcloud/resource_tc_mysql_backup_policy.go index ac13c65c2b..e9312e942f 100644 --- a/tencentcloud/resource_tc_mysql_backup_policy.go +++ b/tencentcloud/resource_tc_mysql_backup_policy.go @@ -6,11 +6,59 @@ Provides a mysql policy resource to create a backup policy. Example Usage ```hcl -resource "tencentcloud_mysql_backup_policy" "default" { - mysql_id = "cdb-dnqksd9f" +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_backup_policy" "example" { + mysql_id = tencentcloud_mysql_instance.example.id retention_period = 7 backup_model = "physical" - backup_time = "02:00-06:00" + backup_time = "01:00-05:00" } ``` */ diff --git a/tencentcloud/resource_tc_mysql_db_import_job_operation.go b/tencentcloud/resource_tc_mysql_db_import_job_operation.go index e1e1d317cf..e67fc34f25 100644 --- a/tencentcloud/resource_tc_mysql_db_import_job_operation.go +++ b/tencentcloud/resource_tc_mysql_db_import_job_operation.go @@ -4,13 +4,69 @@ Provides a resource to create a mysql db_import_job_operation Example Usage ```hcl -resource "tencentcloud_mysql_db_import_job_operation" "db_import_job_operation" { - instance_id = "cdb-c1nl9rpv" - user = "root" - file_name = "mysql.sql" - password = "ABCabc123" - db_name = "t_test" - cos_url = "https://terraform-ci-1308919341.cos.ap-guangzhou.myqcloud.com/mysql/mysql.sql?q-sign-algorithm=sha1&q-ak=AKIDRnMWiUNr14F29GvCwOSHu9l_FdCdORqAxblrE10nDaO6mVI701oXTe-gL1QpClgW&q-sign-time=1684921483;1684925083&q-key-time=1684921483;1684925083&q-header-list=host&q-url-param-list=&q-signature=7410be4ef93075aebca459af4e617f8bcaa36f48&x-cos-security-token=EzDm9S6aRDwBLQcaxUNfb0TA30PqhOTa7d82a06a36e94b66bdbc6d09064a397bZypr0mD3oVkbJR9bRYix6BSDVYncX3Y2VCGYK6V2jFWZqIuEHoWJCe-2pDvJDNbMjF3ttWfLMqEouOkxNk28ay9NPHtMXrJgEEMb95BMAhGwi38oA2LjYfQRkk7AHesg2toSf11hiTAjVv-alf5uEidWGnFKe_6BgmnADYvtPptgXHNtsUZCxc33PF6tGBqX" +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_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." + max_user_connections = 10 +} + +resource "tencentcloud_mysql_db_import_job_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id + user = tencentcloud_mysql_account.example.name + password = tencentcloud_mysql_account.example.password + db_name = "tf_example_db" + file_name = "tf_mysql.sql" + cos_url = "https://terraform-ci-1308919341.cos.ap-guangzhou.myqcloud.com/mysql/mysql.sql?q-sign-algorithm=sha1&q-ak=AKIDRnMWiUNr14F29GvCwOSHu9l_FdCdORqAxblrE10nDaO6mVI701oXTe-gL1QpClgW&q-sign-time=1684921483;1684925083&q-key-time=1684921483;1684925083&q-header-list=host&q-url-param-list=&q-signature=7410be4ef93075aebca459af4e617f8bcaa36f48&x-cos-security-token=EzDm9S6aRDwBLQcaxUNfb0TA30PqhOTa7d82a06a36e94b66bdbc6d09064a397bZypr0mD3oVkbJR9bRYix6BSDVYncX3Y2VCGYK6V2jFWZqIuEHoWJCe-2pDvJDNbMjF3ttWfLMqEouOkxNk28ay9NPHtMXrJgEEMb95BMAhGwi38oA2LjYfQRkk7AHesg2toSf11hiTAjVv-alf5uEidWGnFKe_6BgmnADYvtPptgXHNtsUZCxc33PF6tGBqX" } ``` diff --git a/tencentcloud/resource_tc_mysql_deploy_group.go b/tencentcloud/resource_tc_mysql_deploy_group.go index a76c1d7679..12d1fc07b3 100644 --- a/tencentcloud/resource_tc_mysql_deploy_group.go +++ b/tencentcloud/resource_tc_mysql_deploy_group.go @@ -4,9 +4,9 @@ Provides a resource to create a mysql deploy_group Example Usage ```hcl -resource "tencentcloud_mysql_deploy_group" "deploy_group" { - deploy_group_name = "terrform-deploy" - description = "deploy test" +resource "tencentcloud_mysql_deploy_group" "example" { + deploy_group_name = "tf-example" + description = "desc." limit_num = 1 dev_class = ["TS85"] } diff --git a/tencentcloud/resource_tc_mysql_dr_instance_to_mater.go b/tencentcloud/resource_tc_mysql_dr_instance_to_mater.go index 718b902290..25d292456e 100644 --- a/tencentcloud/resource_tc_mysql_dr_instance_to_mater.go +++ b/tencentcloud/resource_tc_mysql_dr_instance_to_mater.go @@ -4,8 +4,56 @@ Provides a resource to create a mysql dr_instance_to_mater Example Usage ```hcl -resource "tencentcloud_mysql_dr_instance_to_mater" "dr_instance_to_mater" { - instance_id = "cdb-c1nl9rpv" +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_dr_instance_to_mater" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` diff --git a/tencentcloud/resource_tc_mysql_instance.go b/tencentcloud/resource_tc_mysql_instance.go index 6c4ba6cbe0..105cf9be02 100644 --- a/tencentcloud/resource_tc_mysql_instance.go +++ b/tencentcloud/resource_tc_mysql_instance.go @@ -3,35 +3,121 @@ Provides a mysql instance resource to create master database instances. ~> **NOTE:** If this mysql has readonly instance, the terminate operation of the mysql does NOT take effect immediately, maybe takes for several hours. so during that time, VPCs associated with that mysql instance can't be terminated also. +~> **NOTE:** The value of parameter `parameters` can be used with tencentcloud_mysql_parameter_list to obtain. + Example Usage +Create a single node instance + ```hcl -resource "tencentcloud_mysql_instance" "default" { - internet_service = 1 - engine_version = "5.7" - charge_type = "POSTPAID" - root_password = "********" +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 - first_slave_zone = "ap-guangzhou-4" - second_slave_zone = "ap-guangzhou-4" + 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" + } +} +``` + +Create a double node instance + +```hcl +resource "tencentcloud_mysql_instance" "example" { + internet_service = 1 + engine_version = "5.7" + charge_type = "POSTPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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" + } +} +``` + +Create a three node instance + +```hcl +resource "tencentcloud_mysql_instance" "example" { + internet_service = 1 + engine_version = "5.7" + charge_type = "POSTPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.name + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.name slave_sync_mode = 1 - availability_zone = "ap-guangzhou-4" - project_id = 201901010001 - instance_name = "myTestMysql" - mem_size = 128000 - volume_size = 250 - vpc_id = "vpc-12mt3l31" - subnet_id = "subnet-9uivyb1g" + 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 = ["sg-ot8eclwz"] + security_groups = [tencentcloud_security_group.security_group.id] tags = { name = "test" } parameters = { - character_set_server = "UTF8" - max_connections = "1000" + character_set_server = "utf8" + max_connections = "1000" } } ``` diff --git a/tencentcloud/resource_tc_mysql_instance_encryption_operation.go b/tencentcloud/resource_tc_mysql_instance_encryption_operation.go index dbe0eef8af..694c8a623c 100644 --- a/tencentcloud/resource_tc_mysql_instance_encryption_operation.go +++ b/tencentcloud/resource_tc_mysql_instance_encryption_operation.go @@ -4,10 +4,58 @@ Provides a resource to create a mysql instance_encryption_operation Example Usage ```hcl -resource "tencentcloud_mysql_instance_encryption_operation" "instance_encryption_operation" { - instance_id = tencentcloud_mysql_instance.this.id - key_id = "KMS-CDB" - key_region = "ap-guangzhou" +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_instance_encryption_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id + key_id = "KMS-CDB" + key_region = "ap-guangzhou" } ``` diff --git a/tencentcloud/resource_tc_mysql_isolate_instance.go b/tencentcloud/resource_tc_mysql_isolate_instance.go index 0b65181e65..4a5b360782 100644 --- a/tencentcloud/resource_tc_mysql_isolate_instance.go +++ b/tencentcloud/resource_tc_mysql_isolate_instance.go @@ -4,8 +4,56 @@ Provides a resource to create a mysql isolate_instance Example Usage ```hcl -resource "tencentcloud_mysql_isolate_instance" "isolate_instance" { - instance_id = "cdb-1tru99al" +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_isolate_instance" "example" { + instance_id = tencentcloud_mysql_instance.example.id operate = "recover" } ``` diff --git a/tencentcloud/resource_tc_mysql_local_binlog_config.go b/tencentcloud/resource_tc_mysql_local_binlog_config.go index 3d76ac3584..f9c4918701 100644 --- a/tencentcloud/resource_tc_mysql_local_binlog_config.go +++ b/tencentcloud/resource_tc_mysql_local_binlog_config.go @@ -4,10 +4,58 @@ Provides a resource to create a mysql local_binlog_config Example Usage ```hcl -resource "tencentcloud_mysql_local_binlog_config" "local_binlog_config" { - instance_id = "cdb-fitq5t9h" - save_hours = 140 - max_usage = 50 +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 } ``` diff --git a/tencentcloud/resource_tc_mysql_param_template.go b/tencentcloud/resource_tc_mysql_param_template.go index 5529df1fbe..bdbbc6ca42 100644 --- a/tencentcloud/resource_tc_mysql_param_template.go +++ b/tencentcloud/resource_tc_mysql_param_template.go @@ -4,9 +4,57 @@ Provides a resource to create a mysql param template Example Usage ```hcl -resource "tencentcloud_mysql_param_template" "param_template" { - name = "terraform-test" - description = "terraform-test" +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_param_template" "example" { + name = "tf-example" + description = "desc." engine_version = "8.0" param_list { current_value = "1" diff --git a/tencentcloud/resource_tc_mysql_password_complexity.go b/tencentcloud/resource_tc_mysql_password_complexity.go index 41b413d0c2..d79e5dc40a 100644 --- a/tencentcloud/resource_tc_mysql_password_complexity.go +++ b/tencentcloud/resource_tc_mysql_password_complexity.go @@ -4,24 +4,72 @@ Provides a resource to create a mysql password_complexity Example Usage ```hcl -resource "tencentcloud_mysql_password_complexity" "password_complexity" { - instance_id = var.instance_id - param_list { - name = "validate_password_length" - current_value = "8" - } - param_list { - name = "validate_password_mixed_case_count" - current_value = "2" - } - param_list { - name = "validate_password_number_count" - current_value = "2" - } - param_list { - name = "validate_password_special_char_count" - current_value = "2" - } +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_password_complexity" "example" { + instance_id = tencentcloud_mysql_instance.example.id + param_list { + name = "validate_password_length" + current_value = "8" + } + param_list { + name = "validate_password_mixed_case_count" + current_value = "2" + } + param_list { + name = "validate_password_number_count" + current_value = "2" + } + param_list { + name = "validate_password_special_char_count" + current_value = "2" + } } ``` diff --git a/tencentcloud/resource_tc_mysql_privilege.go b/tencentcloud/resource_tc_mysql_privilege.go index df2f7184f4..6d4f74ab74 100644 --- a/tencentcloud/resource_tc_mysql_privilege.go +++ b/tencentcloud/resource_tc_mysql_privilege.go @@ -4,27 +4,65 @@ Provides a mysql account privilege resource to grant different access privilege Example Usage ```hcl -resource "tencentcloud_mysql_instance" "default" { - mem_size = 1000 - volume_size = 25 - instance_name = "guagua" - engine_version = "5.7" - root_password = "0153Y474" - availability_zone = "ap-guangzhou-3" +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_account" "mysql_account2" { - mysql_id = tencentcloud_mysql_instance.default.id - name = "test11" - password = "test1234" - description = "test from terraform" +resource "tencentcloud_mysql_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." + max_user_connections = 10 } -resource "tencentcloud_mysql_privilege" "tttt" { - mysql_id = tencentcloud_mysql_instance.default.id - account_name = tencentcloud_mysql_account.mysql_account2.name +resource "tencentcloud_mysql_privilege" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + account_name = tencentcloud_mysql_account.example.name global = ["TRIGGER"] database { privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE"] diff --git a/tencentcloud/resource_tc_mysql_proxy.go b/tencentcloud/resource_tc_mysql_proxy.go index d32700e1c5..5e9cef7d23 100644 --- a/tencentcloud/resource_tc_mysql_proxy.go +++ b/tencentcloud/resource_tc_mysql_proxy.go @@ -4,10 +4,59 @@ Provides a resource to create a mysql proxy Example Usage ```hcl -resource "tencentcloud_mysql_proxy" "proxy" { - instance_id = "cdb-fitq5t9h" - uniq_vpc_id = "vpc-4owdpnwr" - uniq_subnet_id = "subnet-ahv6swf2" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id proxy_node_custom { node_count = 1 cpu = 2 @@ -15,10 +64,10 @@ resource "tencentcloud_mysql_proxy" "proxy" { region = "ap-guangzhou" zone = "ap-guangzhou-3" } - security_group = ["sg-edmur627"] - desc = "desc1" + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." connection_pool_limit = 2 - vip = "172.16.17.101" + vip = "10.0.0.120" vport = 3306 } ``` @@ -455,6 +504,8 @@ func resourceTencentCloudMysqlProxyUpdate(d *schema.ResourceData, meta interface } request.ProxyNodeCustom = append(request.ProxyNodeCustom, &proxyNodeCustom) } + request.ReloadBalance = helper.String("auto") + request.UpgradeTime = helper.String("nowTime") } err = resource.Retry(writeRetryTimeout, func() *resource.RetryError { diff --git a/tencentcloud/resource_tc_mysql_readonly_instance.go b/tencentcloud/resource_tc_mysql_readonly_instance.go index 6bfaa27041..e3f76e3ace 100644 --- a/tencentcloud/resource_tc_mysql_readonly_instance.go +++ b/tencentcloud/resource_tc_mysql_readonly_instance.go @@ -7,18 +7,66 @@ Provides a mysql instance resource to create read-only database instances. Example Usage ```hcl -resource "tencentcloud_mysql_readonly_instance" "default" { - master_instance_id = "cdb-dnqksd9f" - instance_name = "myTestMysql" +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_readonly_instance" "example" { + master_instance_id = tencentcloud_mysql_instance.example.id + instance_name = "tf-example" mem_size = 128000 volume_size = 255 - vpc_id = "vpc-12mt3l31" - subnet_id = "subnet-9uivyb1g" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id intranet_port = 3306 - security_groups = ["sg-ot8eclwz"] + security_groups = [tencentcloud_security_group.security_group.id] tags = { - name = "test" + createBy = "terraform" } } ``` diff --git a/tencentcloud/resource_tc_mysql_reload_balance_proxy_node.go b/tencentcloud/resource_tc_mysql_reload_balance_proxy_node.go index 2b9dd712f8..c257a1fe85 100644 --- a/tencentcloud/resource_tc_mysql_reload_balance_proxy_node.go +++ b/tencentcloud/resource_tc_mysql_reload_balance_proxy_node.go @@ -4,9 +4,76 @@ Provides a resource to create a mysql reload_balance_proxy_node Example Usage ```hcl -resource "tencentcloud_mysql_reload_balance_proxy_node" "reload_balance_proxy_node" { - proxy_group_id = "proxy-gmi1f78l" - proxy_address_id = "proxyaddr-4wc4y1pq" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 1 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + +resource "tencentcloud_mysql_reload_balance_proxy_node" "example" { + proxy_group_id = tencentcloud_mysql_proxy.example.proxy_group_id + proxy_address_id = tencentcloud_mysql_proxy.example.proxy_address_id } ``` */ diff --git a/tencentcloud/resource_tc_mysql_remote_backup_config.go b/tencentcloud/resource_tc_mysql_remote_backup_config.go index 2c24414109..9fd58da759 100644 --- a/tencentcloud/resource_tc_mysql_remote_backup_config.go +++ b/tencentcloud/resource_tc_mysql_remote_backup_config.go @@ -4,12 +4,60 @@ Provides a resource to create a mysql remote_backup_config Example Usage ```hcl -resource "tencentcloud_mysql_remote_backup_config" "remote_backup_config" { - instance_id = "cdb-c1nl9rpv" +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_remote_backup_config" "example" { + instance_id = tencentcloud_mysql_instance.example.id remote_backup_save = "on" remote_binlog_save = "on" - remote_region = ["ap-shanghai"] - expire_days = 7 + remote_region = ["ap-shanghai"] + expire_days = 7 } ``` diff --git a/tencentcloud/resource_tc_mysql_renew_db_instance_operation.go b/tencentcloud/resource_tc_mysql_renew_db_instance_operation.go index 428f5b42be..d95ce5a1d9 100644 --- a/tencentcloud/resource_tc_mysql_renew_db_instance_operation.go +++ b/tencentcloud/resource_tc_mysql_renew_db_instance_operation.go @@ -4,9 +4,62 @@ Provides a resource to create a mysql renew_db_instance_operation Example Usage ```hcl -resource "tencentcloud_mysql_renew_db_instance_operation" "renew_db_instance_operation" { - instance_id = "cdb-c1nl9rpv" - time_span = 1 +data "tencentcloud_availability_zones_by_product" "zones" { + product = "cdb" +} + +data "tencentcloud_mysql_rollback_range_time" "example" { + instance_ids = [tencentcloud_mysql_instance.example.id] +} + +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 = "PREPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_renew_db_instance_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id + time_span = 1 modify_pay_type = "PREPAID" } ``` diff --git a/tencentcloud/resource_tc_mysql_reset_root_account.go b/tencentcloud/resource_tc_mysql_reset_root_account.go index 69aecd26bd..8a2a7fa840 100644 --- a/tencentcloud/resource_tc_mysql_reset_root_account.go +++ b/tencentcloud/resource_tc_mysql_reset_root_account.go @@ -4,8 +4,57 @@ Provides a resource to create a mysql reset_root_account Example Usage ```hcl -resource "tencentcloud_mysql_reset_root_account" "reset_root_account" { - instance_id = "cdb-fitq5t9h" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_reset_root_account" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` */ diff --git a/tencentcloud/resource_tc_mysql_restart_db_instances_operation.go b/tencentcloud/resource_tc_mysql_restart_db_instances_operation.go index 6745f73703..c102f1560f 100644 --- a/tencentcloud/resource_tc_mysql_restart_db_instances_operation.go +++ b/tencentcloud/resource_tc_mysql_restart_db_instances_operation.go @@ -4,8 +4,56 @@ Provides a resource to create a mysql restart_db_instances_operation Example Usage ```hcl -resource "tencentcloud_mysql_restart_db_instances_operation" "restart_db_instances_operation" { - instance_id = "cdb-bohspx3j" +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_restart_db_instances_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` diff --git a/tencentcloud/resource_tc_mysql_ro_group.go b/tencentcloud/resource_tc_mysql_ro_group.go index ec189cbcc4..659d60a73a 100644 --- a/tencentcloud/resource_tc_mysql_ro_group.go +++ b/tencentcloud/resource_tc_mysql_ro_group.go @@ -4,7 +4,7 @@ Provides a resource to create a mysql ro_group Example Usage ```hcl -resource "tencentcloud_mysql_ro_group" "ro_group" { +resource "tencentcloud_mysql_ro_group" "example" { instance_id = "cdb-e8i766hx" ro_group_id = "cdbrg-f49t0gnj" ro_group_info { diff --git a/tencentcloud/resource_tc_mysql_ro_group_load_operation.go b/tencentcloud/resource_tc_mysql_ro_group_load_operation.go index cb44e70757..a07266e6e5 100644 --- a/tencentcloud/resource_tc_mysql_ro_group_load_operation.go +++ b/tencentcloud/resource_tc_mysql_ro_group_load_operation.go @@ -4,8 +4,77 @@ Provides a resource to create a mysql ro_group_load_operation Example Usage ```hcl +data "tencentcloud_availability_zones_by_product" "zones" { + product = "cdb" +} + +data "tencentcloud_mysql_instance" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + + depends_on = [tencentcloud_mysql_readonly_instance.example] +} + +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.1.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.1.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_readonly_instance" "example" { + master_instance_id = tencentcloud_mysql_instance.example.id + instance_name = "tf-mysql" + mem_size = 2000 + 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 = { + createBy = "terraform" + } +} + resource "tencentcloud_mysql_ro_group_load_operation" "ro_group_load_operation" { - ro_group_id = "cdbrg-bdlvcfpj" + ro_group_id = data.tencentcloud_mysql_instance.example.instance_list.0.ro_groups.0.group_id } ``` diff --git a/tencentcloud/resource_tc_mysql_ro_instance_ip.go b/tencentcloud/resource_tc_mysql_ro_instance_ip.go index 58eb9dbd1b..90d2ff0e98 100644 --- a/tencentcloud/resource_tc_mysql_ro_instance_ip.go +++ b/tencentcloud/resource_tc_mysql_ro_instance_ip.go @@ -4,12 +4,28 @@ Provides a resource to create a mysql ro_instance_ip Example Usage ```hcl -resource "tencentcloud_mysql_ro_instance_ip" "ro_instance_ip" { - instance_id = "cdbro-bdlvcfpj" - uniq_subnet_id = "subnet-dwj7ipnc" - uniq_vpc_id = "vpc-4owdpnwr" +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_mysql_ro_instance_ip" "example" { + instance_id = "cdbro-bdlvcfpj" + uniq_subnet_id = tencentcloud_subnet.subnet.id + uniq_vpc_id = tencentcloud_vpc.vpc.id +} ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_mysql_ro_start_replication.go b/tencentcloud/resource_tc_mysql_ro_start_replication.go index 6dda2b6240..c028f44369 100644 --- a/tencentcloud/resource_tc_mysql_ro_start_replication.go +++ b/tencentcloud/resource_tc_mysql_ro_start_replication.go @@ -4,8 +4,75 @@ Provides a resource to create a mysql ro_start_replication Example Usage ```hcl -resource "tencentcloud_mysql_ro_start_replication" "ro_start_replication" { - instance_id = "cdb-fitq5t9h" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 1 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + +resource "tencentcloud_mysql_ro_start_replication" "example" { + instance_id = tencentcloud_mysql_proxy.example.id } ``` */ diff --git a/tencentcloud/resource_tc_mysql_ro_stop_replication.go b/tencentcloud/resource_tc_mysql_ro_stop_replication.go index 416154c878..00cd49d5ae 100644 --- a/tencentcloud/resource_tc_mysql_ro_stop_replication.go +++ b/tencentcloud/resource_tc_mysql_ro_stop_replication.go @@ -4,8 +4,75 @@ Provides a resource to create a mysql ro_stop_replication Example Usage ```hcl -resource "tencentcloud_mysql_ro_stop_replication" "ro_stop_replication" { - instance_id = "cdb-fitq5t9h" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 1 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + +resource "tencentcloud_mysql_ro_stop_replication" "example" { + instance_id = tencentcloud_mysql_proxy.example.id } ``` */ diff --git a/tencentcloud/resource_tc_mysql_rollback.go b/tencentcloud/resource_tc_mysql_rollback.go index 954850d2c4..5471ec569b 100644 --- a/tencentcloud/resource_tc_mysql_rollback.go +++ b/tencentcloud/resource_tc_mysql_rollback.go @@ -4,19 +4,72 @@ Provides a resource to create a mysql rollback Example Usage ```hcl -resource "tencentcloud_mysql_rollback" "rollback" { - instance_id = "cdb-fitq5t9h" - strategy = "full" - rollback_time = "2023-05-31 23:13:35" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "cdb" +} + +data "tencentcloud_mysql_rollback_range_time" "example" { + instance_ids = [tencentcloud_mysql_instance.example.id] +} + +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_rollback" "example" { + instance_id = tencentcloud_mysql_instance.example.id + strategy = "full" + rollback_time = data.tencentcloud_mysql_rollback_range_time.example.item.0.times.0.start databases { - database_name = "tf_ci_test_bak" - new_database_name = "tf_ci_test_bak_5" + database_name = "tf_db_bak" + new_database_name = "tf_db_bak_new" } tables { - database = "tf_ci_test_bak" + database = "tf_db_bak1" table { - table_name = "test" - new_table_name = "test_bak" + table_name = "tf_table" + new_table_name = "tf_table_new" } } } diff --git a/tencentcloud/resource_tc_mysql_rollback_stop.go b/tencentcloud/resource_tc_mysql_rollback_stop.go index ac63d87820..a6c018500d 100644 --- a/tencentcloud/resource_tc_mysql_rollback_stop.go +++ b/tencentcloud/resource_tc_mysql_rollback_stop.go @@ -3,8 +3,10 @@ Provides a resource to create a mysql rollback_stop Example Usage +Revoke the ongoing rollback task of the instance + ```hcl -resource "tencentcloud_mysql_rollback_stop" "rollback_stop" { +resource "tencentcloud_mysql_rollback_stop" "example" { instance_id = "cdb-fitq5t9h" } ``` diff --git a/tencentcloud/resource_tc_mysql_security_groups_attachment.go b/tencentcloud/resource_tc_mysql_security_groups_attachment.go index c845288db5..e8c9773e09 100644 --- a/tencentcloud/resource_tc_mysql_security_groups_attachment.go +++ b/tencentcloud/resource_tc_mysql_security_groups_attachment.go @@ -4,9 +4,57 @@ Provides a resource to create a mysql security_groups_attachment Example Usage ```hcl -resource "tencentcloud_mysql_security_groups_attachment" "security_groups_attachment" { - security_group_id = "sg-baxfiao5" - instance_id = "cdb-fitq5t9h" +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 } ``` diff --git a/tencentcloud/resource_tc_mysql_switch_for_upgrade.go b/tencentcloud/resource_tc_mysql_switch_for_upgrade.go index d92239b188..54a0d65822 100644 --- a/tencentcloud/resource_tc_mysql_switch_for_upgrade.go +++ b/tencentcloud/resource_tc_mysql_switch_for_upgrade.go @@ -4,8 +4,56 @@ Provides a resource to create a mysql switch_for_upgrade Example Usage ```hcl -resource "tencentcloud_mysql_switch_for_upgrade" "switch_for_upgrade" { - instance_id = "cdb-d9gbh7lt" +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_switch_for_upgrade" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` */ diff --git a/tencentcloud/resource_tc_mysql_switch_master_slave_operation.go b/tencentcloud/resource_tc_mysql_switch_master_slave_operation.go index b6047e5ef2..33f8979f48 100644 --- a/tencentcloud/resource_tc_mysql_switch_master_slave_operation.go +++ b/tencentcloud/resource_tc_mysql_switch_master_slave_operation.go @@ -4,11 +4,60 @@ Provides a resource to create a mysql switch_master_slave_operation Example Usage ```hcl -resource "tencentcloud_mysql_switch_master_slave_operation" "switch_master_slave_operation" { - instance_id = "cdb-d9gbh7lt" - dst_slave = "first" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_switch_master_slave_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id + dst_slave = "second" force_switch = true - wait_switch = true + wait_switch = true } ``` diff --git a/tencentcloud/resource_tc_mysql_switch_proxy.go b/tencentcloud/resource_tc_mysql_switch_proxy.go index f4acaf8422..aea16f9f47 100644 --- a/tencentcloud/resource_tc_mysql_switch_proxy.go +++ b/tencentcloud/resource_tc_mysql_switch_proxy.go @@ -4,9 +4,76 @@ Provides a resource to create a mysql switch_proxy Example Usage ```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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 2 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + resource "tencentcloud_mysql_switch_proxy" "switch_proxy" { - instance_id = "cdb-fitq5t9h" - proxy_group_id = "proxy-h1ub486b" + instance_id = tencentcloud_mysql_instance.example.id + proxy_group_id = tencentcloud_mysql_proxy.example.proxy_group_id } ``` */ diff --git a/tencentcloud/resource_tc_mysql_time_window.go b/tencentcloud/resource_tc_mysql_time_window.go index d3b7b42124..1927a478a1 100644 --- a/tencentcloud/resource_tc_mysql_time_window.go +++ b/tencentcloud/resource_tc_mysql_time_window.go @@ -4,13 +4,61 @@ Provides a resource to create a mysql time_window Example Usage ```hcl -resource "tencentcloud_mysql_time_window" "time_window" { - instance_id = "cdb-lw71b6ar" +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_time_window" "example" { + instance_id = tencentcloud_mysql_instance.example.id max_delay_time = 10 time_ranges = [ "01:00-02:01" ] - weekdays = [ + weekdays = [ "friday", "monday", "saturday", diff --git a/tencentcloud/resource_tc_mysql_verify_root_account.go b/tencentcloud/resource_tc_mysql_verify_root_account.go index 40ce71350c..7a62d3039a 100644 --- a/tencentcloud/resource_tc_mysql_verify_root_account.go +++ b/tencentcloud/resource_tc_mysql_verify_root_account.go @@ -4,9 +4,58 @@ Provides a resource to create a mysql verify_root_account Example Usage ```hcl -resource "tencentcloud_mysql_verify_root_account" "verify_root_account" { - instance_id = "" - password = "" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_verify_root_account" "example" { + instance_id = tencentcloud_mysql_instance.example.id + password = "Qwer@234" } ``` */ diff --git a/tencentcloud/resource_tc_nat_gateway.go b/tencentcloud/resource_tc_nat_gateway.go index b914ba3b46..4e240d4fd0 100644 --- a/tencentcloud/resource_tc_nat_gateway.go +++ b/tencentcloud/resource_tc_nat_gateway.go @@ -3,31 +3,33 @@ Provides a resource to create a NAT gateway. Example Usage +Create a NAT gateway. + ```hcl -data "tencentcloud_vpc_instances" "foo" { - name = "Default-VPC" -} -# Create EIP -resource "tencentcloud_eip" "eip_dev_dnat" { - name = "terraform_nat_test" +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_nat_gateway_vpc" } -resource "tencentcloud_eip" "new_eip" { - name = "terraform_nat_test" + +resource "tencentcloud_eip" "eip_example1" { + name = "tf_nat_gateway_eip1" } -resource "tencentcloud_nat_gateway" "my_nat" { - vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id - name = "new_name" - max_concurrent = 10000000 - bandwidth = 1000 - zone = "ap-guangzhou-3" +resource "tencentcloud_eip" "eip_example2" { + name = "tf_nat_gateway_eip2" +} +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.new_eip.public_ip, + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] tags = { - tf = "test" + tf_tag_key = "tf_tag_value" } } ``` diff --git a/tencentcloud/resource_tc_nat_gateway_snat.go b/tencentcloud/resource_tc_nat_gateway_snat.go index aab26375f9..c58d4ef969 100644 --- a/tencentcloud/resource_tc_nat_gateway_snat.go +++ b/tencentcloud/resource_tc_nat_gateway_snat.go @@ -4,100 +4,112 @@ Provides a resource to create a NAT Gateway SNat rule. Example Usage ```hcl -data "tencentcloud_availability_zones" "my_zones" {} - -data "tencentcloud_vpc" "my_vpc" { - name = "Default-VPC" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "nat" } -data "tencentcloud_images" "my_image" { +data "tencentcloud_images" "image" { os_name = "centos" } -data "tencentcloud_instance_types" "my_instance_types" { - cpu_core_count = 1 - memory_size = 1 +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" } -# Create EIP -resource "tencentcloud_eip" "eip_dev_dnat" { - name = "terraform_test" +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_test_dnat" { - name = "terraform_test" + +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 = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" + vpc_id = tencentcloud_vpc.vpc.id + name = "tf_example_nat_gateway" max_concurrent = 3000000 bandwidth = 500 assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] } # Create route_table and entry -resource "tencentcloud_route_table" "my_route_table" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" +resource "tencentcloud_route_table" "route_table" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf_example" } -resource "tencentcloud_route_table_entry" "my_route_entry" { - route_table_id = tencentcloud_route_table.my_route_table.id + +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 } -# Create Subnet -resource "tencentcloud_subnet" "my_subnet" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" - cidr_block = "172.29.23.0/24" - availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name - route_table_id = tencentcloud_route_table.my_route_table.id -} - # Subnet Nat gateway snat -resource "tencentcloud_nat_gateway_snat" "my_subnet_snat" { +resource "tencentcloud_nat_gateway_snat" "subnet_snat" { nat_gateway_id = tencentcloud_nat_gateway.my_nat.id resource_type = "SUBNET" - subnet_id = tencentcloud_subnet.my_subnet.id - subnet_cidr_block = tencentcloud_subnet.my_subnet.cidr_block + subnet_id = tencentcloud_subnet.subnet.id + subnet_cidr_block = tencentcloud_subnet.subnet.cidr_block description = "terraform test" - public_ip_addr = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, + public_ip_addr = [ + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] } # Create instance -resource "tencentcloud_instance" "my_instance" { - instance_name = "terraform test" - availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name - image_id = data.tencentcloud_images.my_image.images.0.image_id - instance_type = data.tencentcloud_instance_types.my_instance_types.instance_types.0.instance_type - system_disk_type = "CLOUD_PREMIUM" - system_disk_size = 50 - hostname = "user" - project_id = 0 - vpc_id = data.tencentcloud_vpc.my_vpc.id - subnet_id = tencentcloud_subnet.my_subnet.id - internet_max_bandwidth_out = 20 +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.my_instance.id - instance_private_ip_addr = tencentcloud_instance.my_instance.private_ip + instance_id = tencentcloud_instance.example.id + instance_private_ip_addr = tencentcloud_instance.example.private_ip description = "terraform test" - public_ip_addr = [ - tencentcloud_eip.eip_dev_dnat.public_ip, + public_ip_addr = [ + tencentcloud_eip.eip_example1.public_ip, ] } ``` diff --git a/tencentcloud/resource_tc_nat_gateway_test.go b/tencentcloud/resource_tc_nat_gateway_test.go index 767ccde2af..10b4324cd3 100644 --- a/tencentcloud/resource_tc_nat_gateway_test.go +++ b/tencentcloud/resource_tc_nat_gateway_test.go @@ -169,7 +169,7 @@ func testAccCheckNatGatewayExists(n string) resource.TestCheckFunc { const testAccNatGatewayConfig = ` data "tencentcloud_vpc_instances" "foo" { - name = "Default-VPC" + name = "Default-VPC" } # Create EIP resource "tencentcloud_eip" "eip_dev_dnat" { @@ -179,44 +179,44 @@ resource "tencentcloud_eip" "eip_test_dnat" { name = "terraform_test" } resource "tencentcloud_nat_gateway" "my_nat" { - vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id - name = "terraform_test" - max_concurrent = 3000000 - bandwidth = 500 + vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id + name = "terraform_test" + max_concurrent = 3000000 + bandwidth = 500 assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, - ] - tags = { - tf = "test" - } + tencentcloud_eip.eip_dev_dnat.public_ip, + tencentcloud_eip.eip_test_dnat.public_ip, + ] + tags = { + tf = "test" + } } ` const testAccNatGatewayConfigUpdate = ` data "tencentcloud_vpc_instances" "foo" { - name = "Default-VPC" + name = "Default-VPC" } # Create EIP resource "tencentcloud_eip" "eip_dev_dnat" { - name = "terraform_test" + name = "terraform_test" } resource "tencentcloud_eip" "new_eip" { name = "terraform_test" } resource "tencentcloud_nat_gateway" "my_nat" { - vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id - name = "new_name" - max_concurrent = 10000000 - bandwidth = 1000 + vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id + name = "new_name" + max_concurrent = 10000000 + bandwidth = 1000 assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.new_eip.public_ip, - ] - tags = { - tf = "teest" - } + tencentcloud_eip.eip_dev_dnat.public_ip, + tencentcloud_eip.new_eip.public_ip, + ] + tags = { + tf = "teest" + } } ` diff --git a/tencentcloud/resource_tc_nat_refresh_nat_dc_route.go b/tencentcloud/resource_tc_nat_refresh_nat_dc_route.go index 9a17a6c90a..1311303cc6 100644 --- a/tencentcloud/resource_tc_nat_refresh_nat_dc_route.go +++ b/tencentcloud/resource_tc_nat_refresh_nat_dc_route.go @@ -3,11 +3,43 @@ Provides a resource to create a vpc refresh_nat_dc_route Example Usage +If `dry_run` is True + +```hcl +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_eip" "eip_example" { + name = "eip_example" +} + +resource "tencentcloud_nat_gateway" "nat" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf_example_nat_gateway" + max_concurrent = 3000000 + bandwidth = 500 + + assigned_eip_set = [ + tencentcloud_eip.eip_example.public_ip, + ] +} + +resource "tencentcloud_nat_refresh_nat_dc_route" "refresh_nat_dc_route" { + nat_gateway_id = tencentcloud_nat_gateway.nat.id + vpc_id = tencentcloud_vpc.vpc.id + dry_run = true +} +``` + +Or `dry_run` is False + ```hcl resource "tencentcloud_nat_refresh_nat_dc_route" "refresh_nat_dc_route" { - nat_gateway_id = "nat-gnxkey2e" - vpc_id = "vpc-pyyv5k3v" - dry_run = true + nat_gateway_id = tencentcloud_nat_gateway.nat.id + vpc_id = tencentcloud_vpc.vpc.id + dry_run = false } ``` diff --git a/tencentcloud/resource_tc_security_group.go b/tencentcloud/resource_tc_security_group.go index 46453203f9..7e470a6679 100644 --- a/tencentcloud/resource_tc_security_group.go +++ b/tencentcloud/resource_tc_security_group.go @@ -3,11 +3,26 @@ Provides a resource to create security group. Example Usage +Create a basic security group + ```hcl -resource "tencentcloud_security_group" "sglab" { - name = "mysg" - description = "favourite sg" +resource "tencentcloud_security_group" "example" { + name = "tf-example-sg" + description = "sg test" +} +``` + +Create a complete security group + +```hcl +resource "tencentcloud_security_group" "example" { + name = "tf-example-sg" + description = "sg test" project_id = 0 + + tags = { + "example" = "test" + } } ``` diff --git a/tencentcloud/resource_tc_ssl_certificate.go b/tencentcloud/resource_tc_ssl_certificate.go index 5e7557cba6..66ca228144 100644 --- a/tencentcloud/resource_tc_ssl_certificate.go +++ b/tencentcloud/resource_tc_ssl_certificate.go @@ -1,14 +1,48 @@ /* Provides a resource to create a SSL certificate. +Upload the existing SSL certificate to Tencent Cloud. + Example Usage +If SSL certificate type is `CA` + ```hcl -resource "tencentcloud_ssl_certificate" "foo" { - name = "test-ssl-certificate" - type = "CA" - project_id = 0 - cert = "-----BEGIN CERTIFICATE-----\nMIIERzCCAq+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzE5MzlaFw0yOTA4\nMTAwMzE5MzlaMC4xEzARBgNVBAMTCnNlcnZlciBzc2wxFzAVBgNVBAoTDnRlcnJh\nZm9ybS10ZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1Ryp+DKK\nSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8YgpolenbmeEPrzT87tunFD7G9f6ALG\nND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqNAhGLaxWiEB/hy5WOiwxDrGei\ngQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVRopZuCe/RMPNusNVZaIi+qcEf\nfsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWCF97qy8TNYk94K/1tq3zyhVzR\nZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8IslgnqJW4izIXZqgIKmHaRZtM\nN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88aC8HnMqJJ3kScGCL36GYG+Kaw\n5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJyxAXyiX49LQ0v7f9qzwc/0JiD\nbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xlYP6l1SoJG3GgZ8dbAgMBAAGj\ndjB0MAwGA1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/\nBAUDAweAADAdBgNVHQ4EFgQULwWKBQNLL9s3cb3tTnyPVg+mpCMwHwYDVR0jBBgw\nFoAUKwfrmq791mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAMo5RglS\nAHdPgaicWJvmvjjexjF/42b7Rz4pPfMjYw6uYO8He/f4UZWv5CZLrbEe7MywaK3y\n0OsfH8AhyN29pv2x8g9wbmq7omZIOZ0oCAGduEXs/A/qY/hFaCohdkz/IN8qi6JW\nVXreGli3SrpcHFchSwHTyJEXgkutcGAsOvdsOuVSmplOyrkLHc8uUe8SG4j8kGyg\nEzaszFjHkR7g1dVyDVUedc588mjkQxYeAamJgfkgIhljWKMa2XzkVMcVfQHfNpM1\nn+bu8SmqRt9Wma2bMijKRG/Blm756LoI+skY+WRZmlDnq8zj95TT0vceGP0FUWh5\nhKyiocABmpQs9OK9HMi8vgSWISP+fYgkm/bKtKup2NbZBoO5/VL2vCEPInYzUhBO\njCbLMjNjtM5KriCaR7wDARgHiG0gBEPOEW1PIjZ9UOH+LtIxbNZ4eEIIINLHnBHf\nL+doVeZtS/gJc4G4Adr5HYuaS9ZxJ0W2uy0eQlOHzjyxR6Mf/rpnilJlcQ==\n-----END CERTIFICATE-----" +variable "ca" { + default = "-----BEGIN CERTIFICATE-----\nMIIEDjCCAnagAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzA4MjBaFw0yOTA4\nMTAwMzA4MjBaMCgxDTALBgNVBAMTBHRlc3QxFzAVBgNVBAoTDnRlcnJhZm9ybSB0\nZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0k2vqg/GHtFP5P7r\ndbzswfx1jSHeK9r4StV4mGOAoKyzvAJA5BvYbAHpSrL2ZAd6ShjHgRVU1qEroeFn\n8fwTrAVQttMltBFABx7G4iN4Zf6EUXzhhFN6vVVbWaqhYhrdMoPvZxgGSA/4hG4W\nGIr8MXZzXbKLoRoz4Bvq1Ymg5eO14KLJFSTahvIkG60egGN5pmi4czxWy2U7ycA5\nQ5TuQBnF0rKQJW5XKIV3kr5YrzDdJK7up9E6Od4T5jz+qY97KAjIpWD/pTAsc7+6\nfPBpY7NHT9Bw0fDmvsWO/PtswY4hW02n86b5eWA9sfKJGphhsBxgpuuhmxYHS6pA\nB+C7IkyxcADNT5u9tEo2JGOj+/veXKrEhZin7inKsQLD0WOobcg1Rh/3NSWD7geF\nTJBRnzgplaN7cK6c/utEAAnngS38q4DGBR/jHmkWjAeQPZj1eLLBk686HEEbKeU+\n9yAVcPRhA9tuL7wMeSX32VunWZunoA/f8iuGZYJlZsNBqyJbAgMBAAGjQzBBMA8G\nA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAweGADAdBgNVHQ4EFgQUKwfrmq79\n1mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAInM+aeaHoZdw9B9nAH2\nHscEoOulF+RxnysSXTTRLd2VQph4+ynlfRZT4evLBBj/ppmqjp8F7/OcRiiZwSXl\nnamyP/UUINtHfgDM0kll/5Za0aYzMhrORNw+3ythIv2yPJX8t4LmsG1L4PMO8ZU8\nN0K9XyKRaL/tq6rw1gQM152OmNgTzfAQoKYxrvbftOZz4J0ZACctuBmwtp5upKvJ\n36aQ4wJLUzOt69mnW+AaL5EPA37mwtzdnzTTxd3SBfOYXjsflc3l2raljJznnqU2\nySynjb6L3D3L/pObL1Uu7nQBy8CazJBsBsVFK/pr61vcllm8lG7vOhHOUSFUeezq\nFWukAolm9/cagmD6IhNishM3Uzng+UYyCC8uQq3Z7FGqJpXSI79wZYjudnCLPVCg\nOIfJHQeJFLryn6GxiSYmYs6dgUJiiTV+I/2Y5X7ZFdb5FC1J/WmvoCv6yO7NiirY\nBSgfV0lp5CuV8SfiSClpYfrM28NbNgxveUqET642BJOPLQ==\n-----END CERTIFICATE-----" +} + +data "tencentcloud_ssl_certificates" "ca" { + name = tencentcloud_ssl_certificate.ca.name +} + +resource "tencentcloud_ssl_certificate" "ca" { + name = "ssl-ca" + type = "CA" + cert = var.ca +} +``` + +If SSL certificate type is `SVR` + +```hcl +variable "cert" { + default = "-----BEGIN CERTIFICATE-----\nMIIERzCCAq+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzE5MzlaFw0yOTA4\nMTAwMzE5MzlaMC4xEzARBgNVBAMTCnNlcnZlciBzc2wxFzAVBgNVBAoTDnRlcnJh\nZm9ybS10ZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1Ryp+DKK\nSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8YgpolenbmeEPrzT87tunFD7G9f6ALG\nND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqNAhGLaxWiEB/hy5WOiwxDrGei\ngQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVRopZuCe/RMPNusNVZaIi+qcEf\nfsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWCF97qy8TNYk94K/1tq3zyhVzR\nZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8IslgnqJW4izIXZqgIKmHaRZtM\nN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88aC8HnMqJJ3kScGCL36GYG+Kaw\n5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJyxAXyiX49LQ0v7f9qzwc/0JiD\nbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xlYP6l1SoJG3GgZ8dbAgMBAAGj\ndjB0MAwGA1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/\nBAUDAweAADAdBgNVHQ4EFgQULwWKBQNLL9s3cb3tTnyPVg+mpCMwHwYDVR0jBBgw\nFoAUKwfrmq791mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAMo5RglS\nAHdPgaicWJvmvjjexjF/42b7Rz4pPfMjYw6uYO8He/f4UZWv5CZLrbEe7MywaK3y\n0OsfH8AhyN29pv2x8g9wbmq7omZIOZ0oCAGduEXs/A/qY/hFaCohdkz/IN8qi6JW\nVXreGli3SrpcHFchSwHTyJEXgkutcGAsOvdsOuVSmplOyrkLHc8uUe8SG4j8kGyg\nEzaszFjHkR7g1dVyDVUedc588mjkQxYeAamJgfkgIhljWKMa2XzkVMcVfQHfNpM1\nn+bu8SmqRt9Wma2bMijKRG/Blm756LoI+skY+WRZmlDnq8zj95TT0vceGP0FUWh5\nhKyiocABmpQs9OK9HMi8vgSWISP+fYgkm/bKtKup2NbZBoO5/VL2vCEPInYzUhBO\njCbLMjNjtM5KriCaR7wDARgHiG0gBEPOEW1PIjZ9UOH+LtIxbNZ4eEIIINLHnBHf\nL+doVeZtS/gJc4G4Adr5HYuaS9ZxJ0W2uy0eQlOHzjyxR6Mf/rpnilJlcQ==\n-----END CERTIFICATE-----" +} + +variable "key" { + default = "Public Key Info:\n Public Key Algorithm: RSA\n Key Security Level: High (3072 bits)\n\nmodulus:\n 00:d5:1c:a9:f8:32:8a:48:d1:4a:66:c3:ed:c1:f4:7e\n 8f:33:a7:43:c6:05:89:e2:0a:62:06:a4:57:af:3c:77\n c6:20:a6:89:5e:9d:b9:9e:10:fa:f3:4f:ce:ed:ba:71\n 43:ec:6f:5f:e8:02:c6:34:3f:2b:8f:b9:e9:8f:40:28\n c3:18:4e:2f:f8:7f:bf:50:fd:bb:45:2c:21:a8:f9:8b\n 61:96:26:ba:8d:02:11:8b:6b:15:a2:10:1f:e1:cb:95\n 8e:8b:0c:43:ac:67:a2:81:0a:89:90:53:39:d8:4a:7b\n 1b:56:31:ec:f1:c9:98:a1:46:c0:df:45:84:8b:05:8b\n 57:0d:65:f5:51:a2:96:6e:09:ef:d1:30:f3:6e:b0:d5\n 59:68:88:be:a9:c1:1f:7e:c1:35:72:67:e6:b9:29:46\n dc:0a:74:44:a3:88:c9:1d:1a:8c:31:33:a9:99:fd:ff\n 44:7b:57:05:82:17:de:ea:cb:c4:cd:62:4f:78:2b:fd\n 6d:ab:7c:f2:85:5c:d1:67:cd:f1:39:27:eb:4e:a1:1f\n 6f:7b:28:dc:05:36:8f:22:a0:61:dc:2b:fc:56:52:ef\n 65:42:1d:2f:08:b2:58:27:a8:95:b8:8b:32:17:66:a8\n 08:2a:61:da:45:9b:4c:37:88:d4:96:88:ba:97:fe:a5\n 92:db:7a:2e:c8:21:f7:11:02:79:cc:73:89:22:6d:3c\n c6:a8:83:cf:1a:0b:c1:e7:32:a2:49:de:44:9c:18:22\n f7:e8:66:06:f8:a6:b0:e4:f9:c3:95:65:c1:69:e8:83\n 7b:cc:ff:79:62:bd:f9:1a:f6:33:ea:e1:4c:dc:68:b0\n 05:46:7c:32:72:c4:05:f2:89:7e:3d:2d:0d:2f:ed:ff\n 6a:cf:07:3f:d0:98:83:6e:fb:14:bf:57:26:e8:e8:29\n a0:43:0f:f5:25:ea:a8:17:70:1a:a7:8a:6c:3d:bf:da\n 39:4f:e3:cc:65:60:fe:a5:d5:2a:09:1b:71:a0:67:c7\n 5b:\n\npublic exponent:\n 01:00:01:\n\nprivate exponent:\n 00:b1:56:d0:fa:00:d4:a2:13:c7:5e:0c:dc:e4:f1:97\n ff:82:74:46:29:9a:a2:4a:bf:69:23:2d:ce:e9:bb:df\n cf:b7:8b:dd:f4:26:3c:38:14:d9:3f:6f:c2:3a:81:53\n 8f:ba:48:53:fe:b5:90:4a:19:e7:1e:0b:0f:18:6d:c3\n 7d:d5:d3:fa:87:47:86:e4:d6:bf:e7:a7:f9:ba:ab:2e\n 19:5e:e1:8b:8b:9b:95:0d:f7:66:61:1e:19:e9:c3:88\n 08:be:1c:ce:93:c1:09:b1:68:1b:61:46:60:74:64:46\n 5d:51:34:ea:7f:a9:ca:a1:2a:47:85:84:4b:ef:84:05\n 97:c3:46:7d:06:19:ce:24:73:90:64:fb:df:16:d5:80\n 34:8e:90:7c:58:b6:a4:86:ce:30:b3:ab:52:8b:f2:95\n 4c:b6:46:5a:77:db:73:c0:0c:3f:6d:12:18:a8:54:7c\n ff:77:c3:ca:89:9f:63:98:ef:48:2d:c1:09:70:6e:ea\n cb:bb:78:91:42:8a:22:3e:21:ef:a5:bf:16:ee:66:45\n e5:f0:26:6a:85:8e:e1:69:62:ac:05:00:a6:44:ba:c8\n ac:10:00:97:f5:51:65:7f:9a:1f:7b:99:9d:02:d4:87\n 50:ce:74:06:51:67:fa:fb:90:e4:33:79:f2:a8:61:ee\n 45:1d:87:ca:22:5b:ac:e7:32:38:f8:2c:fd:55:92:1e\n 3d:60:1e:7c:4b:fd:28:ff:e5:b1:02:6a:aa:22:f7:ae\n a8:36:90:7b:a6:f7:29:05:14:3a:21:da:36:05:f9:b0\n 9d:f7:fb:10:75:d7:2c:21:32:95:e7:f7:17:be:09:cb\n 66:fe:f1:69:71:df:a4:5e:3f:fc:67:6c:37:65:b8:51\n c6:22:38:fb:07:ce:89:54:50:43:71:44:3d:c3:51:5a\n bd:e5:c7:87:b2:ea:7b:64:0f:5d:34:9c:a1:52:b3:ce\n 06:86:ba:7a:05:80:48:b3:6c:1b:79:74:9b:49:f2:30\n c1:\n\nprime1:\n 00:e4:31:46:59:3d:24:f7:31:d9:22:26:af:c0:3e:f5\n c1:6d:be:ba:d3:9e:3f:b9:2c:43:a0:d0:47:09:e4:35\n 63:19:a4:33:82:af:f9:76:3c:11:c2:cb:34:f9:a6:ab\n dd:ab:64:5a:6b:9c:c1:2a:52:89:64:7e:b5:a7:f0:4d\n 29:13:a4:cf:17:f4:f2:0d:a0:6e:b9:5d:95:41:10:df\n ae:f3:7a:13:49:21:66:73:2a:b7:e2:8d:7c:c2:34:e5\n 3f:bd:78:ca:fc:64:c5:1c:3a:66:7a:12:53:96:bd:b0\n c3:7a:0c:ec:5e:55:c0:c3:3f:7f:25:72:f4:e2:19:94\n 9d:65:15:be:c8:82:20:57:12:97:b2:a8:4d:3d:e0:8f\n e2:1f:d0:c8:49:aa:f4:34:fa:91:d1:d1:cc:98:bc:3d\n 8b:b1:9b:8f:fd:ef:03:dd:92:fb:ca:99:45:af:cc:83\n 58:4c:bb:ba:73:9e:23:84:f9:7e:4f:40:fe:00:b5:bf\n 6f:\n\nprime2:\n 00:ef:14:ef:73:fc:0c:fc:e3:87:d9:7f:a6:f8:55:86\n 57:63:8a:86:87:f5:ef:63:20:1f:b2:ae:28:dc:ab:59\n 80:8f:15:64:44:e2:bc:a5:7b:d7:69:ef:30:b1:83:b3\n bd:09:fd:4a:0c:c6:31:5b:a4:79:d0:e5:d3:a8:31:fd\n 59:ea:52:63:cf:17:a7:c1:54:bf:a8:11:9b:b1:85:47\n 5a:08:a6:9c:2f:47:9d:ac:5d:e8:7c:e4:31:6c:99:71\n 04:7d:20:98:be:8b:60:07:66:2d:b9:41:10:ea:dd:5b\n 87:20:65:62:ea:75:a7:a6:04:a2:18:66:6b:db:5b:a4\n 9f:12:97:cb:7c:8c:d2:e0:ce:02:ef:1e:df:a1:9d:6a\n bc:00:38:18:36:a1:c5:97:16:be:7a:df:5f:4f:4f:de\n a3:cb:25:fe:f6:67:0d:31:aa:0a:d4:1b:be:df:91:2c\n 05:14:20:37:cc:4f:50:33:a6:50:1b:90:f9:b2:08:80\n d5:\n\ncoefficient:\n 47:d1:7f:ca:93:6a:14:9b:fe:85:8d:c2:15:11:52:a2\n a5:bc:f5:6b:a2:69:76:49:1e:09:79:f1:15:bf:39:48\n 41:ff:92:78:af:bc:7d:6f:76:3b:32:9e:08:d2:42:06\n 04:5f:36:e0:be:a8:1d:21:5c:ec:39:09:e0:77:c5:86\n 06:e6:ce:98:16:fc:0f:30:de:a7:69:7a:8f:dd:01:42\n 2a:22:f5:b7:c2:fc:c8:90:5a:78:dc:b3:e0:4d:e7:2d\n 98:6c:e3:34:1b:d7:e8:f8:90:57:7e:4d:41:d6:4a:29\n 81:92:eb:89:5b:45:85:dd:b9:16:20:63:cb:59:f6:06\n 59:c1:dd:3b:6b:92:0a:5e:5e:63:4a:f1:a7:d5:16:b9\n 8b:6c:d8:ad:76:0e:2d:3c:e0:b3:73:e0:6d:af:d4:a2\n bc:4b:fd:6c:2d:d7:5d:4d:cd:28:03:64:b2:ef:9a:1d\n 82:8d:53:40:c5:f8:fb:f3:63:de:8e:1a:21:b6:35:14\n \n\nexp1:\n 00:9c:a5:8a:d2:65:dc:03:69:8f:d2:16:d6:9d:55:5b\n 25:4e:ae:18:d8:7e:90:e6:10:11:d8:ca:41:89:f3:c4\n 06:64:aa:c8:c5:95:01:dd:fd:7c:7f:c9:39:73:8b:cb\n fd:9e:d3:84:12:cd:87:f9:02:b1:d8:6f:f7:49:f2:f7\n 35:14:8c:15:b2:2f:6f:1e:95:9c:8c:d9:46:45:65:4c\n f8:6f:a1:c4:ad:76:25:3b:37:ff:05:a1:f5:1b:e8:6d\n db:64:b9:10:37:55:01:ce:cf:f4:5b:26:4b:85:76:70\n 6a:b0:55:40:c9:bd:7a:57:4e:36:7d:41:be:03:9c:65\n dd:ea:6f:94:09:56:f2:d6:73:27:f9:f7:f9:16:5a:1a\n cb:b2:e5:83:28:b7:17:6f:6a:f7:41:1f:11:a1:63:cf\n a8:1e:e3:58:64:8c:78:8d:d9:81:c9:e1:8f:ea:0f:ad\n b6:a6:ee:54:1f:5c:56:ab:c9:0d:c1:60:2f:3d:d3:86\n 37:\n\nexp2:\n 64:12:b7:48:2d:30:a2:89:fa:cb:27:8b:94:56:f8:2c\n 8c:15:e7:c9:f1:3f:8a:96:5f:ae:43:08:07:96:11:98\n a6:4b:a5:f4:cf:93:77:11:27:51:c8:34:f1:98:d7:1b\n 41:9b:2b:eb:bc:e9:dc:1a:34:83:24:30:3c:2e:f0:85\n 3a:77:d2:1f:55:1f:7a:e5:26:74:0b:2a:c8:5b:a9:4a\n 1e:64:de:eb:4b:66:cc:47:62:91:24:53:2b:c9:ee:6c\n 9a:93:92:5b:ef:aa:fa:6d:e2:a5:b0:7e:8c:50:ab:87\n 1c:20:54:0f:1f:c0:54:d5:8b:a3:fa:fb:1a:8e:79:91\n bc:0e:9d:b6:3c:9b:e8:4d:53:1d:14:27:37:56:d4:de\n 6c:99:0e:49:8f:dd:4d:28:d0:02:4e:8d:6e:7d:58:0b\n e7:74:b8:0c:1b:86:82:4b:52:cd:05:f0:17:54:84:c0\n 7b:74:20:e6:fc:2b:ed:f2:a7:85:62:61:a2:0b:bd:21\n \n\n\nPublic Key PIN:\n pin-sha256:t5OXXC5gYqMNtUMsTqRs3A3vhfK2BiXVOgYzIEYv7Y8=\nPublic Key ID:\n sha256:b793975c2e6062a30db5432c4ea46cdc0def85f2b60625d53a063320462fed8f\n sha1:2f058a05034b2fdb3771bded4e7c8f560fa6a423\n\n-----BEGIN RSA PRIVATE KEY-----\nMIIG5AIBAAKCAYEA1Ryp+DKKSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8Ygpole\nnbmeEPrzT87tunFD7G9f6ALGND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqN\nAhGLaxWiEB/hy5WOiwxDrGeigQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVR\nopZuCe/RMPNusNVZaIi+qcEffsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWC\nF97qy8TNYk94K/1tq3zyhVzRZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8I\nslgnqJW4izIXZqgIKmHaRZtMN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88a\nC8HnMqJJ3kScGCL36GYG+Kaw5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJy\nxAXyiX49LQ0v7f9qzwc/0JiDbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xl\nYP6l1SoJG3GgZ8dbAgMBAAECggGBALFW0PoA1KITx14M3OTxl/+CdEYpmqJKv2kj\nLc7pu9/Pt4vd9CY8OBTZP2/COoFTj7pIU/61kEoZ5x4LDxhtw33V0/qHR4bk1r/n\np/m6qy4ZXuGLi5uVDfdmYR4Z6cOICL4czpPBCbFoG2FGYHRkRl1RNOp/qcqhKkeF\nhEvvhAWXw0Z9BhnOJHOQZPvfFtWANI6QfFi2pIbOMLOrUovylUy2Rlp323PADD9t\nEhioVHz/d8PKiZ9jmO9ILcEJcG7qy7t4kUKKIj4h76W/Fu5mReXwJmqFjuFpYqwF\nAKZEusisEACX9VFlf5ofe5mdAtSHUM50BlFn+vuQ5DN58qhh7kUdh8oiW6znMjj4\nLP1Vkh49YB58S/0o/+WxAmqqIveuqDaQe6b3KQUUOiHaNgX5sJ33+xB11ywhMpXn\n9xe+Cctm/vFpcd+kXj/8Z2w3ZbhRxiI4+wfOiVRQQ3FEPcNRWr3lx4ey6ntkD100\nnKFSs84Ghrp6BYBIs2wbeXSbSfIwwQKBwQDkMUZZPST3MdkiJq/APvXBbb66054/\nuSxDoNBHCeQ1YxmkM4Kv+XY8EcLLNPmmq92rZFprnMEqUolkfrWn8E0pE6TPF/Ty\nDaBuuV2VQRDfrvN6E0khZnMqt+KNfMI05T+9eMr8ZMUcOmZ6ElOWvbDDegzsXlXA\nwz9/JXL04hmUnWUVvsiCIFcSl7KoTT3gj+If0MhJqvQ0+pHR0cyYvD2LsZuP/e8D\n3ZL7yplFr8yDWEy7unOeI4T5fk9A/gC1v28CgcEA7xTvc/wM/OOH2X+m+FWGV2OK\nhof172MgH7KuKNyrWYCPFWRE4ryle9dp7zCxg7O9Cf1KDMYxW6R50OXTqDH9WepS\nY88Xp8FUv6gRm7GFR1oIppwvR52sXeh85DFsmXEEfSCYvotgB2YtuUEQ6t1bhyBl\nYup1p6YEohhma9tbpJ8Sl8t8jNLgzgLvHt+hnWq8ADgYNqHFlxa+et9fT0/eo8sl\n/vZnDTGqCtQbvt+RLAUUIDfMT1AzplAbkPmyCIDVAoHBAJylitJl3ANpj9IW1p1V\nWyVOrhjYfpDmEBHYykGJ88QGZKrIxZUB3f18f8k5c4vL/Z7ThBLNh/kCsdhv90ny\n9zUUjBWyL28elZyM2UZFZUz4b6HErXYlOzf/BaH1G+ht22S5EDdVAc7P9FsmS4V2\ncGqwVUDJvXpXTjZ9Qb4DnGXd6m+UCVby1nMn+ff5Floay7Llgyi3F29q90EfEaFj\nz6ge41hkjHiN2YHJ4Y/qD622pu5UH1xWq8kNwWAvPdOGNwKBwGQSt0gtMKKJ+ssn\ni5RW+CyMFefJ8T+Kll+uQwgHlhGYpkul9M+TdxEnUcg08ZjXG0GbK+u86dwaNIMk\nMDwu8IU6d9IfVR965SZ0CyrIW6lKHmTe60tmzEdikSRTK8nubJqTklvvqvpt4qWw\nfoxQq4ccIFQPH8BU1Yuj+vsajnmRvA6dtjyb6E1THRQnN1bU3myZDkmP3U0o0AJO\njW59WAvndLgMG4aCS1LNBfAXVITAe3Qg5vwr7fKnhWJhogu9IQKBwEfRf8qTahSb\n/oWNwhURUqKlvPVroml2SR4JefEVvzlIQf+SeK+8fW92OzKeCNJCBgRfNuC+qB0h\nXOw5CeB3xYYG5s6YFvwPMN6naXqP3QFCKiL1t8L8yJBaeNyz4E3nLZhs4zQb1+j4\nkFd+TUHWSimBkuuJW0WF3bkWIGPLWfYGWcHdO2uSCl5eY0rxp9UWuYts2K12Di08\n4LNz4G2v1KK8S/1sLdddTc0oA2Sy75odgo1TQMX4+/Nj3o4aIbY1FA==\n-----END RSA PRIVATE KEY-----" +} + +data "tencentcloud_ssl_certificates" "svr" { + name = tencentcloud_ssl_certificate.svr.name +} + +resource "tencentcloud_ssl_certificate" "svr" { + name = "ssl-svr" + type = "SVR" + cert = var.cert + key = var.key } ``` diff --git a/tencentcloud/resource_tc_ssl_free_certificate.go b/tencentcloud/resource_tc_ssl_free_certificate.go index 60bd809d2f..f4ab1b889e 100644 --- a/tencentcloud/resource_tc_ssl_free_certificate.go +++ b/tencentcloud/resource_tc_ssl_free_certificate.go @@ -5,18 +5,20 @@ Provide a resource to create a Free Certificate. Example Usage +Currently, `package_type` only support type 2. 2=TrustAsia TLS RSA CA. + ```hcl -resource "tencentcloud_ssl_free_certificate" "foo" { - dv_auth_method = "DNS_AUTO" - domain = "example.com" - package_type = "2" - contact_email = "foo@example.com" - contact_phone = "12345678901" - validity_period = 12 - csr_encrypt_algo = "RSA" - csr_key_parameter = "2048" - csr_key_password = "xxxxxxxx" - alias = "my_free_cert" +resource "tencentcloud_ssl_free_certificate" "example" { + dv_auth_method = "DNS_AUTO" + domain = "example.com" + package_type = "2" + contact_email = "test@example.com" + contact_phone = "18352458901" + validity_period = 12 + csr_encrypt_algo = "RSA" + csr_key_parameter = "2048" + csr_key_password = "csr_pwd" + alias = "example_free_cert" } ``` diff --git a/tencentcloud/resource_tc_ssl_pay_certificate.go b/tencentcloud/resource_tc_ssl_pay_certificate.go index b3a4f85cb7..97c10a7924 100644 --- a/tencentcloud/resource_tc_ssl_pay_certificate.go +++ b/tencentcloud/resource_tc_ssl_pay_certificate.go @@ -10,34 +10,34 @@ as `Review Cancel`, and then you can click `Request a refund` to refund the fee. Example Usage ```hcl -resource "tencentcloud_ssl_pay_certificate" "ssl" { +resource "tencentcloud_ssl_pay_certificate" "example" { product_id = 33 domain_num = 1 - alias = "test-ssl" + alias = "ssl desc." project_id = 0 information { csr_type = "online" - certificate_domain = "www.domain.com" - organization_name = "test" - organization_division = "test" - organization_address = "test" + certificate_domain = "www.example.com" + organization_name = "Tencent" + organization_division = "Qcloud" + organization_address = "广东省深圳市南山区腾讯大厦1000号" organization_country = "CN" - organization_city = "test" - organization_region = "test" + organization_city = "深圳市" + organization_region = "广东省" postal_code = "0755" phone_area_code = "0755" - phone_number = "12345678901" + phone_number = "86013388" verify_type = "DNS" admin_first_name = "test" admin_last_name = "test" admin_phone_num = "12345678901" admin_email = "test@tencent.com" - admin_position = "dev" + admin_position = "developer" contact_first_name = "test" contact_last_name = "test" contact_email = "test@tencent.com" contact_number = "12345678901" - contact_position = "dev" + contact_position = "developer" } } ``` diff --git a/tencentcloud/resource_tc_subnet.go b/tencentcloud/resource_tc_subnet.go index bc95621a7d..3c962c385a 100644 --- a/tencentcloud/resource_tc_subnet.go +++ b/tencentcloud/resource_tc_subnet.go @@ -4,20 +4,18 @@ Provide a resource to create a VPC subnet. Example Usage ```hcl -variable "availability_zone" { - default = "ap-guangzhou-3" -} +data "tencentcloud_availability_zones" "zones" {} -resource "tencentcloud_vpc" "foo" { - name = "guagua-ci-temp-test" +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { - availability_zone = var.availability_zone - name = "guagua-ci-temp-test" - vpc_id = tencentcloud_vpc.foo.id - cidr_block = "10.0.20.0/28" + vpc_id = tencentcloud_vpc.vpc.id + name = "subnet-example" + cidr_block = "10.0.0.0/16" + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name is_multicast = false } ``` diff --git a/tencentcloud/resource_tc_vpc.go b/tencentcloud/resource_tc_vpc.go index 1f08b484c2..db2cc50ca9 100644 --- a/tencentcloud/resource_tc_vpc.go +++ b/tencentcloud/resource_tc_vpc.go @@ -3,9 +3,11 @@ Provide a resource to create a VPC. Example Usage +Create a basic VPC + ```hcl -resource "tencentcloud_vpc" "foo" { - name = "ci-temp-test-updated" +resource "tencentcloud_vpc" "vpc" { + name = "tf-example" cidr_block = "10.0.0.0/16" dns_servers = ["119.29.29.29", "8.8.8.8"] is_multicast = false @@ -17,9 +19,10 @@ resource "tencentcloud_vpc" "foo" { ``` Using Assistant CIDR + ```hcl -resource "tencentcloud_vpc" "foo" { - name = "ci-temp-test-updated" +resource "tencentcloud_vpc" "vpc" { + name = "tf-example" cidr_block = "10.0.0.0/16" is_multicast = false assistant_cidrs = ["172.16.0.0/24"] diff --git a/tencentcloud/resource_tc_vpc_acl.go b/tencentcloud/resource_tc_vpc_acl.go index a75ff28ac2..03e486346b 100644 --- a/tencentcloud/resource_tc_vpc_acl.go +++ b/tencentcloud/resource_tc_vpc_acl.go @@ -4,20 +4,22 @@ Provide a resource to create a VPC ACL instance. Example Usage ```hcl -data "tencentcloud_vpc_instances" "default" { +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" } -resource "tencentcloud_vpc_acl" "foo" { - vpc_id = data.tencentcloud_vpc_instances.default.instance_list.0.vpc_id - name = "test_acl_update" - ingress = [ - "ACCEPT#192.168.1.0/24#800#TCP", - "ACCEPT#192.168.1.0/24#800-900#TCP", - ] - egress = [ - "ACCEPT#192.168.1.0/24#800#TCP", - "ACCEPT#192.168.1.0/24#800-900#TCP", - ] +resource "tencentcloud_vpc_acl" "example" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf-example" + ingress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] + egress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] } ``` diff --git a/tencentcloud/resource_tc_vpc_acl_attachment.go b/tencentcloud/resource_tc_vpc_acl_attachment.go index a0a15de97a..21a27ffa3f 100644 --- a/tencentcloud/resource_tc_vpc_acl_attachment.go +++ b/tencentcloud/resource_tc_vpc_acl_attachment.go @@ -4,24 +4,36 @@ Provide a resource to attach an existing subnet to Network ACL. Example Usage ```hcl -data "tencentcloud_vpc_instances" "id_instances" { +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name } -resource "tencentcloud_vpc_acl" "foo" { - vpc_id = data.tencentcloud_vpc_instances.id_instances.instance_list.0.vpc_id - name = "test_acl" - ingress = [ - "ACCEPT#192.168.1.0/24#800#TCP", - "ACCEPT#192.168.1.0/24#800-900#TCP", - ] - egress = [ - "ACCEPT#192.168.1.0/24#800#TCP", - "ACCEPT#192.168.1.0/24#800-900#TCP", - ] + +resource "tencentcloud_vpc_acl" "example" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf-example" + ingress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] + egress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] } resource "tencentcloud_vpc_acl_attachment" "attachment"{ - acl_id = tencentcloud_vpc_acl.foo.id - subnet_id = data.tencentcloud_vpc_instances.id_instances.instance_list[0].subnet_ids[0] + acl_id = tencentcloud_vpc_acl.example.id + subnet_id = tencentcloud_subnet.subnet.id } ``` diff --git a/tencentcloud/resource_tc_vpc_bandwidth_package.go b/tencentcloud/resource_tc_vpc_bandwidth_package.go index 8fa0627078..71e567a749 100644 --- a/tencentcloud/resource_tc_vpc_bandwidth_package.go +++ b/tencentcloud/resource_tc_vpc_bandwidth_package.go @@ -4,11 +4,11 @@ Provides a resource to create a vpc bandwidth_package Example Usage ```hcl -resource "tencentcloud_vpc_bandwidth_package" "bandwidth_package" { - network_type = "BGP" - charge_type = "TOP5_POSTPAID_BY_MONTH" - bandwidth_package_name = "test-001" - tags = { +resource "tencentcloud_vpc_bandwidth_package" "example" { + network_type = "BGP" + charge_type = "TOP5_POSTPAID_BY_MONTH" + bandwidth_package_name = "tf-example" + tags = { "createdBy" = "terraform" } } diff --git a/tencentcloud/resource_tc_vpc_bandwidth_package_attachment.go b/tencentcloud/resource_tc_vpc_bandwidth_package_attachment.go index 4332caa0e2..5454d4bcdb 100644 --- a/tencentcloud/resource_tc_vpc_bandwidth_package_attachment.go +++ b/tencentcloud/resource_tc_vpc_bandwidth_package_attachment.go @@ -4,14 +4,47 @@ Provides a resource to create a vpc bandwidth_package_attachment Example Usage ```hcl -resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_attachment" { - resource_id = "lb-dv1ai6ma" - bandwidth_package_id = "bwp-atmf0p9g" - network_type = "BGP" - resource_type = "LoadBalance" - protocol = "" +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name +} + +resource "tencentcloud_vpc_bandwidth_package" "example" { + network_type = "BGP" + charge_type = "TOP5_POSTPAID_BY_MONTH" + bandwidth_package_name = "tf-example" + tags = { + "createdBy" = "terraform" + } } +resource "tencentcloud_clb_instance" "example" { + network_type = "INTERNAL" + clb_name = "tf-example" + project_id = 0 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_vpc_bandwidth_package_attachment" "attachment" { + resource_id = tencentcloud_clb_instance.example.id + bandwidth_package_id = tencentcloud_vpc_bandwidth_package.example.id + network_type = "BGP" + resource_type = "LoadBalance" +} ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_vpc_bandwidth_package_attachment_test.go b/tencentcloud/resource_tc_vpc_bandwidth_package_attachment_test.go index 4bd0f076c2..357270c91e 100644 --- a/tencentcloud/resource_tc_vpc_bandwidth_package_attachment_test.go +++ b/tencentcloud/resource_tc_vpc_bandwidth_package_attachment_test.go @@ -56,7 +56,7 @@ func testAccCheckBandwidthPackageAttachmentDestroy(s *terraform.State) error { if !ok { return err } - fmt.Print(ee) + if ee.Code == "InvalidParameterValue.BandwidthPackageNotFound" { return nil } else { diff --git a/tencentcloud/resource_tc_vpc_classic_link_attachment.go b/tencentcloud/resource_tc_vpc_classic_link_attachment.go index 3e60cdc7a4..e7c927e2ac 100644 --- a/tencentcloud/resource_tc_vpc_classic_link_attachment.go +++ b/tencentcloud/resource_tc_vpc_classic_link_attachment.go @@ -4,9 +4,56 @@ Provides a resource to create a vpc classic_link_attachment Example Usage ```hcl +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +data "tencentcloud_instance_types" "instance_types" { + filter { + name = "zone" + values = [data.tencentcloud_availability_zones.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" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_instance" "example" { + instance_name = "tf-example" + availability_zone = data.tencentcloud_availability_zones.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" + disable_security_service = true + disable_monitor_service = true + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + resource "tencentcloud_vpc_classic_link_attachment" "classic_link_attachment" { - vpc_id = "vpc-hdvfe0g1" - instance_ids = ["ins-ceynqvnu"] + vpc_id = tencentcloud_vpc.vpc.id + instance_ids = [tencentcloud_instance.example.id] } ``` diff --git a/tencentcloud/resource_tc_vpc_dhcp_associate_address.go b/tencentcloud/resource_tc_vpc_dhcp_associate_address.go index 6950c89c98..e6ecc6d788 100644 --- a/tencentcloud/resource_tc_vpc_dhcp_associate_address.go +++ b/tencentcloud/resource_tc_vpc_dhcp_associate_address.go @@ -4,9 +4,34 @@ Provides a resource to create a vpc dhcp_associate_address Example Usage ```hcl -resource "tencentcloud_vpc_dhcp_associate_address" "dhcp_associate_address" { - dhcp_ip_id = tencentcloud_vpc_dhcp_ip.dhcp_ip.id - address_ip = "111.230.72.219" +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_vpc_dhcp_ip" "example" { + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + dhcp_ip_name = "tf-example" +} + +resource "tencentcloud_eip" "eip" { + name = "example-eip" +} + +resource "tencentcloud_vpc_dhcp_associate_address" "example" { + dhcp_ip_id = tencentcloud_vpc_dhcp_ip.example.id + address_ip = tencentcloud_eip.eip.public_ip } ``` diff --git a/tencentcloud/resource_tc_vpc_dhcp_ip.go b/tencentcloud/resource_tc_vpc_dhcp_ip.go index 9eb50b7339..71c86dc0b3 100644 --- a/tencentcloud/resource_tc_vpc_dhcp_ip.go +++ b/tencentcloud/resource_tc_vpc_dhcp_ip.go @@ -4,10 +4,25 @@ Provides a resource to create a vpc dhcp_ip Example Usage ```hcl -resource "tencentcloud_vpc_dhcp_ip" "dhcp_ip" { - vpc_id = "vpc-1yg5ua6l" - subnet_id = "subnet-h7av55g8" - dhcp_ip_name = "terraform-test" +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_vpc_dhcp_ip" "example" { + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + dhcp_ip_name = "tf-example" } ``` diff --git a/tencentcloud/resource_tc_vpc_flow_log.go b/tencentcloud/resource_tc_vpc_flow_log.go index 26c617c9ec..6bb0f4f1c8 100644 --- a/tencentcloud/resource_tc_vpc_flow_log.go +++ b/tencentcloud/resource_tc_vpc_flow_log.go @@ -1,20 +1,104 @@ /* Provides a resource to create a vpc flow_log +~> **NOTE:** The cloud server instance specifications that support stream log collection include: M6ce, M6p, SA3se, S4m, DA3, ITA3, I6t, I6, S5se, SA2, SK1, S4, S5, SN3ne, S3ne, S2ne, SA2a, S3ne, SW3a, SW3b, SW3ne, ITA3, IT5c, IT5, IT5c, IT3, I3, D3, DA2, D2, M6, MA2, M4, C6, IT3a, IT3b, IT3c, C4ne, CN3ne, C3ne, GI1, PNV4, GNV4v, GNV4, GT4, GI3X, GN7, GN7vw. + +~> **NOTE:** The following models no longer support the collection of new stream logs, and the stock stream logs will no longer be reported for data from July 25, 2022: Standard models: S3, SA1, S2, S1;Memory type: M3, M2, M1;Calculation type: C4, CN3, C3, C2;Batch calculation type: BC1, BS1;HPCC: HCCIC5, HCCG5v. + Example Usage ```hcl -resource "tencentcloud_vpc_flow_log" "flow_log" { - flow_log_name = "foo" - resource_type = "NETWORKINTERFACE" - resource_id = "eni-xxxxxxxx" - traffic_type = "ALL" - vpc_id = "vpc-xxxxxxxx" - flow_log_description = "My testing log" - cloud_log_id = "a1b2c3d4-e5f6a7b8-c9d0e1f2-a3b4c5d6" - storage_type = "cls" - tags = { - "createdBy" = "terraform" +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +data "tencentcloud_instance_types" "instance_types" { + filter { + name = "zone" + values = [data.tencentcloud_availability_zones.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} + +resource "tencentcloud_cls_logset" "logset" { + logset_name = "delogsetmo" + tags = { + "test" = "test" + } +} + +resource "tencentcloud_cls_topic" "topic" { + topic_name = "topic" + logset_id = tencentcloud_cls_logset.logset.id + auto_split = false + max_split_partitions = 20 + partition_count = 1 + period = 10 + storage_type = "hot" + tags = { + "test" = "test", + } +} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-flow-log-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "vpc-flow-log-subnet" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eni" "example" { + name = "vpc-flow-log-eni" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc" + ipv4_count = 1 +} + +resource "tencentcloud_instance" "example" { + instance_name = "ci-test-eni-attach" + availability_zone = data.tencentcloud_availability_zones.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" + disable_security_service = true + disable_monitor_service = true + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + +resource "tencentcloud_eni_attachment" "example" { + eni_id = tencentcloud_eni.example.id + instance_id = tencentcloud_instance.example.id +} + +resource "tencentcloud_vpc_flow_log" "example" { + flow_log_name = "tf-example-vpc-flow-log" + resource_type = "NETWORKINTERFACE" + resource_id = tencentcloud_eni_attachment.example.eni_id + traffic_type = "ACCEPT" + vpc_id = tencentcloud_vpc.vpc.id + flow_log_description = "this is a testing flow log" + cloud_log_id = tencentcloud_cls_topic.topic.id + storage_type = "cls" + tags = { + "testKey" = "testValue" } } ``` diff --git a/tencentcloud/resource_tc_vpc_flow_log_config.go b/tencentcloud/resource_tc_vpc_flow_log_config.go index 542cb22f36..4df927fe47 100644 --- a/tencentcloud/resource_tc_vpc_flow_log_config.go +++ b/tencentcloud/resource_tc_vpc_flow_log_config.go @@ -3,10 +3,115 @@ Provides a resource to create a vpc flow_log_config Example Usage +If disable FlowLogs + +```hcl +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +data "tencentcloud_instance_types" "instance_types" { + filter { + name = "zone" + values = [data.tencentcloud_availability_zones.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} + +resource "tencentcloud_cls_logset" "logset" { + logset_name = "delogsetmo" + tags = { + "test" = "test" + } +} + +resource "tencentcloud_cls_topic" "topic" { + topic_name = "topic" + logset_id = tencentcloud_cls_logset.logset.id + auto_split = false + max_split_partitions = 20 + partition_count = 1 + period = 10 + storage_type = "hot" + tags = { + "test" = "test", + } +} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-flow-log-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "vpc-flow-log-subnet" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eni" "example" { + name = "vpc-flow-log-eni" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc" + ipv4_count = 1 +} + +resource "tencentcloud_instance" "example" { + instance_name = "ci-test-eni-attach" + availability_zone = data.tencentcloud_availability_zones.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" + disable_security_service = true + disable_monitor_service = true + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + +resource "tencentcloud_eni_attachment" "example" { + eni_id = tencentcloud_eni.example.id + instance_id = tencentcloud_instance.example.id +} + +resource "tencentcloud_vpc_flow_log" "example" { + flow_log_name = "tf-example-vpc-flow-log" + resource_type = "NETWORKINTERFACE" + resource_id = tencentcloud_eni_attachment.example.eni_id + traffic_type = "ACCEPT" + vpc_id = tencentcloud_vpc.vpc.id + flow_log_description = "this is a testing flow log" + cloud_log_id = tencentcloud_cls_topic.topic.id + storage_type = "cls" + tags = { + "testKey" = "testValue" + } +} + +resource "tencentcloud_vpc_flow_log_config" "config" { + flow_log_id = tencentcloud_vpc_flow_log.example.id + enable = false +} +``` + +If enable FlowLogs + ```hcl -resource "tencentcloud_vpc_flow_log_config" "flow_log_config" { - flow_log_id = "fl-geg2keoj" - enable = false +resource "tencentcloud_vpc_flow_log_config" "config" { + flow_log_id = tencentcloud_vpc_flow_log.example.id + enable = true } ``` diff --git a/tencentcloud/resource_tc_vpc_ipv6_cidr_block.go b/tencentcloud/resource_tc_vpc_ipv6_cidr_block.go index 1f0c1794d4..31c022f622 100644 --- a/tencentcloud/resource_tc_vpc_ipv6_cidr_block.go +++ b/tencentcloud/resource_tc_vpc_ipv6_cidr_block.go @@ -4,14 +4,13 @@ Provides a resource to create a vpc ipv6_cidr_block Example Usage ```hcl -resource "tencentcloud_vpc" "cidr-block" { - name = "ipv6-cidr-block-for-test" - cidr_block = "10.0.0.0/16" - is_multicast = false +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" } -resource "tencentcloud_vpc_ipv6_cidr_block" "ipv6_cidr_block" { - vpc_id = tencentcloud_vpc.cidr-block.id +resource "tencentcloud_vpc_ipv6_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id } ``` diff --git a/tencentcloud/resource_tc_vpc_ipv6_eni_address.go b/tencentcloud/resource_tc_vpc_ipv6_eni_address.go index 2cf2c32033..86ae4ecd17 100644 --- a/tencentcloud/resource_tc_vpc_ipv6_eni_address.go +++ b/tencentcloud/resource_tc_vpc_ipv6_eni_address.go @@ -4,12 +4,39 @@ Provides a resource to create a vpc ipv6_eni_address Example Usage ```hcl +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eni" "eni" { + name = "eni-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc." + ipv4_count = 1 +} + +resource "tencentcloud_vpc_ipv6_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id +} + resource "tencentcloud_vpc_ipv6_eni_address" "ipv6_eni_address" { - vpc_id = "vpc-7w3kgnpl" - network_interface_id = "eni-pzl7fz37" + vpc_id = tencentcloud_vpc.vpc.id + network_interface_id = tencentcloud_eni.eni.id ipv6_addresses { - address = "2402:4e00:1019:6a7b:0:994e:7cd7:fb46" - description = "test123" + address = tencentcloud_vpc_ipv6_cidr_block.example.ipv6_cidr_block + description = "desc." } } ``` diff --git a/tencentcloud/resource_tc_vpc_ipv6_eni_address_test.go b/tencentcloud/resource_tc_vpc_ipv6_eni_address_test.go index 5a52109f03..f7d2be996c 100644 --- a/tencentcloud/resource_tc_vpc_ipv6_eni_address_test.go +++ b/tencentcloud/resource_tc_vpc_ipv6_eni_address_test.go @@ -62,7 +62,7 @@ func TestAccTencentCloudVpcIpv6EniAddressResource_basic(t *testing.T) { // if !ok { // return err // } -// fmt.Print(ee) + // if ee.Code == "InvalidParameterValue.BandwidthPackageNotFound" { // return nil // } else { diff --git a/tencentcloud/resource_tc_vpc_ipv6_subnet_cidr_block.go b/tencentcloud/resource_tc_vpc_ipv6_subnet_cidr_block.go index 155412d14a..1dfe7d8a1e 100644 --- a/tencentcloud/resource_tc_vpc_ipv6_subnet_cidr_block.go +++ b/tencentcloud/resource_tc_vpc_ipv6_subnet_cidr_block.go @@ -4,11 +4,30 @@ Provides a resource to create a vpc ipv6_subnet_cidr_block Example Usage ```hcl -resource "tencentcloud_vpc_ipv6_subnet_cidr_block" "ipv6_subnet_cidr_block" { - vpc_id = "vpc-7w3kgnpl" +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_vpc_ipv6_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id +} + +resource "tencentcloud_vpc_ipv6_subnet_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id ipv6_subnet_cidr_blocks { - subnet_id = "subnet-plg028y8" - ipv6_cidr_block = "2402:4e00:1019:6a7b::/64" + subnet_id = tencentcloud_subnet.subnet.id + ipv6_cidr_block = tencentcloud_vpc_ipv6_cidr_block.example.ipv6_cidr_block } } ``` diff --git a/tencentcloud/resource_tc_vpc_local_gateway.go b/tencentcloud/resource_tc_vpc_local_gateway.go index 5ae741cbfc..d8a5c7a54d 100644 --- a/tencentcloud/resource_tc_vpc_local_gateway.go +++ b/tencentcloud/resource_tc_vpc_local_gateway.go @@ -4,9 +4,14 @@ Provides a resource to create a vpc local_gateway Example Usage ```hcl -resource "tencentcloud_vpc_local_gateway" "local_gateway" { - local_gateway_name = "local-gw-test" - vpc_id = "vpc-lh4nqig9" +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_vpc_local_gateway" "example" { + local_gateway_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id cdc_id = "cluster-j9gyu1iy" } ``` diff --git a/tencentcloud/resource_tc_vpc_net_detect.go b/tencentcloud/resource_tc_vpc_net_detect.go index b1fb1de234..ee10aac2f6 100644 --- a/tencentcloud/resource_tc_vpc_net_detect.go +++ b/tencentcloud/resource_tc_vpc_net_detect.go @@ -3,14 +3,204 @@ Provides a resource to create a vpc net_detect Example Usage +Create a basic Net Detect + +```hcl +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + detect_destination_ip = [ + "10.0.0.1", + "10.0.0.2", + ] +} +``` + +If `next_hop_type` is `VPN` + +```hcl +resource "tencentcloud_vpn_gateway" "vpn" { + name = "tf-example" + bandwidth = 100 + zone = data.tencentcloud_availability_zones.zones.zones.0.name + type = "SSL" + vpc_id = tencentcloud_vpc.vpc.id + + tags = { + test = "test" + } +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "VPN" + next_hop_destination = tencentcloud_vpn_gateway.vpn.id + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + +If `next_hop_type` is `DIRECTCONNECT` + +```hcl +resource "tencentcloud_dc_gateway" "example" { + name = "ci-cdg-vpc-test" + network_instance_id = tencentcloud_vpc.vpc.id + network_type = "VPC" + gateway_type = "NAT" +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "DIRECTCONNECT" + next_hop_destination = tencentcloud_dc_gateway.example.id + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + +If `next_hop_type` is `NAT` + ```hcl -resource "tencentcloud_vpc_net_detect" "net_detect" { - net_detect_name = "terrform-test" - vpc_id = "vpc-4owdpnwr" - subnet_id = "subnet-c1l35990" - next_hop_destination = "172.16.128.57" +resource "tencentcloud_eip" "eip_example1" { + name = "tf_nat_gateway_eip1" +} + +resource "tencentcloud_eip" "eip_example2" { + name = "tf_nat_gateway_eip2" +} + +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 + assigned_eip_set = [ + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, + ] + tags = { + tf_tag_key = "tf_tag_value" + } +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "NAT" + next_hop_destination = tencentcloud_nat_gateway.example.id + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + +If `next_hop_type` is `NORMAL_CVM` + +```hcl +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.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} + +resource "tencentcloud_instance" "example" { + instance_name = "tf_example" + availability_zone = data.tencentcloud_availability_zones.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 +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id next_hop_type = "NORMAL_CVM" - subnet_id = "subnet-c1l35990" + next_hop_destination = tencentcloud_instance.example.private_ip + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + +If `next_hop_type` is `CCN` + +```hcl +resource "tencentcloud_ccn" "example" { + name = "tf-example" + description = "desc." + qos = "AU" + charge_type = "POSTPAID" + bandwidth_limit_type = "OUTER_REGION_LIMIT" +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "CCN" + next_hop_destination = tencentcloud_ccn.example.id + detect_destination_ip = [ + "172.10.0.1", + "172.10.0.2", + ] +} +``` + +If `next_hop_type` is `NONEXTHOP` + +```hcl +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "NONEXTHOP" detect_destination_ip = [ "10.0.0.1", "10.0.0.2", diff --git a/tencentcloud/resource_tc_vpc_network_acl_quintuple.go b/tencentcloud/resource_tc_vpc_network_acl_quintuple.go index 46c11ebb19..d7b093fd17 100644 --- a/tencentcloud/resource_tc_vpc_network_acl_quintuple.go +++ b/tencentcloud/resource_tc_vpc_network_acl_quintuple.go @@ -4,36 +4,60 @@ Provides a resource to create a vpc network_acl_quintuple Example Usage ```hcl +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name +} + +resource "tencentcloud_vpc_acl" "example" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf-example" + ingress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] + egress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] +} + resource "tencentcloud_vpc_network_acl_quintuple" "network_acl_quintuple" { - network_acl_id = "" + network_acl_id = tencentcloud_vpc_acl.example.id network_acl_quintuple_set { - ingress { - protocol = "" - description = "" - source_port = "" - source_cidr = "" - destination_port = "" - destination_cidr = "" - action = "" - network_acl_quintuple_entry_id = "" - priority = - create_time = "" - network_acl_direction = "" - } - egress { - protocol = "" - description = "" - source_port = "" - source_cidr = "" - destination_port = "" - destination_cidr = "" - action = "" - network_acl_quintuple_entry_id = "" - priority = - create_time = "" - network_acl_direction = "" - } - + ingress { + protocol = "TCP" + description = "ingress desc." + source_port = "80" + source_cidr = "192.168.0.0/24" + destination_port = "8080" + destination_cidr = "192.168.0.0/24" + action = "DROP" + network_acl_quintuple_entry_id = "acli45-q1phngkz" + priority = 1 + network_acl_direction = "INGRESS" + } + egress { + protocol = "TCP" + description = "egress desc." + source_port = "80" + source_cidr = "192.168.0.0/24" + destination_port = "8080" + destination_cidr = "192.168.0.0/24" + action = "DROP" + network_acl_quintuple_entry_id = "acli45-q1phngkz" + priority = 1 + network_acl_direction = "EGRESS" + } } } ``` diff --git a/tencentcloud/resource_tc_vpc_notify_routes.go b/tencentcloud/resource_tc_vpc_notify_routes.go index dadf9a2e1d..561f4a18cb 100644 --- a/tencentcloud/resource_tc_vpc_notify_routes.go +++ b/tencentcloud/resource_tc_vpc_notify_routes.go @@ -4,9 +4,19 @@ Provides a resource to create a vpc notify_routes Example Usage ```hcl -resource "tencentcloud_vpc_notify_routes" "notify_routes" { - route_table_id = "" - route_item_ids = [] +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_route_table" "route_table" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf-example" +} + +resource "tencentcloud_vpc_notify_routes" "example" { + route_table_id = tencentcloud_route_table.route_table.id + route_item_ids = ["rti-i8bap903"] } ``` diff --git a/tencentcloud/resource_tc_vpc_resume_snapshot_instance.go b/tencentcloud/resource_tc_vpc_resume_snapshot_instance.go index 2d63b5c941..3e3d56a050 100644 --- a/tencentcloud/resource_tc_vpc_resume_snapshot_instance.go +++ b/tencentcloud/resource_tc_vpc_resume_snapshot_instance.go @@ -3,13 +3,60 @@ Provides a resource to create a vpc resume_snapshot_instance Example Usage +Basic example + ```hcl resource "tencentcloud_vpc_resume_snapshot_instance" "resume_snapshot_instance" { snapshot_policy_id = "sspolicy-1t6cobbv" - snapshot_file_id = "ssfile-test" - instance_id = "policy-1t6cob" + snapshot_file_id = "ssfile-emtabuwu2z" + instance_id = "ntrgm89v" } ``` + +Complete example + +```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" +} +``` + */ package tencentcloud diff --git a/tencentcloud/resource_tc_vpc_snapshot_policy.go b/tencentcloud/resource_tc_vpc_snapshot_policy.go index 570053864f..34b47f2c8c 100644 --- a/tencentcloud/resource_tc_vpc_snapshot_policy.go +++ b/tencentcloud/resource_tc_vpc_snapshot_policy.go @@ -4,10 +4,15 @@ Provides a resource to create a vpc snapshot_policy Example Usage ```hcl -resource "tencentcloud_vpc_snapshot_policy" "snapshot_policy" { - snapshot_policy_name = "terraform-test" +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 = "cos-lock-1308919341" + cos_bucket = tencentcloud_cos_bucket.example.bucket cos_region = "ap-guangzhou" create_new_cos = false keep_time = 2 @@ -18,11 +23,11 @@ resource "tencentcloud_vpc_snapshot_policy" "snapshot_policy" { } backup_policies { backup_day = "tuesday" - backup_time = "02:03:03" + backup_time = "01:00:00" } backup_policies { backup_day = "wednesday" - backup_time = "04:13:23" + backup_time = "02:00:00" } } ``` diff --git a/tencentcloud/resource_tc_vpc_snapshot_policy_attachment.go b/tencentcloud/resource_tc_vpc_snapshot_policy_attachment.go index 7e835f9e94..5b6c5c1b05 100644 --- a/tencentcloud/resource_tc_vpc_snapshot_policy_attachment.go +++ b/tencentcloud/resource_tc_vpc_snapshot_policy_attachment.go @@ -4,20 +4,46 @@ Provides a resource to create a vpc snapshot_policy_attachment Example Usage ```hcl -resource "tencentcloud_vpc_snapshot_policy_attachment" "snapshot_policy_attachment" { - snapshot_policy_id = "sspolicy-1t6cobbv" +resource "tencentcloud_cos_bucket" "example" { + bucket = "tf-example-1308919341" + acl = "private" +} - instances { - instance_id = "sg-r8ibzbd9" - instance_name = "cm-eks-cls-eizsc1iw-security-group" - instance_region = "ap-guangzhou" - instance_type = "securitygroup" +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_security_group" "example" { + name = "tf-example" + description = "desc." +} + +resource "tencentcloud_vpc_snapshot_policy_attachment" "attachment" { + snapshot_policy_id = tencentcloud_vpc_snapshot_policy.example.id + instances { - instance_id = "sg-k3tn70lh" - instance_name = "keep-ci-temp-test-sg" - instance_region = "ap-guangzhou" instance_type = "securitygroup" + instance_id = tencentcloud_security_group.example.id + instance_name = "tf-example" + instance_region = "ap-guangzhou" } } ``` diff --git a/tencentcloud/resource_tc_vpc_snapshot_policy_config.go b/tencentcloud/resource_tc_vpc_snapshot_policy_config.go index ac79292204..d76efe5493 100644 --- a/tencentcloud/resource_tc_vpc_snapshot_policy_config.go +++ b/tencentcloud/resource_tc_vpc_snapshot_policy_config.go @@ -4,8 +4,35 @@ Provides a resource to create a vpc snapshot_policy_config Example Usage ```hcl -resource "tencentcloud_vpc_snapshot_policy_config" "snapshot_policy_config" { - snapshot_policy_id = "sspolicy-1t6cobbv" +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_snapshot_policy_config" "config" { + snapshot_policy_id = tencentcloud_vpc_snapshot_policy.example.id enable = false } ``` diff --git a/tencentcloud/resource_tc_vpc_traffic_package.go b/tencentcloud/resource_tc_vpc_traffic_package.go index c77d6f9e06..d4587db14e 100644 --- a/tencentcloud/resource_tc_vpc_traffic_package.go +++ b/tencentcloud/resource_tc_vpc_traffic_package.go @@ -4,7 +4,7 @@ Provides a resource to create a vpc traffic_package Example Usage ```hcl -resource "tencentcloud_vpc_traffic_package" "traffic_package" { +resource "tencentcloud_vpc_traffic_package" "example" { traffic_amount = 10 } ``` diff --git a/website/docs/r/as_attachment.html.markdown b/website/docs/r/as_attachment.html.markdown index c4ac071d19..9bcfc439f6 100644 --- a/website/docs/r/as_attachment.html.markdown +++ b/website/docs/r/as_attachment.html.markdown @@ -14,9 +14,76 @@ Provides a resource to attach or detach CVM instances to a specified scaling gro ## Example Usage ```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_instance" + 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 + allocate_public_ip = true + internet_max_bandwidth_out = 10 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + resource "tencentcloud_as_attachment" "attachment" { - scaling_group_id = "sg-afasfa" - instance_ids = ["ins-01", "ins-02"] + scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = [tencentcloud_instance.example.id] } ``` diff --git a/website/docs/r/as_complete_lifecycle.html.markdown b/website/docs/r/as_complete_lifecycle.html.markdown index 45e987f366..2de363d5cf 100644 --- a/website/docs/r/as_complete_lifecycle.html.markdown +++ b/website/docs/r/as_complete_lifecycle.html.markdown @@ -14,10 +14,86 @@ Provides a resource to create a as complete_lifecycle ## Example Usage ```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_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + lifecycle_hook_name = "tf-as-lifecycle-hook" + lifecycle_transition = "INSTANCE_LAUNCHING" + default_result = "CONTINUE" + heartbeat_timeout = 500 + notification_metadata = "tf test" +} + +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 +} + resource "tencentcloud_as_complete_lifecycle" "complete_lifecycle" { - lifecycle_hook_id = "ash-xxxxxxxx" + lifecycle_hook_id = tencentcloud_as_lifecycle_hook.example.id + instance_id = tencentcloud_instance.example.id lifecycle_action_result = "CONTINUE" - instance_id = "ins-xxxxxxxx" } ``` diff --git a/website/docs/r/as_execute_scaling_policy.html.markdown b/website/docs/r/as_execute_scaling_policy.html.markdown index bfff349554..952d6bc063 100644 --- a/website/docs/r/as_execute_scaling_policy.html.markdown +++ b/website/docs/r/as_execute_scaling_policy.html.markdown @@ -14,8 +14,62 @@ Provides a resource to create a as execute_scaling_policy ## Example Usage ```hcl -resource "tencentcloud_as_execute_scaling_policy" "execute_scaling_policy" { - auto_scaling_policy_id = "asp-519acdug" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "as" +} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +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 = 4 + min_size = 1 + desired_capacity = 2 + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] +} + +resource "tencentcloud_as_scaling_policy" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + policy_name = "tf-as-scaling-policy" + adjustment_type = "EXACT_CAPACITY" + adjustment_value = 0 + comparison_operator = "GREATER_THAN" + metric_name = "CPU_UTILIZATION" + threshold = 80 + period = 300 + continuous_time = 10 + statistic = "AVERAGE" + cooldown = 360 +} + +resource "tencentcloud_as_execute_scaling_policy" "example" { + auto_scaling_policy_id = tencentcloud_as_scaling_policy.example.id honor_cooldown = false trigger_source = "API" } diff --git a/website/docs/r/as_lifecycle_hook.html.markdown b/website/docs/r/as_lifecycle_hook.html.markdown index a1bdccf702..ae89f9a18f 100644 --- a/website/docs/r/as_lifecycle_hook.html.markdown +++ b/website/docs/r/as_lifecycle_hook.html.markdown @@ -13,9 +13,63 @@ Provides a resource for an AS (Auto scaling) lifecycle hook. ## Example Usage +### Create a basic LifecycleHook + +```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)" +} + +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_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + lifecycle_hook_name = "tf-as-lifecycle-hook" + lifecycle_transition = "INSTANCE_LAUNCHING" + default_result = "CONTINUE" + heartbeat_timeout = 500 + notification_metadata = "tf test" +} +``` + + + ```hcl -resource "tencentcloud_as_lifecycle_hook" "lifecycle_hook" { - scaling_group_id = "sg-12af45" +resource "tencentcloud_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id lifecycle_hook_name = "tf-as-lifecycle-hook" lifecycle_transition = "INSTANCE_LAUNCHING" default_result = "CONTINUE" @@ -26,6 +80,21 @@ resource "tencentcloud_as_lifecycle_hook" "lifecycle_hook" { } ``` + + +```hcl +resource "tencentcloud_as_lifecycle_hook" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id + lifecycle_hook_name = "tf-as-lifecycle-hook" + lifecycle_transition = "INSTANCE_LAUNCHING" + default_result = "CONTINUE" + heartbeat_timeout = 500 + notification_metadata = "tf test" + notification_target_type = "CMQ_TOPIC" + notification_topic_name = "lifcyclehook" +} +``` + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/as_notification.html.markdown b/website/docs/r/as_notification.html.markdown index 4db8dc2a7d..48e2fdd536 100644 --- a/website/docs/r/as_notification.html.markdown +++ b/website/docs/r/as_notification.html.markdown @@ -14,10 +14,56 @@ Provides a resource for an AS (Auto scaling) notification. ## Example Usage ```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)" +} + +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_cam_group" "example" { + name = "tf-example" + remark = "desc." +} + resource "tencentcloud_as_notification" "as_notification" { - scaling_group_id = "sg-12af45" - notification_types = ["SCALE_OUT_FAILED", "SCALE_IN_SUCCESSFUL", "SCALE_IN_FAILED", "REPLACE_UNHEALTHY_INSTANCE_FAILED"] - notification_user_group_ids = ["76955"] + scaling_group_id = tencentcloud_as_scaling_group.example.id + notification_types = [ + "SCALE_OUT_SUCCESSFUL", "SCALE_OUT_FAILED", "SCALE_IN_FAILED", "REPLACE_UNHEALTHY_INSTANCE_SUCCESSFUL", "REPLACE_UNHEALTHY_INSTANCE_FAILED" + ] + notification_user_group_ids = [tencentcloud_cam_group.example.id] } ``` diff --git a/website/docs/r/as_protect_instances.html.markdown b/website/docs/r/as_protect_instances.html.markdown index b1376d2bd1..4cbf46f2db 100644 --- a/website/docs/r/as_protect_instances.html.markdown +++ b/website/docs/r/as_protect_instances.html.markdown @@ -14,13 +14,97 @@ Provides a resource to create a as protect_instances ## Example Usage ```hcl -resource "tencentcloud_as_protect_instances" "protect_instances" { - auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - instance_ids = ["ins-xxxxx"] +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 } ``` +### Or close protect + +```hcl +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 = false +} +``` + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/as_remove_instances.html.markdown b/website/docs/r/as_remove_instances.html.markdown index 3a3c24aaa5..d1a46240ab 100644 --- a/website/docs/r/as_remove_instances.html.markdown +++ b/website/docs/r/as_remove_instances.html.markdown @@ -14,9 +14,83 @@ Provides a resource to create a as remove_instances ## Example Usage ```hcl -resource "tencentcloud_as_remove_instances" "remove_instances" { - auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - instance_ids = ["ins-xxxxxx"] +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] +} + +# Remove Instance +resource "tencentcloud_as_remove_instances" "remove" { + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = tencentcloud_as_attachment.attachment.instance_ids } ``` diff --git a/website/docs/r/as_scale_in_instances.html.markdown b/website/docs/r/as_scale_in_instances.html.markdown index d50b6b4c2c..b4be0e15c1 100644 --- a/website/docs/r/as_scale_in_instances.html.markdown +++ b/website/docs/r/as_scale_in_instances.html.markdown @@ -14,8 +14,48 @@ Provides a resource to create a as scale_in_instances ## Example Usage ```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)" +} + +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 = 4 + min_size = 1 + desired_capacity = 2 + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] +} + resource "tencentcloud_as_scale_in_instances" "scale_in_instances" { - auto_scaling_group_id = "asg-519acdug" + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id scale_in_number = 1 } ``` diff --git a/website/docs/r/as_scale_out_instances.html.markdown b/website/docs/r/as_scale_out_instances.html.markdown index dbe7d64153..40dc224120 100644 --- a/website/docs/r/as_scale_out_instances.html.markdown +++ b/website/docs/r/as_scale_out_instances.html.markdown @@ -14,9 +14,49 @@ Provides a resource to create a as scale_out_instances ## Example Usage ```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)" +} + +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 = 4 + min_size = 0 + desired_capacity = 2 + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] +} + resource "tencentcloud_as_scale_out_instances" "scale_out_instances" { - auto_scaling_group_id = "asg-519acdug" - scale_out_number = 1 + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + scale_out_number = 2 } ``` diff --git a/website/docs/r/as_scaling_config.html.markdown b/website/docs/r/as_scaling_config.html.markdown index 4af500b319..00c5fe185c 100644 --- a/website/docs/r/as_scaling_config.html.markdown +++ b/website/docs/r/as_scaling_config.html.markdown @@ -16,9 +16,14 @@ Provides a resource to create a configuration for an AS (Auto scaling) instance. ## Example Usage ```hcl -resource "tencentcloud_as_scaling_config" "launch_configuration" { - configuration_name = "launch-configuration" - image_id = "img-9qabwvbn" +data "tencentcloud_images" "example" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +resource "tencentcloud_as_scaling_config" "example" { + configuration_name = "example-launch-configuration" + image_id = data.tencentcloud_images.example.images.0.image_id instance_types = ["SA1.SMALL1"] project_id = 0 system_disk_type = "CLOUD_PREMIUM" @@ -32,23 +37,28 @@ resource "tencentcloud_as_scaling_config" "launch_configuration" { internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR" internet_max_bandwidth_out = 10 public_ip_assigned = true - password = "test123#" + password = "Test@123#" enhanced_security_service = false enhanced_monitor_service = false user_data = "dGVzdA==" instance_tags = { - tag = "as" + tag = "example" } } ``` -### Using SPOT charge type +### charge type ```hcl -resource "tencentcloud_as_scaling_config" "launch_configuration" { +data "tencentcloud_images" "example" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +resource "tencentcloud_as_scaling_config" "example" { configuration_name = "launch-configuration" - image_id = "img-9qabwvbn" + image_id = data.tencentcloud_images.example.images.0.image_id instance_types = ["SA1.SMALL1"] instance_charge_type = "SPOTPAID" spot_instance_type = "one-time" diff --git a/website/docs/r/as_scaling_group.html.markdown b/website/docs/r/as_scaling_group.html.markdown index d1d001c898..ce7ab4db4a 100644 --- a/website/docs/r/as_scaling_group.html.markdown +++ b/website/docs/r/as_scaling_group.html.markdown @@ -13,14 +13,85 @@ Provides a resource to create a group of AS (Auto scaling) instances. ## Example Usage +### Create a basic Scaling Group + +```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)" +} + +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] +} +``` + +### Create a complete Scaling Group + ```hcl -resource "tencentcloud_as_scaling_group" "scaling_group" { - scaling_group_name = "tf-as-scaling-group" - configuration_id = "asc-oqio4yyj" +resource "tencentcloud_clb_instance" "example" { + network_type = "INTERNAL" + clb_name = "clb-example" + project_id = 0 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + + tags = { + test = "tf" + } +} + +resource "tencentcloud_clb_listener" "example" { + clb_id = tencentcloud_clb_instance.example.id + listener_name = "listener-example" + port = 80 + protocol = "HTTP" +} + +resource "tencentcloud_clb_listener_rule" "example" { + listener_id = tencentcloud_clb_listener.example.listener_id + clb_id = tencentcloud_clb_instance.example.id + domain = "foo.net" + url = "/bar" +} + +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 = "vpc-3efmz0z" - subnet_ids = ["subnet-mc3egos"] + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] project_id = 0 default_cooldown = 400 desired_capacity = 1 @@ -28,15 +99,19 @@ resource "tencentcloud_as_scaling_group" "scaling_group" { retry_policy = "INCREMENTAL_INTERVALS" forward_balancer_ids { - load_balancer_id = "lb-hk693b1l" - listener_id = "lbl-81wr497k" - rule_id = "loc-kiodx943" + load_balancer_id = tencentcloud_clb_instance.example.id + listener_id = tencentcloud_clb_listener.example.listener_id + rule_id = tencentcloud_clb_listener_rule.example.rule_id target_attribute { port = 80 weight = 90 } } + + tags = { + "createBy" = "tfExample" + } } ``` diff --git a/website/docs/r/as_scaling_group_status.html.markdown b/website/docs/r/as_scaling_group_status.html.markdown index fab2c31cbe..120005df3e 100644 --- a/website/docs/r/as_scaling_group_status.html.markdown +++ b/website/docs/r/as_scaling_group_status.html.markdown @@ -13,13 +13,63 @@ Provides a resource to set as scaling_group status ## Example Usage +### Deactivate Scaling Group + ```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)" +} + +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_as_scaling_group_status" "scaling_group_status" { - auto_scaling_group_id = "asg-519acdug" + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id enable = false } ``` +### Enable Scaling Group + +```hcl +resource "tencentcloud_as_scaling_group_status" "scaling_group_status" { + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + enable = true +} +``` + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/as_scaling_policy.html.markdown b/website/docs/r/as_scaling_policy.html.markdown index 1e8f505c44..764c84918f 100644 --- a/website/docs/r/as_scaling_policy.html.markdown +++ b/website/docs/r/as_scaling_policy.html.markdown @@ -14,8 +14,47 @@ Provides a resource for an AS (Auto scaling) policy. ## Example Usage ```hcl -resource "tencentcloud_as_scaling_policy" "scaling_policy" { - scaling_group_id = "asg-n32ymck2" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "as" +} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +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_as_scaling_policy" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id policy_name = "tf-as-scaling-policy" adjustment_type = "EXACT_CAPACITY" adjustment_value = 0 diff --git a/website/docs/r/as_schedule.html.markdown b/website/docs/r/as_schedule.html.markdown index 0c0e1d3810..08e848ea42 100644 --- a/website/docs/r/as_schedule.html.markdown +++ b/website/docs/r/as_schedule.html.markdown @@ -14,8 +14,47 @@ Provides a resource for an AS (Auto scaling) schedule. ## Example Usage ```hcl -resource "tencentcloud_as_schedule" "schedule" { - scaling_group_id = "sg-12af45" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "as" +} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + os_name = "TencentOS Server 3.2 (Final)" +} + +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_as_schedule" "example" { + scaling_group_id = tencentcloud_as_scaling_group.example.id schedule_action_name = "tf-as-schedule" max_size = 10 min_size = 0 diff --git a/website/docs/r/as_start_instances.html.markdown b/website/docs/r/as_start_instances.html.markdown index 7bb623e413..24c2e10062 100644 --- a/website/docs/r/as_start_instances.html.markdown +++ b/website/docs/r/as_start_instances.html.markdown @@ -14,9 +14,82 @@ Provides a resource to create a as start_instances ## Example Usage ```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.scaling_group.id - instance_ids = ["ins-xxxxx"] + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = tencentcloud_as_attachment.attachment.instance_ids } ``` diff --git a/website/docs/r/as_stop_instances.html.markdown b/website/docs/r/as_stop_instances.html.markdown index 84ec3b48c0..08527983e5 100644 --- a/website/docs/r/as_stop_instances.html.markdown +++ b/website/docs/r/as_stop_instances.html.markdown @@ -14,9 +14,82 @@ Provides a resource to create a as stop_instances ## Example Usage ```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_stop_instances" "stop_instances" { - auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id - instance_ids = ["ins-xxxx"] + auto_scaling_group_id = tencentcloud_as_scaling_group.example.id + instance_ids = tencentcloud_as_attachment.attachment.instance_ids stopped_mode = "STOP_CHARGING" } ``` diff --git a/website/docs/r/dnat.html.markdown b/website/docs/r/dnat.html.markdown index a0f69895d9..85c7be1ce2 100644 --- a/website/docs/r/dnat.html.markdown +++ b/website/docs/r/dnat.html.markdown @@ -14,15 +14,80 @@ Provides a resource to create a NAT forwarding. ## Example Usage ```hcl -resource "tencentcloud_dnat" "foo" { - vpc_id = "vpc-asg3sfa3" - nat_id = "nat-2515tdg" - protocol = "tcp" - elastic_ip = "139.199.232.238" +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "example" { + 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.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" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "example-vpc" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eip" "eip_example" { + name = "tf_nat_gateway_eip" +} + +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 + assigned_eip_set = [ + tencentcloud_eip.eip_example.public_ip, + ] + tags = { + tf_tag_key = "tf_tag_value" + } +} + +resource "tencentcloud_instance" "example" { + instance_name = "tf_example_instance" + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + image_id = data.tencentcloud_images.example.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 + allocate_public_ip = true + internet_max_bandwidth_out = 10 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + +resource "tencentcloud_dnat" "example" { + vpc_id = tencentcloud_vpc.vpc.id + nat_id = tencentcloud_nat_gateway.example.id + protocol = "TCP" + elastic_ip = tencentcloud_eip.eip_example.public_ip elastic_port = 80 - private_ip = "10.0.0.1" - private_port = 22 - description = "test" + private_ip = tencentcloud_instance.example.private_ip + private_port = 9090 + description = "desc." } ``` diff --git a/website/docs/r/mysql_account.html.markdown b/website/docs/r/mysql_account.html.markdown index add122e868..577df1f684 100644 --- a/website/docs/r/mysql_account.html.markdown +++ b/website/docs/r/mysql_account.html.markdown @@ -14,11 +14,59 @@ Provides a MySQL account resource for database management. A MySQL instance supp ## Example Usage ```hcl -resource "tencentcloud_mysql_account" "default" { - mysql_id = "terraform-test-local-database" - name = "tf_test" - password = "********" - description = "My test account" +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_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." max_user_connections = 10 } ``` diff --git a/website/docs/r/mysql_account_privilege.html.markdown b/website/docs/r/mysql_account_privilege.html.markdown index b1f55eb3cd..765d498771 100644 --- a/website/docs/r/mysql_account_privilege.html.markdown +++ b/website/docs/r/mysql_account_privilege.html.markdown @@ -16,11 +16,67 @@ Provides a mysql account privilege resource to grant different access privilege ## Example Usage ```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_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." + max_user_connections = 10 +} + resource "tencentcloud_mysql_account_privilege" "default" { - mysql_id = "terraform-test-local-database" - account_name = "tf_account" - privileges = ["SELECT"] - database_names = ["instance.name"] + mysql_id = tencentcloud_mysql_instance.example.id + account_name = tencentcloud_mysql_account.example.name + privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"] + database_names = ["dbname1", "dbname2"] } ``` diff --git a/website/docs/r/mysql_audit_log_file.html.markdown b/website/docs/r/mysql_audit_log_file.html.markdown index faa3f60fa6..87e0b269cf 100644 --- a/website/docs/r/mysql_audit_log_file.html.markdown +++ b/website/docs/r/mysql_audit_log_file.html.markdown @@ -14,12 +14,73 @@ Provides a resource to create a mysql audit_log_file ## Example Usage ```hcl -resource "tencentcloud_mysql_audit_log_file" "audit_log_file" { - instance_id = "cdb-fitq5t9h" - start_time = "2023-03-28 20:14:00" - end_time = "2023-03-29 20:14:00" +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_audit_log_file" "example" { + instance_id = tencentcloud_mysql_instance.example.id + start_time = "2023-07-01 00:00:00" + end_time = "2023-10-01 00:00:00" order = "ASC" order_by = "timestamp" +} +``` + +### Add filter + +```hcl +resource "tencentcloud_mysql_audit_log_file" "example" { + instance_id = tencentcloud_mysql_instance.example.id + start_time = "2023-07-01 00:00:00" + end_time = "2023-10-01 00:00:00" + order = "ASC" + order_by = "timestamp" + filter { host = ["30.50.207.46"] user = ["keep_dbbrain"] diff --git a/website/docs/r/mysql_backup_download_restriction.html.markdown b/website/docs/r/mysql_backup_download_restriction.html.markdown index e13426d5fe..2d3912565d 100644 --- a/website/docs/r/mysql_backup_download_restriction.html.markdown +++ b/website/docs/r/mysql_backup_download_restriction.html.markdown @@ -14,7 +14,7 @@ Provides a resource to create a mysql backup_download_restriction ## Example Usage ```hcl -resource "tencentcloud_mysql_backup_download_restriction" "backup_download_restriction" { +resource "tencentcloud_mysql_backup_download_restriction" "example" { limit_type = "Customize" vpc_comparison_symbol = "In" ip_comparison_symbol = "In" diff --git a/website/docs/r/mysql_backup_encryption_status.html.markdown b/website/docs/r/mysql_backup_encryption_status.html.markdown index 8045ccde6a..fe7ed835bd 100644 --- a/website/docs/r/mysql_backup_encryption_status.html.markdown +++ b/website/docs/r/mysql_backup_encryption_status.html.markdown @@ -13,13 +13,72 @@ Provides a resource to create a mysql backup_encryption_status ## Example Usage +### Enable encryption + ```hcl -resource "tencentcloud_mysql_backup_encryption_status" "backup_encryption_status" { - instance_id = "cdb-c1nl9rpv" +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_backup_encryption_status" "example" { + instance_id = tencentcloud_mysql_instance.example.id encryption_status = "on" } ``` +### Disable encryption + +```hcl +resource "tencentcloud_mysql_backup_encryption_status" "example" { + instance_id = tencentcloud_mysql_instance.example.id + encryption_status = "off" +} +``` + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/mysql_backup_policy.html.markdown b/website/docs/r/mysql_backup_policy.html.markdown index 31a8e0caa8..124e053783 100644 --- a/website/docs/r/mysql_backup_policy.html.markdown +++ b/website/docs/r/mysql_backup_policy.html.markdown @@ -16,11 +16,59 @@ Provides a mysql policy resource to create a backup policy. ## Example Usage ```hcl -resource "tencentcloud_mysql_backup_policy" "default" { - mysql_id = "cdb-dnqksd9f" +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_backup_policy" "example" { + mysql_id = tencentcloud_mysql_instance.example.id retention_period = 7 backup_model = "physical" - backup_time = "02:00-06:00" + backup_time = "01:00-05:00" } ``` diff --git a/website/docs/r/mysql_deploy_group.html.markdown b/website/docs/r/mysql_deploy_group.html.markdown index b7ecc5eaed..6420e616a7 100644 --- a/website/docs/r/mysql_deploy_group.html.markdown +++ b/website/docs/r/mysql_deploy_group.html.markdown @@ -14,9 +14,9 @@ Provides a resource to create a mysql deploy_group ## Example Usage ```hcl -resource "tencentcloud_mysql_deploy_group" "deploy_group" { - deploy_group_name = "terrform-deploy" - description = "deploy test" +resource "tencentcloud_mysql_deploy_group" "example" { + deploy_group_name = "tf-example" + description = "desc." limit_num = 1 dev_class = ["TS85"] } diff --git a/website/docs/r/mysql_dr_instance_to_mater.html.markdown b/website/docs/r/mysql_dr_instance_to_mater.html.markdown index d079ae8e33..0a823016b2 100644 --- a/website/docs/r/mysql_dr_instance_to_mater.html.markdown +++ b/website/docs/r/mysql_dr_instance_to_mater.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql dr_instance_to_mater ## Example Usage ```hcl -resource "tencentcloud_mysql_dr_instance_to_mater" "dr_instance_to_mater" { - instance_id = "cdb-c1nl9rpv" +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_dr_instance_to_mater" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` diff --git a/website/docs/r/mysql_instance.html.markdown b/website/docs/r/mysql_instance.html.markdown index 395aaad16d..a8e5e2a885 100644 --- a/website/docs/r/mysql_instance.html.markdown +++ b/website/docs/r/mysql_instance.html.markdown @@ -13,34 +13,120 @@ Provides a mysql instance resource to create master database instances. ~> **NOTE:** If this mysql has readonly instance, the terminate operation of the mysql does NOT take effect immediately, maybe takes for several hours. so during that time, VPCs associated with that mysql instance can't be terminated also. +~> **NOTE:** The value of parameter `parameters` can be used with tencentcloud_mysql_parameter_list to obtain. + ## Example Usage +### Create a single node instance + ```hcl -resource "tencentcloud_mysql_instance" "default" { +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 = "********" + root_password = "PassWord123" slave_deploy_mode = 0 - first_slave_zone = "ap-guangzhou-4" - second_slave_zone = "ap-guangzhou-4" + 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" + } +} +``` + +### Create a double node instance + +```hcl +resource "tencentcloud_mysql_instance" "example" { + internet_service = 1 + engine_version = "5.7" + charge_type = "POSTPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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" + } +} +``` + +### Create a three node instance + +```hcl +resource "tencentcloud_mysql_instance" "example" { + internet_service = 1 + engine_version = "5.7" + charge_type = "POSTPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.name + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.name slave_sync_mode = 1 - availability_zone = "ap-guangzhou-4" - project_id = 201901010001 - instance_name = "myTestMysql" - mem_size = 128000 - volume_size = 250 - vpc_id = "vpc-12mt3l31" - subnet_id = "subnet-9uivyb1g" + 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 = ["sg-ot8eclwz"] + security_groups = [tencentcloud_security_group.security_group.id] tags = { name = "test" } parameters = { - character_set_server = "UTF8" + character_set_server = "utf8" max_connections = "1000" } } diff --git a/website/docs/r/mysql_instance_encryption_operation.html.markdown b/website/docs/r/mysql_instance_encryption_operation.html.markdown index b18196a5d7..7b9e26c762 100644 --- a/website/docs/r/mysql_instance_encryption_operation.html.markdown +++ b/website/docs/r/mysql_instance_encryption_operation.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql instance_encryption_operation ## Example Usage ```hcl -resource "tencentcloud_mysql_instance_encryption_operation" "instance_encryption_operation" { - instance_id = tencentcloud_mysql_instance.this.id +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_instance_encryption_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id key_id = "KMS-CDB" key_region = "ap-guangzhou" } diff --git a/website/docs/r/mysql_isolate_instance.html.markdown b/website/docs/r/mysql_isolate_instance.html.markdown index eed43f4955..da66363223 100644 --- a/website/docs/r/mysql_isolate_instance.html.markdown +++ b/website/docs/r/mysql_isolate_instance.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql isolate_instance ## Example Usage ```hcl -resource "tencentcloud_mysql_isolate_instance" "isolate_instance" { - instance_id = "cdb-1tru99al" +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_isolate_instance" "example" { + instance_id = tencentcloud_mysql_instance.example.id operate = "recover" } ``` diff --git a/website/docs/r/mysql_local_binlog_config.html.markdown b/website/docs/r/mysql_local_binlog_config.html.markdown index 6d77bded87..a547c2cda9 100644 --- a/website/docs/r/mysql_local_binlog_config.html.markdown +++ b/website/docs/r/mysql_local_binlog_config.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql local_binlog_config ## Example Usage ```hcl -resource "tencentcloud_mysql_local_binlog_config" "local_binlog_config" { - instance_id = "cdb-fitq5t9h" +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 } diff --git a/website/docs/r/mysql_param_template.html.markdown b/website/docs/r/mysql_param_template.html.markdown index 39f4ccfc24..a9acc29dcd 100644 --- a/website/docs/r/mysql_param_template.html.markdown +++ b/website/docs/r/mysql_param_template.html.markdown @@ -14,9 +14,57 @@ Provides a resource to create a mysql param template ## Example Usage ```hcl -resource "tencentcloud_mysql_param_template" "param_template" { - name = "terraform-test" - description = "terraform-test" +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_param_template" "example" { + name = "tf-example" + description = "desc." engine_version = "8.0" param_list { current_value = "1" diff --git a/website/docs/r/mysql_password_complexity.html.markdown b/website/docs/r/mysql_password_complexity.html.markdown index e71299d53f..875034a9fb 100644 --- a/website/docs/r/mysql_password_complexity.html.markdown +++ b/website/docs/r/mysql_password_complexity.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql password_complexity ## Example Usage ```hcl -resource "tencentcloud_mysql_password_complexity" "password_complexity" { - instance_id = var.instance_id +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_password_complexity" "example" { + instance_id = tencentcloud_mysql_instance.example.id param_list { name = "validate_password_length" current_value = "8" diff --git a/website/docs/r/mysql_privilege.html.markdown b/website/docs/r/mysql_privilege.html.markdown index c9764c5cd6..d2cd3dfe4a 100644 --- a/website/docs/r/mysql_privilege.html.markdown +++ b/website/docs/r/mysql_privilege.html.markdown @@ -14,27 +14,65 @@ Provides a mysql account privilege resource to grant different access privilege ## Example Usage ```hcl -resource "tencentcloud_mysql_instance" "default" { - mem_size = 1000 - volume_size = 25 - instance_name = "guagua" - engine_version = "5.7" - root_password = "0153Y474" - availability_zone = "ap-guangzhou-3" +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_account" "mysql_account2" { - mysql_id = tencentcloud_mysql_instance.default.id - name = "test11" - password = "test1234" - description = "test from terraform" +resource "tencentcloud_mysql_account" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + name = "tf_example" + password = "Qwer@234" + description = "desc." + max_user_connections = 10 } -resource "tencentcloud_mysql_privilege" "tttt" { - mysql_id = tencentcloud_mysql_instance.default.id - account_name = tencentcloud_mysql_account.mysql_account2.name +resource "tencentcloud_mysql_privilege" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + account_name = tencentcloud_mysql_account.example.name global = ["TRIGGER"] database { privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE"] diff --git a/website/docs/r/mysql_proxy.html.markdown b/website/docs/r/mysql_proxy.html.markdown index 054c269055..085b395b87 100644 --- a/website/docs/r/mysql_proxy.html.markdown +++ b/website/docs/r/mysql_proxy.html.markdown @@ -14,10 +14,59 @@ Provides a resource to create a mysql proxy ## Example Usage ```hcl -resource "tencentcloud_mysql_proxy" "proxy" { - instance_id = "cdb-fitq5t9h" - uniq_vpc_id = "vpc-4owdpnwr" - uniq_subnet_id = "subnet-ahv6swf2" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id proxy_node_custom { node_count = 1 cpu = 2 @@ -25,10 +74,10 @@ resource "tencentcloud_mysql_proxy" "proxy" { region = "ap-guangzhou" zone = "ap-guangzhou-3" } - security_group = ["sg-edmur627"] - desc = "desc1" + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." connection_pool_limit = 2 - vip = "172.16.17.101" + vip = "10.0.0.120" vport = 3306 } ``` diff --git a/website/docs/r/mysql_readonly_instance.html.markdown b/website/docs/r/mysql_readonly_instance.html.markdown index cfd91b74de..964f8cf35e 100644 --- a/website/docs/r/mysql_readonly_instance.html.markdown +++ b/website/docs/r/mysql_readonly_instance.html.markdown @@ -17,18 +17,66 @@ Provides a mysql instance resource to create read-only database instances. ## Example Usage ```hcl -resource "tencentcloud_mysql_readonly_instance" "default" { - master_instance_id = "cdb-dnqksd9f" - instance_name = "myTestMysql" +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_readonly_instance" "example" { + master_instance_id = tencentcloud_mysql_instance.example.id + instance_name = "tf-example" mem_size = 128000 volume_size = 255 - vpc_id = "vpc-12mt3l31" - subnet_id = "subnet-9uivyb1g" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id intranet_port = 3306 - security_groups = ["sg-ot8eclwz"] + security_groups = [tencentcloud_security_group.security_group.id] tags = { - name = "test" + createBy = "terraform" } } ``` diff --git a/website/docs/r/mysql_reload_balance_proxy_node.html.markdown b/website/docs/r/mysql_reload_balance_proxy_node.html.markdown index 9e88045e6d..dfed805f94 100644 --- a/website/docs/r/mysql_reload_balance_proxy_node.html.markdown +++ b/website/docs/r/mysql_reload_balance_proxy_node.html.markdown @@ -14,9 +14,76 @@ Provides a resource to create a mysql reload_balance_proxy_node ## Example Usage ```hcl -resource "tencentcloud_mysql_reload_balance_proxy_node" "reload_balance_proxy_node" { - proxy_group_id = "proxy-gmi1f78l" - proxy_address_id = "proxyaddr-4wc4y1pq" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 1 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + +resource "tencentcloud_mysql_reload_balance_proxy_node" "example" { + proxy_group_id = tencentcloud_mysql_proxy.example.proxy_group_id + proxy_address_id = tencentcloud_mysql_proxy.example.proxy_address_id } ``` diff --git a/website/docs/r/mysql_remote_backup_config.html.markdown b/website/docs/r/mysql_remote_backup_config.html.markdown index 53941f5ca4..490f5402ed 100644 --- a/website/docs/r/mysql_remote_backup_config.html.markdown +++ b/website/docs/r/mysql_remote_backup_config.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql remote_backup_config ## Example Usage ```hcl -resource "tencentcloud_mysql_remote_backup_config" "remote_backup_config" { - instance_id = "cdb-c1nl9rpv" +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_remote_backup_config" "example" { + instance_id = tencentcloud_mysql_instance.example.id remote_backup_save = "on" remote_binlog_save = "on" remote_region = ["ap-shanghai"] diff --git a/website/docs/r/mysql_renew_db_instance_operation.html.markdown b/website/docs/r/mysql_renew_db_instance_operation.html.markdown index ea7bcbe76b..de72c4d4d8 100644 --- a/website/docs/r/mysql_renew_db_instance_operation.html.markdown +++ b/website/docs/r/mysql_renew_db_instance_operation.html.markdown @@ -14,8 +14,61 @@ Provides a resource to create a mysql renew_db_instance_operation ## Example Usage ```hcl -resource "tencentcloud_mysql_renew_db_instance_operation" "renew_db_instance_operation" { - instance_id = "cdb-c1nl9rpv" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "cdb" +} + +data "tencentcloud_mysql_rollback_range_time" "example" { + instance_ids = [tencentcloud_mysql_instance.example.id] +} + +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 = "PREPAID" + root_password = "PassWord123" + slave_deploy_mode = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_renew_db_instance_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id time_span = 1 modify_pay_type = "PREPAID" } diff --git a/website/docs/r/mysql_reset_root_account.html.markdown b/website/docs/r/mysql_reset_root_account.html.markdown index 4e6fda9787..6b3c726b69 100644 --- a/website/docs/r/mysql_reset_root_account.html.markdown +++ b/website/docs/r/mysql_reset_root_account.html.markdown @@ -14,8 +14,57 @@ Provides a resource to create a mysql reset_root_account ## Example Usage ```hcl -resource "tencentcloud_mysql_reset_root_account" "reset_root_account" { - instance_id = "cdb-fitq5t9h" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_reset_root_account" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` diff --git a/website/docs/r/mysql_restart_db_instances_operation.html.markdown b/website/docs/r/mysql_restart_db_instances_operation.html.markdown index 041d9977ad..47355a122b 100644 --- a/website/docs/r/mysql_restart_db_instances_operation.html.markdown +++ b/website/docs/r/mysql_restart_db_instances_operation.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql restart_db_instances_operation ## Example Usage ```hcl -resource "tencentcloud_mysql_restart_db_instances_operation" "restart_db_instances_operation" { - instance_id = "cdb-bohspx3j" +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_restart_db_instances_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` diff --git a/website/docs/r/mysql_ro_group.html.markdown b/website/docs/r/mysql_ro_group.html.markdown index 9204e09b8d..9cad4ecbb7 100644 --- a/website/docs/r/mysql_ro_group.html.markdown +++ b/website/docs/r/mysql_ro_group.html.markdown @@ -14,7 +14,7 @@ Provides a resource to create a mysql ro_group ## Example Usage ```hcl -resource "tencentcloud_mysql_ro_group" "ro_group" { +resource "tencentcloud_mysql_ro_group" "example" { instance_id = "cdb-e8i766hx" ro_group_id = "cdbrg-f49t0gnj" ro_group_info { diff --git a/website/docs/r/mysql_ro_group_load_operation.html.markdown b/website/docs/r/mysql_ro_group_load_operation.html.markdown index 0067616b35..7ad584bc3d 100644 --- a/website/docs/r/mysql_ro_group_load_operation.html.markdown +++ b/website/docs/r/mysql_ro_group_load_operation.html.markdown @@ -14,8 +14,77 @@ Provides a resource to create a mysql ro_group_load_operation ## Example Usage ```hcl +data "tencentcloud_availability_zones_by_product" "zones" { + product = "cdb" +} + +data "tencentcloud_mysql_instance" "example" { + mysql_id = tencentcloud_mysql_instance.example.id + + depends_on = [tencentcloud_mysql_readonly_instance.example] +} + +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.1.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.1.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_readonly_instance" "example" { + master_instance_id = tencentcloud_mysql_instance.example.id + instance_name = "tf-mysql" + mem_size = 2000 + 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 = { + createBy = "terraform" + } +} + resource "tencentcloud_mysql_ro_group_load_operation" "ro_group_load_operation" { - ro_group_id = "cdbrg-bdlvcfpj" + ro_group_id = data.tencentcloud_mysql_instance.example.instance_list.0.ro_groups.0.group_id } ``` diff --git a/website/docs/r/mysql_ro_instance_ip.html.markdown b/website/docs/r/mysql_ro_instance_ip.html.markdown index 11ffbc4baa..dd74f59087 100644 --- a/website/docs/r/mysql_ro_instance_ip.html.markdown +++ b/website/docs/r/mysql_ro_instance_ip.html.markdown @@ -14,10 +14,27 @@ Provides a resource to create a mysql ro_instance_ip ## Example Usage ```hcl -resource "tencentcloud_mysql_ro_instance_ip" "ro_instance_ip" { +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_mysql_ro_instance_ip" "example" { instance_id = "cdbro-bdlvcfpj" - uniq_subnet_id = "subnet-dwj7ipnc" - uniq_vpc_id = "vpc-4owdpnwr" + uniq_subnet_id = tencentcloud_subnet.subnet.id + uniq_vpc_id = tencentcloud_vpc.vpc.id } ``` diff --git a/website/docs/r/mysql_ro_start_replication.html.markdown b/website/docs/r/mysql_ro_start_replication.html.markdown index f99f78e9cf..a56f492ba5 100644 --- a/website/docs/r/mysql_ro_start_replication.html.markdown +++ b/website/docs/r/mysql_ro_start_replication.html.markdown @@ -14,8 +14,75 @@ Provides a resource to create a mysql ro_start_replication ## Example Usage ```hcl -resource "tencentcloud_mysql_ro_start_replication" "ro_start_replication" { - instance_id = "cdb-fitq5t9h" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 1 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + +resource "tencentcloud_mysql_ro_start_replication" "example" { + instance_id = tencentcloud_mysql_proxy.example.id } ``` diff --git a/website/docs/r/mysql_ro_stop_replication.html.markdown b/website/docs/r/mysql_ro_stop_replication.html.markdown index 808cfadbe8..9538e6db98 100644 --- a/website/docs/r/mysql_ro_stop_replication.html.markdown +++ b/website/docs/r/mysql_ro_stop_replication.html.markdown @@ -14,8 +14,75 @@ Provides a resource to create a mysql ro_stop_replication ## Example Usage ```hcl -resource "tencentcloud_mysql_ro_stop_replication" "ro_stop_replication" { - instance_id = "cdb-fitq5t9h" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_proxy" "example" { + instance_id = tencentcloud_mysql_instance.example.id + uniq_vpc_id = tencentcloud_vpc.vpc.id + uniq_subnet_id = tencentcloud_subnet.subnet.id + proxy_node_custom { + node_count = 1 + cpu = 2 + mem = 4000 + region = "ap-guangzhou" + zone = "ap-guangzhou-3" + } + security_group = [tencentcloud_security_group.security_group.id] + desc = "desc." + connection_pool_limit = 2 + vip = "10.0.0.120" + vport = 3306 +} + +resource "tencentcloud_mysql_ro_stop_replication" "example" { + instance_id = tencentcloud_mysql_proxy.example.id } ``` diff --git a/website/docs/r/mysql_rollback.html.markdown b/website/docs/r/mysql_rollback.html.markdown index 250036cac1..d098ece357 100644 --- a/website/docs/r/mysql_rollback.html.markdown +++ b/website/docs/r/mysql_rollback.html.markdown @@ -14,19 +14,72 @@ Provides a resource to create a mysql rollback ## Example Usage ```hcl -resource "tencentcloud_mysql_rollback" "rollback" { - instance_id = "cdb-fitq5t9h" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "cdb" +} + +data "tencentcloud_mysql_rollback_range_time" "example" { + instance_ids = [tencentcloud_mysql_instance.example.id] +} + +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_rollback" "example" { + instance_id = tencentcloud_mysql_instance.example.id strategy = "full" - rollback_time = "2023-05-31 23:13:35" + rollback_time = data.tencentcloud_mysql_rollback_range_time.example.item.0.times.0.start databases { - database_name = "tf_ci_test_bak" - new_database_name = "tf_ci_test_bak_5" + database_name = "tf_db_bak" + new_database_name = "tf_db_bak_new" } tables { - database = "tf_ci_test_bak" + database = "tf_db_bak1" table { - table_name = "test" - new_table_name = "test_bak" + table_name = "tf_table" + new_table_name = "tf_table_new" } } } diff --git a/website/docs/r/mysql_rollback_stop.html.markdown b/website/docs/r/mysql_rollback_stop.html.markdown index 17b7166da2..d636692e7c 100644 --- a/website/docs/r/mysql_rollback_stop.html.markdown +++ b/website/docs/r/mysql_rollback_stop.html.markdown @@ -13,8 +13,10 @@ Provides a resource to create a mysql rollback_stop ## Example Usage +### Revoke the ongoing rollback task of the instance + ```hcl -resource "tencentcloud_mysql_rollback_stop" "rollback_stop" { +resource "tencentcloud_mysql_rollback_stop" "example" { instance_id = "cdb-fitq5t9h" } ``` diff --git a/website/docs/r/mysql_security_groups_attachment.html.markdown b/website/docs/r/mysql_security_groups_attachment.html.markdown index d30fd423b9..f1fa05a6b8 100644 --- a/website/docs/r/mysql_security_groups_attachment.html.markdown +++ b/website/docs/r/mysql_security_groups_attachment.html.markdown @@ -14,9 +14,57 @@ Provides a resource to create a mysql security_groups_attachment ## Example Usage ```hcl -resource "tencentcloud_mysql_security_groups_attachment" "security_groups_attachment" { - security_group_id = "sg-baxfiao5" - instance_id = "cdb-fitq5t9h" +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 } ``` diff --git a/website/docs/r/mysql_switch_for_upgrade.html.markdown b/website/docs/r/mysql_switch_for_upgrade.html.markdown index 2b7e8e0eb7..054c00794d 100644 --- a/website/docs/r/mysql_switch_for_upgrade.html.markdown +++ b/website/docs/r/mysql_switch_for_upgrade.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql switch_for_upgrade ## Example Usage ```hcl -resource "tencentcloud_mysql_switch_for_upgrade" "switch_for_upgrade" { - instance_id = "cdb-d9gbh7lt" +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_switch_for_upgrade" "example" { + instance_id = tencentcloud_mysql_instance.example.id } ``` diff --git a/website/docs/r/mysql_switch_master_slave_operation.html.markdown b/website/docs/r/mysql_switch_master_slave_operation.html.markdown index ce29760eea..e5d9560826 100644 --- a/website/docs/r/mysql_switch_master_slave_operation.html.markdown +++ b/website/docs/r/mysql_switch_master_slave_operation.html.markdown @@ -14,9 +14,58 @@ Provides a resource to create a mysql switch_master_slave_operation ## Example Usage ```hcl -resource "tencentcloud_mysql_switch_master_slave_operation" "switch_master_slave_operation" { - instance_id = "cdb-d9gbh7lt" - dst_slave = "first" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_switch_master_slave_operation" "example" { + instance_id = tencentcloud_mysql_instance.example.id + dst_slave = "second" force_switch = true wait_switch = true } diff --git a/website/docs/r/mysql_time_window.html.markdown b/website/docs/r/mysql_time_window.html.markdown index 97bf4ae697..8304ac6dbf 100644 --- a/website/docs/r/mysql_time_window.html.markdown +++ b/website/docs/r/mysql_time_window.html.markdown @@ -14,8 +14,56 @@ Provides a resource to create a mysql time_window ## Example Usage ```hcl -resource "tencentcloud_mysql_time_window" "time_window" { - instance_id = "cdb-lw71b6ar" +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_time_window" "example" { + instance_id = tencentcloud_mysql_instance.example.id max_delay_time = 10 time_ranges = [ "01:00-02:01" diff --git a/website/docs/r/mysql_verify_root_account.html.markdown b/website/docs/r/mysql_verify_root_account.html.markdown index a77c47d815..c4d3d51f3d 100644 --- a/website/docs/r/mysql_verify_root_account.html.markdown +++ b/website/docs/r/mysql_verify_root_account.html.markdown @@ -14,9 +14,58 @@ Provides a resource to create a mysql verify_root_account ## Example Usage ```hcl -resource "tencentcloud_mysql_verify_root_account" "verify_root_account" { - instance_id = "" - password = "" +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 = 1 + availability_zone = data.tencentcloud_availability_zones_by_product.zones.zones.0.name + first_slave_zone = data.tencentcloud_availability_zones_by_product.zones.zones.1.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_verify_root_account" "example" { + instance_id = tencentcloud_mysql_instance.example.id + password = "Qwer@234" } ``` diff --git a/website/docs/r/nat_gateway.html.markdown b/website/docs/r/nat_gateway.html.markdown index cbcbb054ff..904c462901 100644 --- a/website/docs/r/nat_gateway.html.markdown +++ b/website/docs/r/nat_gateway.html.markdown @@ -13,31 +13,33 @@ Provides a resource to create a NAT gateway. ## Example Usage +### Create a NAT gateway. + ```hcl -data "tencentcloud_vpc_instances" "foo" { - name = "Default-VPC" -} -# Create EIP -resource "tencentcloud_eip" "eip_dev_dnat" { - name = "terraform_nat_test" +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_nat_gateway_vpc" } -resource "tencentcloud_eip" "new_eip" { - name = "terraform_nat_test" + +resource "tencentcloud_eip" "eip_example1" { + name = "tf_nat_gateway_eip1" } -resource "tencentcloud_nat_gateway" "my_nat" { - vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id - name = "new_name" - max_concurrent = 10000000 - bandwidth = 1000 - zone = "ap-guangzhou-3" +resource "tencentcloud_eip" "eip_example2" { + name = "tf_nat_gateway_eip2" +} +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.new_eip.public_ip, + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] tags = { - tf = "test" + tf_tag_key = "tf_tag_value" } } ``` diff --git a/website/docs/r/nat_gateway_snat.html.markdown b/website/docs/r/nat_gateway_snat.html.markdown index f3e894dbfe..334c095136 100644 --- a/website/docs/r/nat_gateway_snat.html.markdown +++ b/website/docs/r/nat_gateway_snat.html.markdown @@ -14,100 +14,112 @@ Provides a resource to create a NAT Gateway SNat rule. ## Example Usage ```hcl -data "tencentcloud_availability_zones" "my_zones" {} - -data "tencentcloud_vpc" "my_vpc" { - name = "Default-VPC" +data "tencentcloud_availability_zones_by_product" "zones" { + product = "nat" } -data "tencentcloud_images" "my_image" { +data "tencentcloud_images" "image" { os_name = "centos" } -data "tencentcloud_instance_types" "my_instance_types" { - cpu_core_count = 1 - memory_size = 1 +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" } -# Create EIP -resource "tencentcloud_eip" "eip_dev_dnat" { - name = "terraform_test" +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_test_dnat" { - name = "terraform_test" + +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 = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" + vpc_id = tencentcloud_vpc.vpc.id + name = "tf_example_nat_gateway" max_concurrent = 3000000 bandwidth = 500 assigned_eip_set = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] } # Create route_table and entry -resource "tencentcloud_route_table" "my_route_table" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" +resource "tencentcloud_route_table" "route_table" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf_example" } -resource "tencentcloud_route_table_entry" "my_route_entry" { - route_table_id = tencentcloud_route_table.my_route_table.id + +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 } -# Create Subnet -resource "tencentcloud_subnet" "my_subnet" { - vpc_id = data.tencentcloud_vpc.my_vpc.id - name = "terraform test" - cidr_block = "172.29.23.0/24" - availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name - route_table_id = tencentcloud_route_table.my_route_table.id -} - # Subnet Nat gateway snat -resource "tencentcloud_nat_gateway_snat" "my_subnet_snat" { +resource "tencentcloud_nat_gateway_snat" "subnet_snat" { nat_gateway_id = tencentcloud_nat_gateway.my_nat.id resource_type = "SUBNET" - subnet_id = tencentcloud_subnet.my_subnet.id - subnet_cidr_block = tencentcloud_subnet.my_subnet.cidr_block + subnet_id = tencentcloud_subnet.subnet.id + subnet_cidr_block = tencentcloud_subnet.subnet.cidr_block description = "terraform test" public_ip_addr = [ - tencentcloud_eip.eip_dev_dnat.public_ip, - tencentcloud_eip.eip_test_dnat.public_ip, + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, ] } # Create instance -resource "tencentcloud_instance" "my_instance" { - instance_name = "terraform test" - availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name - image_id = data.tencentcloud_images.my_image.images.0.image_id - instance_type = data.tencentcloud_instance_types.my_instance_types.instance_types.0.instance_type - system_disk_type = "CLOUD_PREMIUM" - system_disk_size = 50 - hostname = "user" - project_id = 0 - vpc_id = data.tencentcloud_vpc.my_vpc.id - subnet_id = tencentcloud_subnet.my_subnet.id - internet_max_bandwidth_out = 20 +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.my_instance.id - instance_private_ip_addr = tencentcloud_instance.my_instance.private_ip + instance_id = tencentcloud_instance.example.id + instance_private_ip_addr = tencentcloud_instance.example.private_ip description = "terraform test" public_ip_addr = [ - tencentcloud_eip.eip_dev_dnat.public_ip, + tencentcloud_eip.eip_example1.public_ip, ] } ``` diff --git a/website/docs/r/nat_refresh_nat_dc_route.html.markdown b/website/docs/r/nat_refresh_nat_dc_route.html.markdown index e334d42619..2288ada497 100644 --- a/website/docs/r/nat_refresh_nat_dc_route.html.markdown +++ b/website/docs/r/nat_refresh_nat_dc_route.html.markdown @@ -13,14 +13,46 @@ Provides a resource to create a vpc refresh_nat_dc_route ## Example Usage +### is True + ```hcl +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_eip" "eip_example" { + name = "eip_example" +} + +resource "tencentcloud_nat_gateway" "nat" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf_example_nat_gateway" + max_concurrent = 3000000 + bandwidth = 500 + + assigned_eip_set = [ + tencentcloud_eip.eip_example.public_ip, + ] +} + resource "tencentcloud_nat_refresh_nat_dc_route" "refresh_nat_dc_route" { - nat_gateway_id = "nat-gnxkey2e" - vpc_id = "vpc-pyyv5k3v" + nat_gateway_id = tencentcloud_nat_gateway.nat.id + vpc_id = tencentcloud_vpc.vpc.id dry_run = true } ``` +### is False + +```hcl +resource "tencentcloud_nat_refresh_nat_dc_route" "refresh_nat_dc_route" { + nat_gateway_id = tencentcloud_nat_gateway.nat.id + vpc_id = tencentcloud_vpc.vpc.id + dry_run = false +} +``` + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/security_group.html.markdown b/website/docs/r/security_group.html.markdown index 06b7e693d2..9921c451fe 100644 --- a/website/docs/r/security_group.html.markdown +++ b/website/docs/r/security_group.html.markdown @@ -13,11 +13,26 @@ Provides a resource to create security group. ## Example Usage +### Create a basic security group + ```hcl -resource "tencentcloud_security_group" "sglab" { - name = "mysg" - description = "favourite sg" +resource "tencentcloud_security_group" "example" { + name = "tf-example-sg" + description = "sg test" +} +``` + +### Create a complete security group + +```hcl +resource "tencentcloud_security_group" "example" { + name = "tf-example-sg" + description = "sg test" project_id = 0 + + tags = { + "example" = "test" + } } ``` diff --git a/website/docs/r/ssl_certificate.html.markdown b/website/docs/r/ssl_certificate.html.markdown index 0a1e5b14c0..450dfb2d89 100644 --- a/website/docs/r/ssl_certificate.html.markdown +++ b/website/docs/r/ssl_certificate.html.markdown @@ -11,14 +11,46 @@ description: |- Provides a resource to create a SSL certificate. +Upload the existing SSL certificate to Tencent Cloud. + ## Example Usage ```hcl -resource "tencentcloud_ssl_certificate" "foo" { - name = "test-ssl-certificate" - type = "CA" - project_id = 0 - cert = "-----BEGIN CERTIFICATE-----\nMIIERzCCAq+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzE5MzlaFw0yOTA4\nMTAwMzE5MzlaMC4xEzARBgNVBAMTCnNlcnZlciBzc2wxFzAVBgNVBAoTDnRlcnJh\nZm9ybS10ZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1Ryp+DKK\nSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8YgpolenbmeEPrzT87tunFD7G9f6ALG\nND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqNAhGLaxWiEB/hy5WOiwxDrGei\ngQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVRopZuCe/RMPNusNVZaIi+qcEf\nfsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWCF97qy8TNYk94K/1tq3zyhVzR\nZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8IslgnqJW4izIXZqgIKmHaRZtM\nN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88aC8HnMqJJ3kScGCL36GYG+Kaw\n5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJyxAXyiX49LQ0v7f9qzwc/0JiD\nbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xlYP6l1SoJG3GgZ8dbAgMBAAGj\ndjB0MAwGA1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/\nBAUDAweAADAdBgNVHQ4EFgQULwWKBQNLL9s3cb3tTnyPVg+mpCMwHwYDVR0jBBgw\nFoAUKwfrmq791mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAMo5RglS\nAHdPgaicWJvmvjjexjF/42b7Rz4pPfMjYw6uYO8He/f4UZWv5CZLrbEe7MywaK3y\n0OsfH8AhyN29pv2x8g9wbmq7omZIOZ0oCAGduEXs/A/qY/hFaCohdkz/IN8qi6JW\nVXreGli3SrpcHFchSwHTyJEXgkutcGAsOvdsOuVSmplOyrkLHc8uUe8SG4j8kGyg\nEzaszFjHkR7g1dVyDVUedc588mjkQxYeAamJgfkgIhljWKMa2XzkVMcVfQHfNpM1\nn+bu8SmqRt9Wma2bMijKRG/Blm756LoI+skY+WRZmlDnq8zj95TT0vceGP0FUWh5\nhKyiocABmpQs9OK9HMi8vgSWISP+fYgkm/bKtKup2NbZBoO5/VL2vCEPInYzUhBO\njCbLMjNjtM5KriCaR7wDARgHiG0gBEPOEW1PIjZ9UOH+LtIxbNZ4eEIIINLHnBHf\nL+doVeZtS/gJc4G4Adr5HYuaS9ZxJ0W2uy0eQlOHzjyxR6Mf/rpnilJlcQ==\n-----END CERTIFICATE-----" +variable "ca" { + default = "-----BEGIN CERTIFICATE-----\nMIIEDjCCAnagAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzA4MjBaFw0yOTA4\nMTAwMzA4MjBaMCgxDTALBgNVBAMTBHRlc3QxFzAVBgNVBAoTDnRlcnJhZm9ybSB0\nZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0k2vqg/GHtFP5P7r\ndbzswfx1jSHeK9r4StV4mGOAoKyzvAJA5BvYbAHpSrL2ZAd6ShjHgRVU1qEroeFn\n8fwTrAVQttMltBFABx7G4iN4Zf6EUXzhhFN6vVVbWaqhYhrdMoPvZxgGSA/4hG4W\nGIr8MXZzXbKLoRoz4Bvq1Ymg5eO14KLJFSTahvIkG60egGN5pmi4czxWy2U7ycA5\nQ5TuQBnF0rKQJW5XKIV3kr5YrzDdJK7up9E6Od4T5jz+qY97KAjIpWD/pTAsc7+6\nfPBpY7NHT9Bw0fDmvsWO/PtswY4hW02n86b5eWA9sfKJGphhsBxgpuuhmxYHS6pA\nB+C7IkyxcADNT5u9tEo2JGOj+/veXKrEhZin7inKsQLD0WOobcg1Rh/3NSWD7geF\nTJBRnzgplaN7cK6c/utEAAnngS38q4DGBR/jHmkWjAeQPZj1eLLBk686HEEbKeU+\n9yAVcPRhA9tuL7wMeSX32VunWZunoA/f8iuGZYJlZsNBqyJbAgMBAAGjQzBBMA8G\nA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAweGADAdBgNVHQ4EFgQUKwfrmq79\n1mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAInM+aeaHoZdw9B9nAH2\nHscEoOulF+RxnysSXTTRLd2VQph4+ynlfRZT4evLBBj/ppmqjp8F7/OcRiiZwSXl\nnamyP/UUINtHfgDM0kll/5Za0aYzMhrORNw+3ythIv2yPJX8t4LmsG1L4PMO8ZU8\nN0K9XyKRaL/tq6rw1gQM152OmNgTzfAQoKYxrvbftOZz4J0ZACctuBmwtp5upKvJ\n36aQ4wJLUzOt69mnW+AaL5EPA37mwtzdnzTTxd3SBfOYXjsflc3l2raljJznnqU2\nySynjb6L3D3L/pObL1Uu7nQBy8CazJBsBsVFK/pr61vcllm8lG7vOhHOUSFUeezq\nFWukAolm9/cagmD6IhNishM3Uzng+UYyCC8uQq3Z7FGqJpXSI79wZYjudnCLPVCg\nOIfJHQeJFLryn6GxiSYmYs6dgUJiiTV+I/2Y5X7ZFdb5FC1J/WmvoCv6yO7NiirY\nBSgfV0lp5CuV8SfiSClpYfrM28NbNgxveUqET642BJOPLQ==\n-----END CERTIFICATE-----" +} + +data "tencentcloud_ssl_certificates" "ca" { + name = tencentcloud_ssl_certificate.ca.name +} + +resource "tencentcloud_ssl_certificate" "ca" { + name = "ssl-ca" + type = "CA" + cert = var.ca +} +``` + + + +```hcl +variable "cert" { + default = "-----BEGIN CERTIFICATE-----\nMIIERzCCAq+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMQ0wCwYDVQQDEwR0ZXN0\nMRcwFQYDVQQKEw50ZXJyYWZvcm0gdGVzdDAeFw0xOTA4MTMwMzE5MzlaFw0yOTA4\nMTAwMzE5MzlaMC4xEzARBgNVBAMTCnNlcnZlciBzc2wxFzAVBgNVBAoTDnRlcnJh\nZm9ybS10ZXN0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1Ryp+DKK\nSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8YgpolenbmeEPrzT87tunFD7G9f6ALG\nND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqNAhGLaxWiEB/hy5WOiwxDrGei\ngQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVRopZuCe/RMPNusNVZaIi+qcEf\nfsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWCF97qy8TNYk94K/1tq3zyhVzR\nZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8IslgnqJW4izIXZqgIKmHaRZtM\nN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88aC8HnMqJJ3kScGCL36GYG+Kaw\n5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJyxAXyiX49LQ0v7f9qzwc/0JiD\nbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xlYP6l1SoJG3GgZ8dbAgMBAAGj\ndjB0MAwGA1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/\nBAUDAweAADAdBgNVHQ4EFgQULwWKBQNLL9s3cb3tTnyPVg+mpCMwHwYDVR0jBBgw\nFoAUKwfrmq791mY831S6UHARHtgYnlgwDQYJKoZIhvcNAQELBQADggGBAMo5RglS\nAHdPgaicWJvmvjjexjF/42b7Rz4pPfMjYw6uYO8He/f4UZWv5CZLrbEe7MywaK3y\n0OsfH8AhyN29pv2x8g9wbmq7omZIOZ0oCAGduEXs/A/qY/hFaCohdkz/IN8qi6JW\nVXreGli3SrpcHFchSwHTyJEXgkutcGAsOvdsOuVSmplOyrkLHc8uUe8SG4j8kGyg\nEzaszFjHkR7g1dVyDVUedc588mjkQxYeAamJgfkgIhljWKMa2XzkVMcVfQHfNpM1\nn+bu8SmqRt9Wma2bMijKRG/Blm756LoI+skY+WRZmlDnq8zj95TT0vceGP0FUWh5\nhKyiocABmpQs9OK9HMi8vgSWISP+fYgkm/bKtKup2NbZBoO5/VL2vCEPInYzUhBO\njCbLMjNjtM5KriCaR7wDARgHiG0gBEPOEW1PIjZ9UOH+LtIxbNZ4eEIIINLHnBHf\nL+doVeZtS/gJc4G4Adr5HYuaS9ZxJ0W2uy0eQlOHzjyxR6Mf/rpnilJlcQ==\n-----END CERTIFICATE-----" +} + +variable "key" { + default = "Public Key Info:\n Public Key Algorithm: RSA\n Key Security Level: High (3072 bits)\n\nmodulus:\n 00:d5:1c:a9:f8:32:8a:48:d1:4a:66:c3:ed:c1:f4:7e\n 8f:33:a7:43:c6:05:89:e2:0a:62:06:a4:57:af:3c:77\n c6:20:a6:89:5e:9d:b9:9e:10:fa:f3:4f:ce:ed:ba:71\n 43:ec:6f:5f:e8:02:c6:34:3f:2b:8f:b9:e9:8f:40:28\n c3:18:4e:2f:f8:7f:bf:50:fd:bb:45:2c:21:a8:f9:8b\n 61:96:26:ba:8d:02:11:8b:6b:15:a2:10:1f:e1:cb:95\n 8e:8b:0c:43:ac:67:a2:81:0a:89:90:53:39:d8:4a:7b\n 1b:56:31:ec:f1:c9:98:a1:46:c0:df:45:84:8b:05:8b\n 57:0d:65:f5:51:a2:96:6e:09:ef:d1:30:f3:6e:b0:d5\n 59:68:88:be:a9:c1:1f:7e:c1:35:72:67:e6:b9:29:46\n dc:0a:74:44:a3:88:c9:1d:1a:8c:31:33:a9:99:fd:ff\n 44:7b:57:05:82:17:de:ea:cb:c4:cd:62:4f:78:2b:fd\n 6d:ab:7c:f2:85:5c:d1:67:cd:f1:39:27:eb:4e:a1:1f\n 6f:7b:28:dc:05:36:8f:22:a0:61:dc:2b:fc:56:52:ef\n 65:42:1d:2f:08:b2:58:27:a8:95:b8:8b:32:17:66:a8\n 08:2a:61:da:45:9b:4c:37:88:d4:96:88:ba:97:fe:a5\n 92:db:7a:2e:c8:21:f7:11:02:79:cc:73:89:22:6d:3c\n c6:a8:83:cf:1a:0b:c1:e7:32:a2:49:de:44:9c:18:22\n f7:e8:66:06:f8:a6:b0:e4:f9:c3:95:65:c1:69:e8:83\n 7b:cc:ff:79:62:bd:f9:1a:f6:33:ea:e1:4c:dc:68:b0\n 05:46:7c:32:72:c4:05:f2:89:7e:3d:2d:0d:2f:ed:ff\n 6a:cf:07:3f:d0:98:83:6e:fb:14:bf:57:26:e8:e8:29\n a0:43:0f:f5:25:ea:a8:17:70:1a:a7:8a:6c:3d:bf:da\n 39:4f:e3:cc:65:60:fe:a5:d5:2a:09:1b:71:a0:67:c7\n 5b:\n\npublic exponent:\n 01:00:01:\n\nprivate exponent:\n 00:b1:56:d0:fa:00:d4:a2:13:c7:5e:0c:dc:e4:f1:97\n ff:82:74:46:29:9a:a2:4a:bf:69:23:2d:ce:e9:bb:df\n cf:b7:8b:dd:f4:26:3c:38:14:d9:3f:6f:c2:3a:81:53\n 8f:ba:48:53:fe:b5:90:4a:19:e7:1e:0b:0f:18:6d:c3\n 7d:d5:d3:fa:87:47:86:e4:d6:bf:e7:a7:f9:ba:ab:2e\n 19:5e:e1:8b:8b:9b:95:0d:f7:66:61:1e:19:e9:c3:88\n 08:be:1c:ce:93:c1:09:b1:68:1b:61:46:60:74:64:46\n 5d:51:34:ea:7f:a9:ca:a1:2a:47:85:84:4b:ef:84:05\n 97:c3:46:7d:06:19:ce:24:73:90:64:fb:df:16:d5:80\n 34:8e:90:7c:58:b6:a4:86:ce:30:b3:ab:52:8b:f2:95\n 4c:b6:46:5a:77:db:73:c0:0c:3f:6d:12:18:a8:54:7c\n ff:77:c3:ca:89:9f:63:98:ef:48:2d:c1:09:70:6e:ea\n cb:bb:78:91:42:8a:22:3e:21:ef:a5:bf:16:ee:66:45\n e5:f0:26:6a:85:8e:e1:69:62:ac:05:00:a6:44:ba:c8\n ac:10:00:97:f5:51:65:7f:9a:1f:7b:99:9d:02:d4:87\n 50:ce:74:06:51:67:fa:fb:90:e4:33:79:f2:a8:61:ee\n 45:1d:87:ca:22:5b:ac:e7:32:38:f8:2c:fd:55:92:1e\n 3d:60:1e:7c:4b:fd:28:ff:e5:b1:02:6a:aa:22:f7:ae\n a8:36:90:7b:a6:f7:29:05:14:3a:21:da:36:05:f9:b0\n 9d:f7:fb:10:75:d7:2c:21:32:95:e7:f7:17:be:09:cb\n 66:fe:f1:69:71:df:a4:5e:3f:fc:67:6c:37:65:b8:51\n c6:22:38:fb:07:ce:89:54:50:43:71:44:3d:c3:51:5a\n bd:e5:c7:87:b2:ea:7b:64:0f:5d:34:9c:a1:52:b3:ce\n 06:86:ba:7a:05:80:48:b3:6c:1b:79:74:9b:49:f2:30\n c1:\n\nprime1:\n 00:e4:31:46:59:3d:24:f7:31:d9:22:26:af:c0:3e:f5\n c1:6d:be:ba:d3:9e:3f:b9:2c:43:a0:d0:47:09:e4:35\n 63:19:a4:33:82:af:f9:76:3c:11:c2:cb:34:f9:a6:ab\n dd:ab:64:5a:6b:9c:c1:2a:52:89:64:7e:b5:a7:f0:4d\n 29:13:a4:cf:17:f4:f2:0d:a0:6e:b9:5d:95:41:10:df\n ae:f3:7a:13:49:21:66:73:2a:b7:e2:8d:7c:c2:34:e5\n 3f:bd:78:ca:fc:64:c5:1c:3a:66:7a:12:53:96:bd:b0\n c3:7a:0c:ec:5e:55:c0:c3:3f:7f:25:72:f4:e2:19:94\n 9d:65:15:be:c8:82:20:57:12:97:b2:a8:4d:3d:e0:8f\n e2:1f:d0:c8:49:aa:f4:34:fa:91:d1:d1:cc:98:bc:3d\n 8b:b1:9b:8f:fd:ef:03:dd:92:fb:ca:99:45:af:cc:83\n 58:4c:bb:ba:73:9e:23:84:f9:7e:4f:40:fe:00:b5:bf\n 6f:\n\nprime2:\n 00:ef:14:ef:73:fc:0c:fc:e3:87:d9:7f:a6:f8:55:86\n 57:63:8a:86:87:f5:ef:63:20:1f:b2:ae:28:dc:ab:59\n 80:8f:15:64:44:e2:bc:a5:7b:d7:69:ef:30:b1:83:b3\n bd:09:fd:4a:0c:c6:31:5b:a4:79:d0:e5:d3:a8:31:fd\n 59:ea:52:63:cf:17:a7:c1:54:bf:a8:11:9b:b1:85:47\n 5a:08:a6:9c:2f:47:9d:ac:5d:e8:7c:e4:31:6c:99:71\n 04:7d:20:98:be:8b:60:07:66:2d:b9:41:10:ea:dd:5b\n 87:20:65:62:ea:75:a7:a6:04:a2:18:66:6b:db:5b:a4\n 9f:12:97:cb:7c:8c:d2:e0:ce:02:ef:1e:df:a1:9d:6a\n bc:00:38:18:36:a1:c5:97:16:be:7a:df:5f:4f:4f:de\n a3:cb:25:fe:f6:67:0d:31:aa:0a:d4:1b:be:df:91:2c\n 05:14:20:37:cc:4f:50:33:a6:50:1b:90:f9:b2:08:80\n d5:\n\ncoefficient:\n 47:d1:7f:ca:93:6a:14:9b:fe:85:8d:c2:15:11:52:a2\n a5:bc:f5:6b:a2:69:76:49:1e:09:79:f1:15:bf:39:48\n 41:ff:92:78:af:bc:7d:6f:76:3b:32:9e:08:d2:42:06\n 04:5f:36:e0:be:a8:1d:21:5c:ec:39:09:e0:77:c5:86\n 06:e6:ce:98:16:fc:0f:30:de:a7:69:7a:8f:dd:01:42\n 2a:22:f5:b7:c2:fc:c8:90:5a:78:dc:b3:e0:4d:e7:2d\n 98:6c:e3:34:1b:d7:e8:f8:90:57:7e:4d:41:d6:4a:29\n 81:92:eb:89:5b:45:85:dd:b9:16:20:63:cb:59:f6:06\n 59:c1:dd:3b:6b:92:0a:5e:5e:63:4a:f1:a7:d5:16:b9\n 8b:6c:d8:ad:76:0e:2d:3c:e0:b3:73:e0:6d:af:d4:a2\n bc:4b:fd:6c:2d:d7:5d:4d:cd:28:03:64:b2:ef:9a:1d\n 82:8d:53:40:c5:f8:fb:f3:63:de:8e:1a:21:b6:35:14\n \n\nexp1:\n 00:9c:a5:8a:d2:65:dc:03:69:8f:d2:16:d6:9d:55:5b\n 25:4e:ae:18:d8:7e:90:e6:10:11:d8:ca:41:89:f3:c4\n 06:64:aa:c8:c5:95:01:dd:fd:7c:7f:c9:39:73:8b:cb\n fd:9e:d3:84:12:cd:87:f9:02:b1:d8:6f:f7:49:f2:f7\n 35:14:8c:15:b2:2f:6f:1e:95:9c:8c:d9:46:45:65:4c\n f8:6f:a1:c4:ad:76:25:3b:37:ff:05:a1:f5:1b:e8:6d\n db:64:b9:10:37:55:01:ce:cf:f4:5b:26:4b:85:76:70\n 6a:b0:55:40:c9:bd:7a:57:4e:36:7d:41:be:03:9c:65\n dd:ea:6f:94:09:56:f2:d6:73:27:f9:f7:f9:16:5a:1a\n cb:b2:e5:83:28:b7:17:6f:6a:f7:41:1f:11:a1:63:cf\n a8:1e:e3:58:64:8c:78:8d:d9:81:c9:e1:8f:ea:0f:ad\n b6:a6:ee:54:1f:5c:56:ab:c9:0d:c1:60:2f:3d:d3:86\n 37:\n\nexp2:\n 64:12:b7:48:2d:30:a2:89:fa:cb:27:8b:94:56:f8:2c\n 8c:15:e7:c9:f1:3f:8a:96:5f:ae:43:08:07:96:11:98\n a6:4b:a5:f4:cf:93:77:11:27:51:c8:34:f1:98:d7:1b\n 41:9b:2b:eb:bc:e9:dc:1a:34:83:24:30:3c:2e:f0:85\n 3a:77:d2:1f:55:1f:7a:e5:26:74:0b:2a:c8:5b:a9:4a\n 1e:64:de:eb:4b:66:cc:47:62:91:24:53:2b:c9:ee:6c\n 9a:93:92:5b:ef:aa:fa:6d:e2:a5:b0:7e:8c:50:ab:87\n 1c:20:54:0f:1f:c0:54:d5:8b:a3:fa:fb:1a:8e:79:91\n bc:0e:9d:b6:3c:9b:e8:4d:53:1d:14:27:37:56:d4:de\n 6c:99:0e:49:8f:dd:4d:28:d0:02:4e:8d:6e:7d:58:0b\n e7:74:b8:0c:1b:86:82:4b:52:cd:05:f0:17:54:84:c0\n 7b:74:20:e6:fc:2b:ed:f2:a7:85:62:61:a2:0b:bd:21\n \n\n\nPublic Key PIN:\n pin-sha256:t5OXXC5gYqMNtUMsTqRs3A3vhfK2BiXVOgYzIEYv7Y8=\nPublic Key ID:\n sha256:b793975c2e6062a30db5432c4ea46cdc0def85f2b60625d53a063320462fed8f\n sha1:2f058a05034b2fdb3771bded4e7c8f560fa6a423\n\n-----BEGIN RSA PRIVATE KEY-----\nMIIG5AIBAAKCAYEA1Ryp+DKKSNFKZsPtwfR+jzOnQ8YFieIKYgakV688d8Ygpole\nnbmeEPrzT87tunFD7G9f6ALGND8rj7npj0AowxhOL/h/v1D9u0UsIaj5i2GWJrqN\nAhGLaxWiEB/hy5WOiwxDrGeigQqJkFM52Ep7G1Yx7PHJmKFGwN9FhIsFi1cNZfVR\nopZuCe/RMPNusNVZaIi+qcEffsE1cmfmuSlG3Ap0RKOIyR0ajDEzqZn9/0R7VwWC\nF97qy8TNYk94K/1tq3zyhVzRZ83xOSfrTqEfb3so3AU2jyKgYdwr/FZS72VCHS8I\nslgnqJW4izIXZqgIKmHaRZtMN4jUloi6l/6lktt6Lsgh9xECecxziSJtPMaog88a\nC8HnMqJJ3kScGCL36GYG+Kaw5PnDlWXBaeiDe8z/eWK9+Rr2M+rhTNxosAVGfDJy\nxAXyiX49LQ0v7f9qzwc/0JiDbvsUv1cm6OgpoEMP9SXqqBdwGqeKbD2/2jlP48xl\nYP6l1SoJG3GgZ8dbAgMBAAECggGBALFW0PoA1KITx14M3OTxl/+CdEYpmqJKv2kj\nLc7pu9/Pt4vd9CY8OBTZP2/COoFTj7pIU/61kEoZ5x4LDxhtw33V0/qHR4bk1r/n\np/m6qy4ZXuGLi5uVDfdmYR4Z6cOICL4czpPBCbFoG2FGYHRkRl1RNOp/qcqhKkeF\nhEvvhAWXw0Z9BhnOJHOQZPvfFtWANI6QfFi2pIbOMLOrUovylUy2Rlp323PADD9t\nEhioVHz/d8PKiZ9jmO9ILcEJcG7qy7t4kUKKIj4h76W/Fu5mReXwJmqFjuFpYqwF\nAKZEusisEACX9VFlf5ofe5mdAtSHUM50BlFn+vuQ5DN58qhh7kUdh8oiW6znMjj4\nLP1Vkh49YB58S/0o/+WxAmqqIveuqDaQe6b3KQUUOiHaNgX5sJ33+xB11ywhMpXn\n9xe+Cctm/vFpcd+kXj/8Z2w3ZbhRxiI4+wfOiVRQQ3FEPcNRWr3lx4ey6ntkD100\nnKFSs84Ghrp6BYBIs2wbeXSbSfIwwQKBwQDkMUZZPST3MdkiJq/APvXBbb66054/\nuSxDoNBHCeQ1YxmkM4Kv+XY8EcLLNPmmq92rZFprnMEqUolkfrWn8E0pE6TPF/Ty\nDaBuuV2VQRDfrvN6E0khZnMqt+KNfMI05T+9eMr8ZMUcOmZ6ElOWvbDDegzsXlXA\nwz9/JXL04hmUnWUVvsiCIFcSl7KoTT3gj+If0MhJqvQ0+pHR0cyYvD2LsZuP/e8D\n3ZL7yplFr8yDWEy7unOeI4T5fk9A/gC1v28CgcEA7xTvc/wM/OOH2X+m+FWGV2OK\nhof172MgH7KuKNyrWYCPFWRE4ryle9dp7zCxg7O9Cf1KDMYxW6R50OXTqDH9WepS\nY88Xp8FUv6gRm7GFR1oIppwvR52sXeh85DFsmXEEfSCYvotgB2YtuUEQ6t1bhyBl\nYup1p6YEohhma9tbpJ8Sl8t8jNLgzgLvHt+hnWq8ADgYNqHFlxa+et9fT0/eo8sl\n/vZnDTGqCtQbvt+RLAUUIDfMT1AzplAbkPmyCIDVAoHBAJylitJl3ANpj9IW1p1V\nWyVOrhjYfpDmEBHYykGJ88QGZKrIxZUB3f18f8k5c4vL/Z7ThBLNh/kCsdhv90ny\n9zUUjBWyL28elZyM2UZFZUz4b6HErXYlOzf/BaH1G+ht22S5EDdVAc7P9FsmS4V2\ncGqwVUDJvXpXTjZ9Qb4DnGXd6m+UCVby1nMn+ff5Floay7Llgyi3F29q90EfEaFj\nz6ge41hkjHiN2YHJ4Y/qD622pu5UH1xWq8kNwWAvPdOGNwKBwGQSt0gtMKKJ+ssn\ni5RW+CyMFefJ8T+Kll+uQwgHlhGYpkul9M+TdxEnUcg08ZjXG0GbK+u86dwaNIMk\nMDwu8IU6d9IfVR965SZ0CyrIW6lKHmTe60tmzEdikSRTK8nubJqTklvvqvpt4qWw\nfoxQq4ccIFQPH8BU1Yuj+vsajnmRvA6dtjyb6E1THRQnN1bU3myZDkmP3U0o0AJO\njW59WAvndLgMG4aCS1LNBfAXVITAe3Qg5vwr7fKnhWJhogu9IQKBwEfRf8qTahSb\n/oWNwhURUqKlvPVroml2SR4JefEVvzlIQf+SeK+8fW92OzKeCNJCBgRfNuC+qB0h\nXOw5CeB3xYYG5s6YFvwPMN6naXqP3QFCKiL1t8L8yJBaeNyz4E3nLZhs4zQb1+j4\nkFd+TUHWSimBkuuJW0WF3bkWIGPLWfYGWcHdO2uSCl5eY0rxp9UWuYts2K12Di08\n4LNz4G2v1KK8S/1sLdddTc0oA2Sy75odgo1TQMX4+/Nj3o4aIbY1FA==\n-----END RSA PRIVATE KEY-----" +} + +data "tencentcloud_ssl_certificates" "svr" { + name = tencentcloud_ssl_certificate.svr.name +} + +resource "tencentcloud_ssl_certificate" "svr" { + name = "ssl-svr" + type = "SVR" + cert = var.cert + key = var.key } ``` diff --git a/website/docs/r/ssl_free_certificate.html.markdown b/website/docs/r/ssl_free_certificate.html.markdown index b80a500c2d..91261d7982 100644 --- a/website/docs/r/ssl_free_certificate.html.markdown +++ b/website/docs/r/ssl_free_certificate.html.markdown @@ -15,18 +15,20 @@ Provide a resource to create a Free Certificate. ## Example Usage +### only support type 2. 2=TrustAsia TLS RSA CA. + ```hcl -resource "tencentcloud_ssl_free_certificate" "foo" { +resource "tencentcloud_ssl_free_certificate" "example" { dv_auth_method = "DNS_AUTO" domain = "example.com" package_type = "2" - contact_email = "foo@example.com" - contact_phone = "12345678901" + contact_email = "test@example.com" + contact_phone = "18352458901" validity_period = 12 csr_encrypt_algo = "RSA" csr_key_parameter = "2048" - csr_key_password = "xxxxxxxx" - alias = "my_free_cert" + csr_key_password = "csr_pwd" + alias = "example_free_cert" } ``` diff --git a/website/docs/r/ssl_pay_certificate.html.markdown b/website/docs/r/ssl_pay_certificate.html.markdown index 6354febd19..21c47dbbde 100644 --- a/website/docs/r/ssl_pay_certificate.html.markdown +++ b/website/docs/r/ssl_pay_certificate.html.markdown @@ -20,34 +20,34 @@ as `Review Cancel`, and then you can click `Request a refund` to refund the fee. ## Example Usage ```hcl -resource "tencentcloud_ssl_pay_certificate" "ssl" { +resource "tencentcloud_ssl_pay_certificate" "example" { product_id = 33 domain_num = 1 - alias = "test-ssl" + alias = "ssl desc." project_id = 0 information { csr_type = "online" - certificate_domain = "www.domain.com" - organization_name = "test" - organization_division = "test" - organization_address = "test" + certificate_domain = "www.example.com" + organization_name = "Tencent" + organization_division = "Qcloud" + organization_address = "广东省深圳市南山区腾讯大厦1000号" organization_country = "CN" - organization_city = "test" - organization_region = "test" + organization_city = "深圳市" + organization_region = "广东省" postal_code = "0755" phone_area_code = "0755" - phone_number = "12345678901" + phone_number = "86013388" verify_type = "DNS" admin_first_name = "test" admin_last_name = "test" admin_phone_num = "12345678901" admin_email = "test@tencent.com" - admin_position = "dev" + admin_position = "developer" contact_first_name = "test" contact_last_name = "test" contact_email = "test@tencent.com" contact_number = "12345678901" - contact_position = "dev" + contact_position = "developer" } } ``` diff --git a/website/docs/r/subnet.html.markdown b/website/docs/r/subnet.html.markdown index a70359f421..178ca35cc1 100644 --- a/website/docs/r/subnet.html.markdown +++ b/website/docs/r/subnet.html.markdown @@ -14,20 +14,18 @@ Provide a resource to create a VPC subnet. ## Example Usage ```hcl -variable "availability_zone" { - default = "ap-guangzhou-3" -} +data "tencentcloud_availability_zones" "zones" {} -resource "tencentcloud_vpc" "foo" { - name = "guagua-ci-temp-test" +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" cidr_block = "10.0.0.0/16" } resource "tencentcloud_subnet" "subnet" { - availability_zone = var.availability_zone - name = "guagua-ci-temp-test" - vpc_id = tencentcloud_vpc.foo.id - cidr_block = "10.0.20.0/28" + vpc_id = tencentcloud_vpc.vpc.id + name = "subnet-example" + cidr_block = "10.0.0.0/16" + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name is_multicast = false } ``` diff --git a/website/docs/r/vpc.html.markdown b/website/docs/r/vpc.html.markdown index 05baf06c4d..754bbc9617 100644 --- a/website/docs/r/vpc.html.markdown +++ b/website/docs/r/vpc.html.markdown @@ -13,9 +13,11 @@ Provide a resource to create a VPC. ## Example Usage +### Create a basic VPC + ```hcl -resource "tencentcloud_vpc" "foo" { - name = "ci-temp-test-updated" +resource "tencentcloud_vpc" "vpc" { + name = "tf-example" cidr_block = "10.0.0.0/16" dns_servers = ["119.29.29.29", "8.8.8.8"] is_multicast = false @@ -29,8 +31,8 @@ resource "tencentcloud_vpc" "foo" { ### Using Assistant CIDR ```hcl -resource "tencentcloud_vpc" "foo" { - name = "ci-temp-test-updated" +resource "tencentcloud_vpc" "vpc" { + name = "tf-example" cidr_block = "10.0.0.0/16" is_multicast = false assistant_cidrs = ["172.16.0.0/24"] diff --git a/website/docs/r/vpc_acl.html.markdown b/website/docs/r/vpc_acl.html.markdown index 705216f0f0..456c4b5fec 100644 --- a/website/docs/r/vpc_acl.html.markdown +++ b/website/docs/r/vpc_acl.html.markdown @@ -14,12 +14,14 @@ Provide a resource to create a VPC ACL instance. ## Example Usage ```hcl -data "tencentcloud_vpc_instances" "default" { +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" } -resource "tencentcloud_vpc_acl" "foo" { - vpc_id = data.tencentcloud_vpc_instances.default.instance_list.0.vpc_id - name = "test_acl_update" +resource "tencentcloud_vpc_acl" "example" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf-example" ingress = [ "ACCEPT#192.168.1.0/24#800#TCP", "ACCEPT#192.168.1.0/24#800-900#TCP", diff --git a/website/docs/r/vpc_acl_attachment.html.markdown b/website/docs/r/vpc_acl_attachment.html.markdown index c1afb8271a..7a16903a95 100644 --- a/website/docs/r/vpc_acl_attachment.html.markdown +++ b/website/docs/r/vpc_acl_attachment.html.markdown @@ -14,11 +14,23 @@ Provide a resource to attach an existing subnet to Network ACL. ## Example Usage ```hcl -data "tencentcloud_vpc_instances" "id_instances" { +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name } -resource "tencentcloud_vpc_acl" "foo" { - vpc_id = data.tencentcloud_vpc_instances.id_instances.instance_list.0.vpc_id - name = "test_acl" + +resource "tencentcloud_vpc_acl" "example" { + vpc_id = tencentcloud_vpc.vpc.id + name = "tf-example" ingress = [ "ACCEPT#192.168.1.0/24#800#TCP", "ACCEPT#192.168.1.0/24#800-900#TCP", @@ -30,8 +42,8 @@ resource "tencentcloud_vpc_acl" "foo" { } resource "tencentcloud_vpc_acl_attachment" "attachment" { - acl_id = tencentcloud_vpc_acl.foo.id - subnet_id = data.tencentcloud_vpc_instances.id_instances.instance_list[0].subnet_ids[0] + acl_id = tencentcloud_vpc_acl.example.id + subnet_id = tencentcloud_subnet.subnet.id } ``` diff --git a/website/docs/r/vpc_bandwidth_package.html.markdown b/website/docs/r/vpc_bandwidth_package.html.markdown index a2408081fe..518b154c1f 100644 --- a/website/docs/r/vpc_bandwidth_package.html.markdown +++ b/website/docs/r/vpc_bandwidth_package.html.markdown @@ -14,10 +14,10 @@ Provides a resource to create a vpc bandwidth_package ## Example Usage ```hcl -resource "tencentcloud_vpc_bandwidth_package" "bandwidth_package" { +resource "tencentcloud_vpc_bandwidth_package" "example" { network_type = "BGP" charge_type = "TOP5_POSTPAID_BY_MONTH" - bandwidth_package_name = "test-001" + bandwidth_package_name = "tf-example" tags = { "createdBy" = "terraform" } diff --git a/website/docs/r/vpc_bandwidth_package_attachment.html.markdown b/website/docs/r/vpc_bandwidth_package_attachment.html.markdown index e5f382e5b2..6273137b8f 100644 --- a/website/docs/r/vpc_bandwidth_package_attachment.html.markdown +++ b/website/docs/r/vpc_bandwidth_package_attachment.html.markdown @@ -14,12 +14,46 @@ Provides a resource to create a vpc bandwidth_package_attachment ## Example Usage ```hcl -resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_attachment" { - resource_id = "lb-dv1ai6ma" - bandwidth_package_id = "bwp-atmf0p9g" +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name +} + +resource "tencentcloud_vpc_bandwidth_package" "example" { + network_type = "BGP" + charge_type = "TOP5_POSTPAID_BY_MONTH" + bandwidth_package_name = "tf-example" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_clb_instance" "example" { + network_type = "INTERNAL" + clb_name = "tf-example" + project_id = 0 + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_vpc_bandwidth_package_attachment" "attachment" { + resource_id = tencentcloud_clb_instance.example.id + bandwidth_package_id = tencentcloud_vpc_bandwidth_package.example.id network_type = "BGP" resource_type = "LoadBalance" - protocol = "" } ``` diff --git a/website/docs/r/vpc_dhcp_ip.html.markdown b/website/docs/r/vpc_dhcp_ip.html.markdown index 474e848886..dd31648760 100644 --- a/website/docs/r/vpc_dhcp_ip.html.markdown +++ b/website/docs/r/vpc_dhcp_ip.html.markdown @@ -14,10 +14,25 @@ Provides a resource to create a vpc dhcp_ip ## Example Usage ```hcl -resource "tencentcloud_vpc_dhcp_ip" "dhcp_ip" { - vpc_id = "vpc-1yg5ua6l" - subnet_id = "subnet-h7av55g8" - dhcp_ip_name = "terraform-test" +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_vpc_dhcp_ip" "example" { + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + dhcp_ip_name = "tf-example" } ``` diff --git a/website/docs/r/vpc_flow_log.html.markdown b/website/docs/r/vpc_flow_log.html.markdown index 547fe0e364..f1aaa0aafa 100644 --- a/website/docs/r/vpc_flow_log.html.markdown +++ b/website/docs/r/vpc_flow_log.html.markdown @@ -11,20 +11,104 @@ description: |- Provides a resource to create a vpc flow_log +~> **NOTE:** The cloud server instance specifications that support stream log collection include: M6ce, M6p, SA3se, S4m, DA3, ITA3, I6t, I6, S5se, SA2, SK1, S4, S5, SN3ne, S3ne, S2ne, SA2a, S3ne, SW3a, SW3b, SW3ne, ITA3, IT5c, IT5, IT5c, IT3, I3, D3, DA2, D2, M6, MA2, M4, C6, IT3a, IT3b, IT3c, C4ne, CN3ne, C3ne, GI1, PNV4, GNV4v, GNV4, GT4, GI3X, GN7, GN7vw. + +~> **NOTE:** The following models no longer support the collection of new stream logs, and the stock stream logs will no longer be reported for data from July 25, 2022: Standard models: S3, SA1, S2, S1;Memory type: M3, M2, M1;Calculation type: C4, CN3, C3, C2;Batch calculation type: BC1, BS1;HPCC: HCCIC5, HCCG5v. + ## Example Usage ```hcl -resource "tencentcloud_vpc_flow_log" "flow_log" { - flow_log_name = "foo" +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +data "tencentcloud_instance_types" "instance_types" { + filter { + name = "zone" + values = [data.tencentcloud_availability_zones.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} + +resource "tencentcloud_cls_logset" "logset" { + logset_name = "delogsetmo" + tags = { + "test" = "test" + } +} + +resource "tencentcloud_cls_topic" "topic" { + topic_name = "topic" + logset_id = tencentcloud_cls_logset.logset.id + auto_split = false + max_split_partitions = 20 + partition_count = 1 + period = 10 + storage_type = "hot" + tags = { + "test" = "test", + } +} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-flow-log-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "vpc-flow-log-subnet" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eni" "example" { + name = "vpc-flow-log-eni" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc" + ipv4_count = 1 +} + +resource "tencentcloud_instance" "example" { + instance_name = "ci-test-eni-attach" + availability_zone = data.tencentcloud_availability_zones.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" + disable_security_service = true + disable_monitor_service = true + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + +resource "tencentcloud_eni_attachment" "example" { + eni_id = tencentcloud_eni.example.id + instance_id = tencentcloud_instance.example.id +} + +resource "tencentcloud_vpc_flow_log" "example" { + flow_log_name = "tf-example-vpc-flow-log" resource_type = "NETWORKINTERFACE" - resource_id = "eni-xxxxxxxx" - traffic_type = "ALL" - vpc_id = "vpc-xxxxxxxx" - flow_log_description = "My testing log" - cloud_log_id = "a1b2c3d4-e5f6a7b8-c9d0e1f2-a3b4c5d6" + resource_id = tencentcloud_eni_attachment.example.eni_id + traffic_type = "ACCEPT" + vpc_id = tencentcloud_vpc.vpc.id + flow_log_description = "this is a testing flow log" + cloud_log_id = tencentcloud_cls_topic.topic.id storage_type = "cls" tags = { - "createdBy" = "terraform" + "testKey" = "testValue" } } ``` diff --git a/website/docs/r/vpc_flow_log_config.html.markdown b/website/docs/r/vpc_flow_log_config.html.markdown index 8105ddeebe..90c4b317ed 100644 --- a/website/docs/r/vpc_flow_log_config.html.markdown +++ b/website/docs/r/vpc_flow_log_config.html.markdown @@ -13,13 +13,118 @@ Provides a resource to create a vpc flow_log_config ## Example Usage +### If disable FlowLogs + ```hcl -resource "tencentcloud_vpc_flow_log_config" "flow_log_config" { - flow_log_id = "fl-geg2keoj" +data "tencentcloud_availability_zones" "zones" {} + +data "tencentcloud_images" "image" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +data "tencentcloud_instance_types" "instance_types" { + filter { + name = "zone" + values = [data.tencentcloud_availability_zones.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} + +resource "tencentcloud_cls_logset" "logset" { + logset_name = "delogsetmo" + tags = { + "test" = "test" + } +} + +resource "tencentcloud_cls_topic" "topic" { + topic_name = "topic" + logset_id = tencentcloud_cls_logset.logset.id + auto_split = false + max_split_partitions = 20 + partition_count = 1 + period = 10 + storage_type = "hot" + tags = { + "test" = "test", + } +} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-flow-log-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "vpc-flow-log-subnet" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eni" "example" { + name = "vpc-flow-log-eni" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc" + ipv4_count = 1 +} + +resource "tencentcloud_instance" "example" { + instance_name = "ci-test-eni-attach" + availability_zone = data.tencentcloud_availability_zones.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" + disable_security_service = true + disable_monitor_service = true + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id +} + +resource "tencentcloud_eni_attachment" "example" { + eni_id = tencentcloud_eni.example.id + instance_id = tencentcloud_instance.example.id +} + +resource "tencentcloud_vpc_flow_log" "example" { + flow_log_name = "tf-example-vpc-flow-log" + resource_type = "NETWORKINTERFACE" + resource_id = tencentcloud_eni_attachment.example.eni_id + traffic_type = "ACCEPT" + vpc_id = tencentcloud_vpc.vpc.id + flow_log_description = "this is a testing flow log" + cloud_log_id = tencentcloud_cls_topic.topic.id + storage_type = "cls" + tags = { + "testKey" = "testValue" + } +} + +resource "tencentcloud_vpc_flow_log_config" "config" { + flow_log_id = tencentcloud_vpc_flow_log.example.id enable = false } ``` +### If enable FlowLogs + +```hcl +resource "tencentcloud_vpc_flow_log_config" "config" { + flow_log_id = tencentcloud_vpc_flow_log.example.id + enable = true +} +``` + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/vpc_ipv6_cidr_block.html.markdown b/website/docs/r/vpc_ipv6_cidr_block.html.markdown index da5e8df230..0f5d500f29 100644 --- a/website/docs/r/vpc_ipv6_cidr_block.html.markdown +++ b/website/docs/r/vpc_ipv6_cidr_block.html.markdown @@ -14,14 +14,13 @@ Provides a resource to create a vpc ipv6_cidr_block ## Example Usage ```hcl -resource "tencentcloud_vpc" "cidr-block" { - name = "ipv6-cidr-block-for-test" - cidr_block = "10.0.0.0/16" - is_multicast = false +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" } -resource "tencentcloud_vpc_ipv6_cidr_block" "ipv6_cidr_block" { - vpc_id = tencentcloud_vpc.cidr-block.id +resource "tencentcloud_vpc_ipv6_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id } ``` diff --git a/website/docs/r/vpc_ipv6_eni_address.html.markdown b/website/docs/r/vpc_ipv6_eni_address.html.markdown index 66d7a5152c..7c0584f858 100644 --- a/website/docs/r/vpc_ipv6_eni_address.html.markdown +++ b/website/docs/r/vpc_ipv6_eni_address.html.markdown @@ -14,12 +14,39 @@ Provides a resource to create a vpc ipv6_eni_address ## Example Usage ```hcl +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_eni" "eni" { + name = "eni-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + description = "eni desc." + ipv4_count = 1 +} + +resource "tencentcloud_vpc_ipv6_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id +} + resource "tencentcloud_vpc_ipv6_eni_address" "ipv6_eni_address" { - vpc_id = "vpc-7w3kgnpl" - network_interface_id = "eni-pzl7fz37" + vpc_id = tencentcloud_vpc.vpc.id + network_interface_id = tencentcloud_eni.eni.id ipv6_addresses { - address = "2402:4e00:1019:6a7b:0:994e:7cd7:fb46" - description = "test123" + address = tencentcloud_vpc_ipv6_cidr_block.example.ipv6_cidr_block + description = "desc." } } ``` diff --git a/website/docs/r/vpc_ipv6_subnet_cidr_block.html.markdown b/website/docs/r/vpc_ipv6_subnet_cidr_block.html.markdown index 970bca3737..5421fdeacf 100644 --- a/website/docs/r/vpc_ipv6_subnet_cidr_block.html.markdown +++ b/website/docs/r/vpc_ipv6_subnet_cidr_block.html.markdown @@ -14,11 +14,30 @@ Provides a resource to create a vpc ipv6_subnet_cidr_block ## Example Usage ```hcl -resource "tencentcloud_vpc_ipv6_subnet_cidr_block" "ipv6_subnet_cidr_block" { - vpc_id = "vpc-7w3kgnpl" +data "tencentcloud_availability_zones" "zones" {} + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_vpc_ipv6_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id +} + +resource "tencentcloud_vpc_ipv6_subnet_cidr_block" "example" { + vpc_id = tencentcloud_vpc.vpc.id ipv6_subnet_cidr_blocks { - subnet_id = "subnet-plg028y8" - ipv6_cidr_block = "2402:4e00:1019:6a7b::/64" + subnet_id = tencentcloud_subnet.subnet.id + ipv6_cidr_block = tencentcloud_vpc_ipv6_cidr_block.example.ipv6_cidr_block } } ``` diff --git a/website/docs/r/vpc_local_gateway.html.markdown b/website/docs/r/vpc_local_gateway.html.markdown index 4bb467deb2..e89972a979 100644 --- a/website/docs/r/vpc_local_gateway.html.markdown +++ b/website/docs/r/vpc_local_gateway.html.markdown @@ -14,9 +14,14 @@ Provides a resource to create a vpc local_gateway ## Example Usage ```hcl -resource "tencentcloud_vpc_local_gateway" "local_gateway" { - local_gateway_name = "local-gw-test" - vpc_id = "vpc-lh4nqig9" +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_vpc_local_gateway" "example" { + local_gateway_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id cdc_id = "cluster-j9gyu1iy" } ``` diff --git a/website/docs/r/vpc_net_detect.html.markdown b/website/docs/r/vpc_net_detect.html.markdown index 3a58fe3c0d..14e241967d 100644 --- a/website/docs/r/vpc_net_detect.html.markdown +++ b/website/docs/r/vpc_net_detect.html.markdown @@ -13,14 +13,204 @@ Provides a resource to create a vpc net_detect ## Example Usage +### Create a basic Net Detect + +```hcl +data "tencentcloud_availability_zones" "zones" {} + +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.zones.zones.0.name +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + detect_destination_ip = [ + "10.0.0.1", + "10.0.0.2", + ] +} +``` + + + ```hcl -resource "tencentcloud_vpc_net_detect" "net_detect" { - net_detect_name = "terrform-test" - vpc_id = "vpc-4owdpnwr" - subnet_id = "subnet-c1l35990" - next_hop_destination = "172.16.128.57" +resource "tencentcloud_vpn_gateway" "vpn" { + name = "tf-example" + bandwidth = 100 + zone = data.tencentcloud_availability_zones.zones.zones.0.name + type = "SSL" + vpc_id = tencentcloud_vpc.vpc.id + + tags = { + test = "test" + } +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "VPN" + next_hop_destination = tencentcloud_vpn_gateway.vpn.id + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + + + +```hcl +resource "tencentcloud_dc_gateway" "example" { + name = "ci-cdg-vpc-test" + network_instance_id = tencentcloud_vpc.vpc.id + network_type = "VPC" + gateway_type = "NAT" +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "DIRECTCONNECT" + next_hop_destination = tencentcloud_dc_gateway.example.id + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + + + +```hcl +resource "tencentcloud_eip" "eip_example1" { + name = "tf_nat_gateway_eip1" +} + +resource "tencentcloud_eip" "eip_example2" { + name = "tf_nat_gateway_eip2" +} + +resource "tencentcloud_nat_gateway" "example" { + name = "tf_example_nat_gateway" + vpc_id = tencentcloud_vpc.vpc.id + bandwidth = 100 + max_concurrent = 1000000 + assigned_eip_set = [ + tencentcloud_eip.eip_example1.public_ip, + tencentcloud_eip.eip_example2.public_ip, + ] + tags = { + tf_tag_key = "tf_tag_value" + } +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "NAT" + next_hop_destination = tencentcloud_nat_gateway.example.id + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + + + +```hcl +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.zones.zones.0.name] + } + + filter { + name = "instance-family" + values = ["S5"] + } + + cpu_core_count = 2 + exclude_sold_out = true +} + +resource "tencentcloud_instance" "example" { + instance_name = "tf_example" + availability_zone = data.tencentcloud_availability_zones.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 +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id next_hop_type = "NORMAL_CVM" - subnet_id = "subnet-c1l35990" + next_hop_destination = tencentcloud_instance.example.private_ip + detect_destination_ip = [ + "192.16.10.10", + "172.16.10.22", + ] +} +``` + + + +```hcl +resource "tencentcloud_ccn" "example" { + name = "tf-example" + description = "desc." + qos = "AU" + charge_type = "POSTPAID" + bandwidth_limit_type = "OUTER_REGION_LIMIT" +} + +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "CCN" + next_hop_destination = tencentcloud_ccn.example.id + detect_destination_ip = [ + "172.10.0.1", + "172.10.0.2", + ] +} +``` + + + +```hcl +resource "tencentcloud_vpc_net_detect" "example" { + net_detect_name = "tf-example" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + next_hop_type = "NONEXTHOP" detect_destination_ip = [ "10.0.0.1", "10.0.0.2", diff --git a/website/docs/r/vpc_resume_snapshot_instance.html.markdown b/website/docs/r/vpc_resume_snapshot_instance.html.markdown index c0b58e95b5..260df10835 100644 --- a/website/docs/r/vpc_resume_snapshot_instance.html.markdown +++ b/website/docs/r/vpc_resume_snapshot_instance.html.markdown @@ -13,10 +13,56 @@ Provides a resource to create a vpc resume_snapshot_instance ## Example Usage +### Basic example + ```hcl resource "tencentcloud_vpc_resume_snapshot_instance" "resume_snapshot_instance" { snapshot_policy_id = "sspolicy-1t6cobbv" - snapshot_file_id = "ssfile-test" + snapshot_file_id = "ssfile-emtabuwu2z" + instance_id = "ntrgm89v" +} +``` + +### Complete example + +```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" } ``` diff --git a/website/docs/r/vpc_snapshot_policy.html.markdown b/website/docs/r/vpc_snapshot_policy.html.markdown index e04e852aae..1a91f361ca 100644 --- a/website/docs/r/vpc_snapshot_policy.html.markdown +++ b/website/docs/r/vpc_snapshot_policy.html.markdown @@ -14,10 +14,15 @@ Provides a resource to create a vpc snapshot_policy ## Example Usage ```hcl -resource "tencentcloud_vpc_snapshot_policy" "snapshot_policy" { - snapshot_policy_name = "terraform-test" +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 = "cos-lock-1308919341" + cos_bucket = tencentcloud_cos_bucket.example.bucket cos_region = "ap-guangzhou" create_new_cos = false keep_time = 2 @@ -28,11 +33,11 @@ resource "tencentcloud_vpc_snapshot_policy" "snapshot_policy" { } backup_policies { backup_day = "tuesday" - backup_time = "02:03:03" + backup_time = "01:00:00" } backup_policies { backup_day = "wednesday" - backup_time = "04:13:23" + backup_time = "02:00:00" } } ``` diff --git a/website/docs/r/vpc_snapshot_policy_attachment.html.markdown b/website/docs/r/vpc_snapshot_policy_attachment.html.markdown index 91e780b82d..8f3fd86eeb 100644 --- a/website/docs/r/vpc_snapshot_policy_attachment.html.markdown +++ b/website/docs/r/vpc_snapshot_policy_attachment.html.markdown @@ -14,20 +14,46 @@ Provides a resource to create a vpc snapshot_policy_attachment ## Example Usage ```hcl -resource "tencentcloud_vpc_snapshot_policy_attachment" "snapshot_policy_attachment" { - snapshot_policy_id = "sspolicy-1t6cobbv" +resource "tencentcloud_cos_bucket" "example" { + bucket = "tf-example-1308919341" + acl = "private" +} - instances { - instance_id = "sg-r8ibzbd9" - instance_name = "cm-eks-cls-eizsc1iw-security-group" - instance_region = "ap-guangzhou" - instance_type = "securitygroup" +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_security_group" "example" { + name = "tf-example" + description = "desc." +} + +resource "tencentcloud_vpc_snapshot_policy_attachment" "attachment" { + snapshot_policy_id = tencentcloud_vpc_snapshot_policy.example.id + instances { - instance_id = "sg-k3tn70lh" - instance_name = "keep-ci-temp-test-sg" - instance_region = "ap-guangzhou" instance_type = "securitygroup" + instance_id = tencentcloud_security_group.example.id + instance_name = "tf-example" + instance_region = "ap-guangzhou" } } ``` diff --git a/website/docs/r/vpc_snapshot_policy_config.html.markdown b/website/docs/r/vpc_snapshot_policy_config.html.markdown index 33efb348bd..cb8be09f0c 100644 --- a/website/docs/r/vpc_snapshot_policy_config.html.markdown +++ b/website/docs/r/vpc_snapshot_policy_config.html.markdown @@ -14,8 +14,35 @@ Provides a resource to create a vpc snapshot_policy_config ## Example Usage ```hcl -resource "tencentcloud_vpc_snapshot_policy_config" "snapshot_policy_config" { - snapshot_policy_id = "sspolicy-1t6cobbv" +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_snapshot_policy_config" "config" { + snapshot_policy_id = tencentcloud_vpc_snapshot_policy.example.id enable = false } ``` diff --git a/website/docs/r/vpc_traffic_package.html.markdown b/website/docs/r/vpc_traffic_package.html.markdown index 5082b7a929..f003b78eb9 100644 --- a/website/docs/r/vpc_traffic_package.html.markdown +++ b/website/docs/r/vpc_traffic_package.html.markdown @@ -14,7 +14,7 @@ Provides a resource to create a vpc traffic_package ## Example Usage ```hcl -resource "tencentcloud_vpc_traffic_package" "traffic_package" { +resource "tencentcloud_vpc_traffic_package" "example" { traffic_amount = 10 } ```