diff --git a/.changelog/2888.txt b/.changelog/2888.txt new file mode 100644 index 0000000000..c750b2e155 --- /dev/null +++ b/.changelog/2888.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +tencentcloud_postgresql_clone_db_instance +``` \ No newline at end of file diff --git a/tencentcloud/connectivity/client.go b/tencentcloud/connectivity/client.go index 494adba5fb..2b61103c20 100644 --- a/tencentcloud/connectivity/client.go +++ b/tencentcloud/connectivity/client.go @@ -211,10 +211,11 @@ type TencentCloudClient struct { controlcenterConn *controlcenter.Client thpcConn *thpc.Client //omit nil client - omitNilConn *common.Client - emrv20190103Conn *emr.Client - teov20220901Conn *teo.Client - sslv20191205Conn *sslCertificate.Client + omitNilConn *common.Client + emrv20190103Conn *emr.Client + teov20220901Conn *teo.Client + sslv20191205Conn *sslCertificate.Client + postgresv20170312Conn *postgre.Client } // NewClientProfile returns a new ClientProfile @@ -1858,3 +1859,16 @@ func (me *TencentCloudClient) UseSslV20191205Client() *sslCertificate.Client { return me.sslv20191205Conn } + +// UsePostgresV20170312Client return POSTGRES client for service +func (me *TencentCloudClient) UsePostgresV20170312Client() *postgre.Client { + if me.postgresv20170312Conn != nil { + return me.postgresv20170312Conn + } + cpf := me.NewClientProfile(300) + cpf.Language = "zh-CN" + me.postgresv20170312Conn, _ = postgre.NewClient(me.Credential, me.Region, cpf) + me.postgresv20170312Conn.WithHttpTransport(&LogRoundTripper{}) + + return me.postgresv20170312Conn +} diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index fb426a141d..154f8eef77 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -1506,6 +1506,7 @@ func Provider() *schema.Provider { "tencentcloud_postgresql_account": postgresql.ResourceTencentCloudPostgresqlAccount(), "tencentcloud_postgresql_account_privileges_operation": postgresql.ResourceTencentCloudPostgresqlAccountPrivilegesOperation(), "tencentcloud_postgresql_apply_parameter_template_operation": postgresql.ResourceTencentCloudPostgresqlApplyParameterTemplateOperation(), + "tencentcloud_postgresql_clone_db_instance": postgresql.ResourceTencentCloudPostgresqlCloneDbInstance(), "tencentcloud_sqlserver_instance": sqlserver.ResourceTencentCloudSqlserverInstance(), "tencentcloud_sqlserver_db": sqlserver.ResourceTencentCloudSqlserverDB(), "tencentcloud_sqlserver_account": sqlserver.ResourceTencentCloudSqlserverAccount(), diff --git a/tencentcloud/provider.md b/tencentcloud/provider.md index e0710bfbfb..e711cf85dd 100644 --- a/tencentcloud/provider.md +++ b/tencentcloud/provider.md @@ -901,6 +901,7 @@ TencentDB for PostgreSQL(PostgreSQL) tencentcloud_postgresql_instance_ha_config tencentcloud_postgresql_account tencentcloud_postgresql_apply_parameter_template_operation + tencentcloud_postgresql_clone_db_instance TencentDB for Redis(crs) Data Source diff --git a/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance.go b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance.go new file mode 100644 index 0000000000..4699bce30c --- /dev/null +++ b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance.go @@ -0,0 +1,356 @@ +// Code generated by iacg; DO NOT EDIT. +package postgresql + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + postgresv20170312 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres/v20170312" + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" + "log" + "time" +) + +func ResourceTencentCloudPostgresqlCloneDbInstance() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudPostgresqlCloneDbInstanceCreate, + Read: resourceTencentCloudPostgresqlCloneDbInstanceRead, + Delete: resourceTencentCloudPostgresqlCloneDbInstanceDelete, + Schema: map[string]*schema.Schema{ + "db_instance_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "ID of the original instance to be cloned.", + }, + + "spec_code": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Purchasable code, which can be obtained from the `SpecCode` field in the return value of the [DescribeClasses](https://intl.cloud.tencent.com/document/api/409/89019?from_cn_redirect=1) API.", + }, + + "storage": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + Description: "Instance storage capacity in GB.", + }, + + "period": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + Description: "Purchase duration, in months.\n- Prepaid: Supports `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, and `36`.\n- Pay-as-you-go: Only supports `1`.", + }, + + "auto_renew_flag": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + Description: "Renewal Flag:\n\n- `0`: manual renewal\n`1`: auto-renewal\n\nDefault value: 0.", + }, + + "vpc_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "VPC ID in the format of `vpc-xxxxxxx`, which can be obtained in the console or from the `unVpcId` field in the return value of the [DescribeVpcEx](https://intl.cloud.tencent.com/document/api/215/1372?from_cn_redirect=1) API.", + }, + + "subnet_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "VPC subnet ID in the format of `subnet-xxxxxxxx`, which can be obtained in the console or from the `unSubnetId` field in the return value of the [DescribeSubnets](https://intl.cloud.tencent.com/document/api/215/15784?from_cn_redirect=1) API.", + }, + + "name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Name of the newly purchased instance, which can contain up to 60 letters, digits, or symbols (-_). If this parameter is not specified, \"Unnamed\" will be displayed by default.", + }, + + "instance_charge_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Instance billing type, which currently supports:\n\n- PREPAID: Prepaid, i.e., monthly subscription\n- POSTPAID_BY_HOUR: Pay-as-you-go, i.e., pay by consumption\n\nDefault value: PREPAID.", + }, + + "security_group_ids": { + Type: schema.TypeSet, + Optional: true, + ForceNew: true, + Description: "Security group of the instance, which can be obtained from the `sgld` field in the return value of the [DescribeSecurityGroups](https://intl.cloud.tencent.com/document/api/215/15808?from_cn_redirect=1) API. If this parameter is not specified, the default security group will be bound.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + + "project_id": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Description: "Project ID.", + }, + + "tag_list": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: "The information of tags to be bound with the instance, which is left empty by default. This parameter can be obtained from the `Tags` field in the return value of the [DescribeTags](https://intl.cloud.tencent.com/document/api/651/35316?from_cn_redirect=1) API.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tag_key": { + Type: schema.TypeString, + Required: true, + Description: "Tag key.", + }, + "tag_value": { + Type: schema.TypeString, + Required: true, + Description: "Tag value.", + }, + }, + }, + }, + + "db_node_set": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: "Deployment information of the instance node, which will display the information of each AZ when the instance node is deployed across multiple AZs.\nThe information of AZ can be obtained from the `Zone` field in the return value of the [DescribeZones](https://intl.cloud.tencent.com/document/api/409/16769?from_cn_redirect=1) API.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "role": { + Type: schema.TypeString, + Required: true, + Description: "Node type. Valid values:\n`Primary`;\n`Standby`.", + }, + "zone": { + Type: schema.TypeString, + Required: true, + Description: "AZ where the node resides, such as ap-guangzhou-1.", + }, + }, + }, + }, + + "activity_id": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Description: "Campaign ID.", + }, + + "backup_set_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Basic backup set ID.", + }, + + "recovery_target_time": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Restoration point in time.", + }, + + "sync_mode": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Primary-standby sync mode, which supports:\nSemi-sync: Semi-sync\nAsync: Asynchronous\nDefault value for the primary instance: Semi-sync\nDefault value for the read-only instance: Async.", + }, + }, + } +} + +func resourceTencentCloudPostgresqlCloneDbInstanceCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_postgresql_clone_db_instance.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + var ( + dBInstanceId string + ) + var ( + request = postgresv20170312.NewCloneDBInstanceRequest() + response = postgresv20170312.NewCloneDBInstanceResponse() + ) + + if v, ok := d.GetOk("db_instance_id"); ok { + request.DBInstanceId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("spec_code"); ok { + request.SpecCode = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("storage"); ok { + request.Storage = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOkExists("period"); ok { + request.Period = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOkExists("auto_renew_flag"); ok { + request.AutoRenewFlag = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOk("vpc_id"); ok { + request.VpcId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("subnet_id"); ok { + request.SubnetId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("name"); ok { + request.Name = helper.String(v.(string)) + } + + if v, ok := d.GetOk("instance_charge_type"); ok { + request.InstanceChargeType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("security_group_ids"); ok { + securityGroupIdsSet := v.(*schema.Set).List() + for i := range securityGroupIdsSet { + securityGroupIds := securityGroupIdsSet[i].(string) + request.SecurityGroupIds = append(request.SecurityGroupIds, helper.String(securityGroupIds)) + } + } + + if v, ok := d.GetOkExists("project_id"); ok { + request.ProjectId = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOk("tag_list"); ok { + for _, item := range v.([]interface{}) { + tagListMap := item.(map[string]interface{}) + tag := postgresv20170312.Tag{} + if v, ok := tagListMap["tag_key"]; ok { + tag.TagKey = helper.String(v.(string)) + } + if v, ok := tagListMap["tag_value"]; ok { + tag.TagValue = helper.String(v.(string)) + } + request.TagList = append(request.TagList, &tag) + } + } + + if v, ok := d.GetOk("db_node_set"); ok { + for _, item := range v.([]interface{}) { + dBNodeSetMap := item.(map[string]interface{}) + dBNode := postgresv20170312.DBNode{} + if v, ok := dBNodeSetMap["role"]; ok { + dBNode.Role = helper.String(v.(string)) + } + if v, ok := dBNodeSetMap["zone"]; ok { + dBNode.Zone = helper.String(v.(string)) + } + request.DBNodeSet = append(request.DBNodeSet, &dBNode) + } + } + + if v, ok := d.GetOkExists("activity_id"); ok { + request.ActivityId = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOk("backup_set_id"); ok { + request.BackupSetId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("recovery_target_time"); ok { + request.RecoveryTargetTime = helper.String(v.(string)) + } + + if v, ok := d.GetOk("sync_mode"); ok { + request.SyncMode = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePostgresV20170312Client().CloneDBInstanceWithContext(ctx, request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create postgresql clone db instance failed, reason:%+v", logId, err) + return err + } + + dBInstanceId = *response.Response.DBInstanceId + + if _, err := (&resource.StateChangeConf{ + Delay: 10 * time.Second, + MinTimeout: 3 * time.Second, + Pending: []string{}, + Refresh: resourcePostgresqlCloneDbInstanceCreateStateRefreshFunc_0_0(ctx, dBInstanceId), + Target: []string{"running"}, + Timeout: 1800 * time.Second, + }).WaitForStateContext(ctx); err != nil { + return err + } + d.SetId(dBInstanceId) + + return resourceTencentCloudPostgresqlCloneDbInstanceRead(d, meta) +} + +func resourceTencentCloudPostgresqlCloneDbInstanceRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_postgresql_clone_db_instance.read")() + defer tccommon.InconsistentCheck(d, meta)() + + return nil +} + +func resourceTencentCloudPostgresqlCloneDbInstanceDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_postgresql_clone_db_instance.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + return nil +} + +func resourcePostgresqlCloneDbInstanceCreateStateRefreshFunc_0_0(ctx context.Context, dBInstanceId string) resource.StateRefreshFunc { + var req *postgresv20170312.DescribeDBInstanceAttributeRequest + return func() (interface{}, string, error) { + meta := tccommon.ProviderMetaFromContext(ctx) + if meta == nil { + return nil, "", fmt.Errorf("resource data can not be nil") + } + if req == nil { + d := tccommon.ResourceDataFromContext(ctx) + if d == nil { + return nil, "", fmt.Errorf("resource data can not be nil") + } + _ = d + req = postgresv20170312.NewDescribeDBInstanceAttributeRequest() + req.DBInstanceId = helper.String(dBInstanceId) + + } + resp, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePostgresV20170312Client().DescribeDBInstanceAttributeWithContext(ctx, req) + if err != nil { + return nil, "", err + } + if resp == nil || resp.Response == nil { + return nil, "", nil + } + state := fmt.Sprintf("%v", *resp.Response.DBInstance.DBInstanceStatus) + return resp.Response, state, nil + } +} diff --git a/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance.md b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance.md new file mode 100644 index 0000000000..aba33d49e6 --- /dev/null +++ b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance.md @@ -0,0 +1,79 @@ +Provides a resource to create a postgresql clone db instance + +Example Usage + +Clone db instance by `recovery_target_time` + +```hcl +resource "tencentcloud_postgresql_clone_db_instance" "example" { + db_instance_id = "postgres-evsqpyap" + name = "tf-example-clone" + spec_code = "pg.it.medium4" + storage = 200 + period = 1 + auto_renew_flag = 0 + vpc_id = "vpc-a6zec4mf" + subnet_id = "subnet-b8hintyy" + instance_charge_type = "POSTPAID_BY_HOUR" + security_group_ids = ["sg-8stavs03"] + project_id = 0 + recovery_target_time = "2024-10-12 18:17:00" + db_node_set { + role = "Primary" + zone = "ap-guangzhou-6" + } + + db_node_set { + role = "Standby" + zone = "ap-guangzhou-6" + } + + tag_list { + tag_key = "createBy" + tag_value = "terraform" + } +} +``` + +Clone db instance by `backup_set_id` + +```hcl +data "tencentcloud_postgresql_base_backups" "base_backups" { + filters { + name = "db-instance-id" + values = ["postgres-evsqpyap"] + } + + order_by = "Size" + order_by_type = "asc" +} + +resource "tencentcloud_postgresql_clone_db_instance" "example" { + db_instance_id = "postgres-evsqpyap" + name = "tf-example-clone" + spec_code = "pg.it.medium4" + storage = 200 + period = 1 + auto_renew_flag = 0 + vpc_id = "vpc-a6zec4mf" + subnet_id = "subnet-b8hintyy" + instance_charge_type = "POSTPAID_BY_HOUR" + security_group_ids = ["sg-8stavs03"] + project_id = 0 + backup_set_id = data.tencentcloud_postgresql_base_backups.base_backups.base_backup_set.0.id + db_node_set { + role = "Primary" + zone = "ap-guangzhou-6" + } + + db_node_set { + role = "Standby" + zone = "ap-guangzhou-6" + } + + tag_list { + tag_key = "createBy" + tag_value = "terraform" + } +} +``` diff --git a/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance_extension.go b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance_extension.go new file mode 100644 index 0000000000..4e9a54a3ce --- /dev/null +++ b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance_extension.go @@ -0,0 +1 @@ +package postgresql diff --git a/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance_test.go b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance_test.go new file mode 100644 index 0000000000..f0c18282a0 --- /dev/null +++ b/tencentcloud/services/postgresql/resource_tc_postgresql_clone_db_instance_test.go @@ -0,0 +1,56 @@ +package postgresql_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudNeedFixPostgresqlCloneDbInstanceResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccPostgresqlCloneDbInstance, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_postgresql_clone_db_instance.postgresql_clone_db_instance", "id")), + }, + }, + }) +} + +const testAccPostgresqlCloneDbInstance = ` +resource "tencentcloud_postgresql_clone_db_instance" "example" { + db_instance_id = "postgres-evsqpyap" + name = "tf-example-clone" + spec_code = "pg.it.medium4" + storage = 200 + period = 1 + auto_renew_flag = 0 + vpc_id = "vpc-a6zec4mf" + subnet_id = "subnet-b8hintyy" + instance_charge_type = "POSTPAID_BY_HOUR" + security_group_ids = ["sg-8stavs03"] + project_id = 0 + recovery_target_time = "2024-10-12 18:17:00" + db_node_set { + role = "Primary" + zone = "ap-guangzhou-6" + } + + db_node_set { + role = "Standby" + zone = "ap-guangzhou-6" + } + + tag_list { + tag_key = "createBy" + tag_value = "terraform" + } +} +` diff --git a/website/docs/r/postgresql_clone_db_instance.html.markdown b/website/docs/r/postgresql_clone_db_instance.html.markdown new file mode 100644 index 0000000000..22edfeaae8 --- /dev/null +++ b/website/docs/r/postgresql_clone_db_instance.html.markdown @@ -0,0 +1,148 @@ +--- +subcategory: "TencentDB for PostgreSQL(PostgreSQL)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_postgresql_clone_db_instance" +sidebar_current: "docs-tencentcloud-resource-postgresql_clone_db_instance" +description: |- + Provides a resource to create a postgresql clone db instance +--- + +# tencentcloud_postgresql_clone_db_instance + +Provides a resource to create a postgresql clone db instance + +## Example Usage + +```hcl +resource "tencentcloud_postgresql_clone_db_instance" "example" { + db_instance_id = "postgres-evsqpyap" + name = "tf-example-clone" + spec_code = "pg.it.medium4" + storage = 200 + period = 1 + auto_renew_flag = 0 + vpc_id = "vpc-a6zec4mf" + subnet_id = "subnet-b8hintyy" + instance_charge_type = "POSTPAID_BY_HOUR" + security_group_ids = ["sg-8stavs03"] + project_id = 0 + recovery_target_time = "2024-10-12 18:17:00" + db_node_set { + role = "Primary" + zone = "ap-guangzhou-6" + } + + db_node_set { + role = "Standby" + zone = "ap-guangzhou-6" + } + + tag_list { + tag_key = "createBy" + tag_value = "terraform" + } +} +``` + + + +```hcl +data "tencentcloud_postgresql_base_backups" "base_backups" { + filters { + name = "db-instance-id" + values = ["postgres-evsqpyap"] + } + + order_by = "Size" + order_by_type = "asc" +} + +resource "tencentcloud_postgresql_clone_db_instance" "example" { + db_instance_id = "postgres-evsqpyap" + name = "tf-example-clone" + spec_code = "pg.it.medium4" + storage = 200 + period = 1 + auto_renew_flag = 0 + vpc_id = "vpc-a6zec4mf" + subnet_id = "subnet-b8hintyy" + instance_charge_type = "POSTPAID_BY_HOUR" + security_group_ids = ["sg-8stavs03"] + project_id = 0 + backup_set_id = data.tencentcloud_postgresql_base_backups.base_backups.base_backup_set.0.id + db_node_set { + role = "Primary" + zone = "ap-guangzhou-6" + } + + db_node_set { + role = "Standby" + zone = "ap-guangzhou-6" + } + + tag_list { + tag_key = "createBy" + tag_value = "terraform" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `auto_renew_flag` - (Required, Int, ForceNew) Renewal Flag: + +- `0`: manual renewal +`1`: auto-renewal + +Default value: 0. +* `db_instance_id` - (Required, String, ForceNew) ID of the original instance to be cloned. +* `period` - (Required, Int, ForceNew) Purchase duration, in months. +- Prepaid: Supports `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, and `36`. +- Pay-as-you-go: Only supports `1`. +* `spec_code` - (Required, String, ForceNew) Purchasable code, which can be obtained from the `SpecCode` field in the return value of the [DescribeClasses](https://intl.cloud.tencent.com/document/api/409/89019?from_cn_redirect=1) API. +* `storage` - (Required, Int, ForceNew) Instance storage capacity in GB. +* `subnet_id` - (Required, String, ForceNew) VPC subnet ID in the format of `subnet-xxxxxxxx`, which can be obtained in the console or from the `unSubnetId` field in the return value of the [DescribeSubnets](https://intl.cloud.tencent.com/document/api/215/15784?from_cn_redirect=1) API. +* `vpc_id` - (Required, String, ForceNew) VPC ID in the format of `vpc-xxxxxxx`, which can be obtained in the console or from the `unVpcId` field in the return value of the [DescribeVpcEx](https://intl.cloud.tencent.com/document/api/215/1372?from_cn_redirect=1) API. +* `activity_id` - (Optional, Int, ForceNew) Campaign ID. +* `backup_set_id` - (Optional, String, ForceNew) Basic backup set ID. +* `db_node_set` - (Optional, List, ForceNew) Deployment information of the instance node, which will display the information of each AZ when the instance node is deployed across multiple AZs. +The information of AZ can be obtained from the `Zone` field in the return value of the [DescribeZones](https://intl.cloud.tencent.com/document/api/409/16769?from_cn_redirect=1) API. +* `instance_charge_type` - (Optional, String, ForceNew) Instance billing type, which currently supports: + +- PREPAID: Prepaid, i.e., monthly subscription +- POSTPAID_BY_HOUR: Pay-as-you-go, i.e., pay by consumption + +Default value: PREPAID. +* `name` - (Optional, String, ForceNew) Name of the newly purchased instance, which can contain up to 60 letters, digits, or symbols (-_). If this parameter is not specified, "Unnamed" will be displayed by default. +* `project_id` - (Optional, Int, ForceNew) Project ID. +* `recovery_target_time` - (Optional, String, ForceNew) Restoration point in time. +* `security_group_ids` - (Optional, Set: [`String`], ForceNew) Security group of the instance, which can be obtained from the `sgld` field in the return value of the [DescribeSecurityGroups](https://intl.cloud.tencent.com/document/api/215/15808?from_cn_redirect=1) API. If this parameter is not specified, the default security group will be bound. +* `sync_mode` - (Optional, String, ForceNew) Primary-standby sync mode, which supports: +Semi-sync: Semi-sync +Async: Asynchronous +Default value for the primary instance: Semi-sync +Default value for the read-only instance: Async. +* `tag_list` - (Optional, List, ForceNew) The information of tags to be bound with the instance, which is left empty by default. This parameter can be obtained from the `Tags` field in the return value of the [DescribeTags](https://intl.cloud.tencent.com/document/api/651/35316?from_cn_redirect=1) API. + +The `db_node_set` object supports the following: + +* `role` - (Required, String) Node type. Valid values: +`Primary`; +`Standby`. +* `zone` - (Required, String) AZ where the node resides, such as ap-guangzhou-1. + +The `tag_list` object supports the following: + +* `tag_key` - (Required, String) Tag key. +* `tag_value` - (Required, String) Tag value. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index 8cbe2a43a8..e0efa6a00b 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -5858,6 +5858,9 @@