From 4b7ad9a6b4cadad0c55371ce601498cb0bdb3419 Mon Sep 17 00:00:00 2001 From: nickyinluo Date: Wed, 5 Jul 2023 16:30:37 +0800 Subject: [PATCH 1/4] example readjust: tencentcloud_kubernetes_serverless_node_pool --- ...urce_tc_kubernetes_serverless_node_pool.go | 99 +++++++++++++++++-- ...ernetes_serverless_node_pool.html.markdown | 96 ++++++++++++++++-- 2 files changed, 176 insertions(+), 19 deletions(-) diff --git a/tencentcloud/resource_tc_kubernetes_serverless_node_pool.go b/tencentcloud/resource_tc_kubernetes_serverless_node_pool.go index ec4c145933..87da7059fb 100644 --- a/tencentcloud/resource_tc_kubernetes_serverless_node_pool.go +++ b/tencentcloud/resource_tc_kubernetes_serverless_node_pool.go @@ -2,22 +2,101 @@ Provide a resource to create serverless node pool of cluster. Example Usage + +Add serverless node pool to a cluster + +```hcl +variable "availability_zone" { + default = "ap-guangzhou-3" +} + +variable "example_cluster_cidr" { + default = "10.31.0.0/16" +} + +locals { + vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id + subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id + sg_id = data.tencentcloud_security_groups.sg.security_groups.0.security_group_id +} + +data "tencentcloud_vpc_subnets" "vpc" { + is_default = true + availability_zone = var.availability_zone +} + +data "tencentcloud_security_groups" "sg" { + name = "default" +} + +resource "tencentcloud_kubernetes_cluster" "example" { + vpc_id = local.vpc_id + cluster_cidr = var.example_cluster_cidr + cluster_max_pod_num = 32 + cluster_name = "tf_example_cluster" + cluster_desc = "tf example cluster" + cluster_max_service_num = 32 + cluster_version = "1.18.4" + cluster_deploy_type = "MANAGED_CLUSTER" +} + +resource "tencentcloud_kubernetes_serverless_node_pool" "example" { + cluster_id = tencentcloud_kubernetes_cluster.example.id + name = "tf_example_serverless_node_pool" + + serverless_nodes { + display_name = "tf_example_serverless_node1" + subnet_id = local.subnet_id + } + + serverless_nodes { + display_name = "tf_example_serverless_node2" + subnet_id = local.subnet_id + } + + security_group_ids = [local.sg_id] + labels = { + "label1" : "value1", + "label2" : "value2", + } +} ``` -resource "tencentcloud_kubernetes_serverless_node_pool" "example_serverless_node_pool" { + +Adding taints to the virtual nodes under this node pool + +The pods without appropriate tolerations will not be scheduled on this node. Refer [taint-and-toleration](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) for more details. + +```hcl +resource "tencentcloud_kubernetes_serverless_node_pool" "example" { cluster_id = tencentcloud_kubernetes_cluster.example.id - name = "example_node_pool" + name = "tf_example_serverless_node_pool" + serverless_nodes { - display_name = "serverless_node1" - subnet_id = "subnet-xxx" + display_name = "tf_example_serverless_node1" + subnet_id = local.subnet_id } + serverless_nodes { - display_name = "serverless_node2" - subnet_id = "subnet-xxx" + display_name = "tf_example_serverless_node2" + subnet_id = local.subnet_id + } + + security_group_ids = [local.sg_id] + labels = { + "label1" : "value1", + "label2" : "value2", + } + + taints{ + key = "key1" + value = "value1" + effect = "NoSchedule" } - security_group_ids = ["sg-xxx"] - labels = { - "example1" : "test1", - "example2" : "test2", + + taints{ + key = "key1" + value = "value1" + effect = "NoExecute" } } ``` diff --git a/website/docs/r/kubernetes_serverless_node_pool.html.markdown b/website/docs/r/kubernetes_serverless_node_pool.html.markdown index 100c16c96a..a45cfa0ef8 100644 --- a/website/docs/r/kubernetes_serverless_node_pool.html.markdown +++ b/website/docs/r/kubernetes_serverless_node_pool.html.markdown @@ -13,22 +13,100 @@ Provide a resource to create serverless node pool of cluster. ## Example Usage +### Add serverless node pool to a cluster + +```hcl +variable "availability_zone" { + default = "ap-guangzhou-3" +} + +variable "example_cluster_cidr" { + default = "10.31.0.0/16" +} + +locals { + vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id + subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id + sg_id = data.tencentcloud_security_groups.sg.security_groups.0.security_group_id +} + +data "tencentcloud_vpc_subnets" "vpc" { + is_default = true + availability_zone = var.availability_zone +} + +data "tencentcloud_security_groups" "sg" { + name = "default" +} + +resource "tencentcloud_kubernetes_cluster" "example" { + vpc_id = local.vpc_id + cluster_cidr = var.example_cluster_cidr + cluster_max_pod_num = 32 + cluster_name = "tf_example_cluster" + cluster_desc = "tf example cluster" + cluster_max_service_num = 32 + cluster_version = "1.18.4" + cluster_deploy_type = "MANAGED_CLUSTER" +} + +resource "tencentcloud_kubernetes_serverless_node_pool" "example" { + cluster_id = tencentcloud_kubernetes_cluster.example.id + name = "tf_example_serverless_node_pool" + + serverless_nodes { + display_name = "tf_example_serverless_node1" + subnet_id = local.subnet_id + } + + serverless_nodes { + display_name = "tf_example_serverless_node2" + subnet_id = local.subnet_id + } + + security_group_ids = [local.sg_id] + labels = { + "label1" : "value1", + "label2" : "value2", + } +} +``` + +### Adding taints to the virtual nodes under this node pool + +The pods without appropriate tolerations will not be scheduled on this node. Refer [taint-and-toleration](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) for more details. + ```hcl -resource "tencentcloud_kubernetes_serverless_node_pool" "example_serverless_node_pool" { +resource "tencentcloud_kubernetes_serverless_node_pool" "example" { cluster_id = tencentcloud_kubernetes_cluster.example.id - name = "example_node_pool" + name = "tf_example_serverless_node_pool" + serverless_nodes { - display_name = "serverless_node1" - subnet_id = "subnet-xxx" + display_name = "tf_example_serverless_node1" + subnet_id = local.subnet_id } + serverless_nodes { - display_name = "serverless_node2" - subnet_id = "subnet-xxx" + display_name = "tf_example_serverless_node2" + subnet_id = local.subnet_id } - security_group_ids = ["sg-xxx"] + + security_group_ids = [local.sg_id] labels = { - "example1" : "test1", - "example2" : "test2", + "label1" : "value1", + "label2" : "value2", + } + + taints { + key = "key1" + value = "value1" + effect = "NoSchedule" + } + + taints { + key = "key1" + value = "value1" + effect = "NoExecute" } } ``` From 9fd5fddf9e5f2793d8f3e971a628ba1c6ac5ccf2 Mon Sep 17 00:00:00 2001 From: nickyinluo Date: Tue, 11 Jul 2023 15:43:34 +0800 Subject: [PATCH 2/4] add pre-commit-local --- .githooks/pre-commit-local | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 .githooks/pre-commit-local diff --git a/.githooks/pre-commit-local b/.githooks/pre-commit-local new file mode 100755 index 0000000000..dca120dc69 --- /dev/null +++ b/.githooks/pre-commit-local @@ -0,0 +1,28 @@ +#!/bin/sh +REQUIRED_GO_VERSION="1.18" # use the .go-version later + +printf "==> Step 1: Gofmt Check...\n" +make fmt-faster +if [ $? -ne 0 ]; then + printf "COMMIT FAILED\n" + exit 1 +fi + +printf "==> Step 2: Generating docs...\n" +doc=$(make doc 2>&1) +if [ $? -ne 0 ]; then + echo "$doc" | tail -n 4 | head -n 2 + printf "COMMIT FAILED\n" + exit 1 +fi + +printf "==> Step 2: Generating docs...\n" +go_version=$(go version | awk '{print $3}') +if [ $go_version -ne $REQUIRED_GO_VERSION* ]; then + echo "Go version is not compatible. Expected $REQUIRED_GO_VERSION.x" + printf "COMMIT FAILED\n" + exit 1 +fi + +printf "COMMIT READY\n" +exit 0 From a4cfd300e2255dc03f3e967f72dc8e00a43b94a4 Mon Sep 17 00:00:00 2001 From: nickyinluo Date: Mon, 17 Jul 2023 18:53:24 +0800 Subject: [PATCH 3/4] adjust e2e case --- ...tc_postgresql_backup_download_urls_test.go | 10 ++- ..._tc_postgresql_db_instance_classes_test.go | 4 + ...tc_postgresql_db_instance_versions_test.go | 5 ++ ...e_tc_postgresql_default_parameters_test.go | 5 ++ ...ata_source_tc_postgresql_instances_test.go | 9 ++- .../data_source_tc_postgresql_log_backups.go | 2 +- ...a_source_tc_postgresql_log_backups_test.go | 5 ++ ..._tc_postgresql_parameter_templates_test.go | 5 ++ ...urce_tc_postgresql_readonly_groups_test.go | 1 + ...source_tc_postgresql_recovery_time_test.go | 5 ++ .../data_source_tc_postgresql_regions_test.go | 5 ++ ...ata_source_tc_postgresql_specinfos_test.go | 5 ++ .../data_source_tc_postgresql_xlogs_test.go | 9 ++- .../data_source_tc_postgresql_zones_test.go | 5 ++ ...backup_download_restriction_config_test.go | 19 +++++ ...e_tc_postgresql_backup_plan_config_test.go | 5 ++ ...resql_common_db_instance_operation_test.go | 38 +++++++--- ...gresql_delete_log_backup_operation_test.go | 5 ++ .../resource_tc_postgresql_instance_test.go | 73 ++++++++++++++----- ...ql_modify_account_remark_operation_test.go | 5 ++ ...odify_switch_time_period_operation_test.go | 5 ++ ...e_tc_postgresql_parameter_template_test.go | 17 +++++ ...ource_tc_postgresql_readonly_group_test.go | 19 +++-- ...ce_tc_postgresql_readonly_instance_test.go | 38 +++++++--- ...rebalance_readonly_group_operation_test.go | 5 ++ ...c_postgresql_security_group_config_test.go | 10 +++ 26 files changed, 263 insertions(+), 51 deletions(-) diff --git a/tencentcloud/data_source_tc_postgresql_backup_download_urls_test.go b/tencentcloud/data_source_tc_postgresql_backup_download_urls_test.go index 272a74c60b..be140acbcb 100644 --- a/tencentcloud/data_source_tc_postgresql_backup_download_urls_test.go +++ b/tencentcloud/data_source_tc_postgresql_backup_download_urls_test.go @@ -19,6 +19,10 @@ func TestAccTencentCloudPostgresqlBackupDownloadUrlsDataSource_basic(t *testing. Providers: testAccProviders, Steps: []resource.TestStep{ { + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, // Config: fmt.Sprintf(testAccPostgresqlBackupDownloadUrlsDataSource, startTime, endTime), Config: testAccPostgresqlBackupDownloadUrlsDataSource, Check: resource.ComposeTestCheckFunc( @@ -40,7 +44,7 @@ func TestAccTencentCloudPostgresqlBackupDownloadUrlsDataSource_basic(t *testing. }) } -const testAccPostgresqlBackupDownloadUrlsDataSource = CommonPresetPGSQL + defaultVpcSubnets + ` +const testAccPostgresqlBackupDownloadUrlsDataSource = OperationPresetPGSQL + defaultVpcSubnets + ` data "tencentcloud_postgresql_log_backups" "log_backups" { min_finish_time = "" max_finish_time = "" @@ -55,8 +59,8 @@ data "tencentcloud_postgresql_log_backups" "log_backups" { data "tencentcloud_postgresql_backup_download_urls" "backup_download_urls" { db_instance_id = local.pgsql_id backup_type = "LogBackup" -// backup_id = data.tencentcloud_postgresql_log_backups.log_backups.log_backup_set.0.id - backup_id = "01a57d08-b7f5-584e-b64a-dc2236bb0438" + backup_id = data.tencentcloud_postgresql_log_backups.log_backups.log_backup_set.0.id +// backup_id = "01a57d08-b7f5-584e-b64a-dc2236bb0438" url_expire_time = 12 backup_download_restriction { restriction_type = "NONE" diff --git a/tencentcloud/data_source_tc_postgresql_db_instance_classes_test.go b/tencentcloud/data_source_tc_postgresql_db_instance_classes_test.go index c7302ee854..9f16a89429 100644 --- a/tencentcloud/data_source_tc_postgresql_db_instance_classes_test.go +++ b/tencentcloud/data_source_tc_postgresql_db_instance_classes_test.go @@ -16,6 +16,10 @@ func TestAccTencentCloudPostgresqlDbInstanceClassesDataSource_basic(t *testing.T Steps: []resource.TestStep{ { Config: testAccPostgresqlDbInstanceClassesDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_db_instance_classes.db_instance_classes"), resource.TestCheckResourceAttr("data.tencentcloud_postgresql_db_instance_classes.db_instance_classes", "zone", "ap-guangzhou-7"), diff --git a/tencentcloud/data_source_tc_postgresql_db_instance_versions_test.go b/tencentcloud/data_source_tc_postgresql_db_instance_versions_test.go index 5abc9e24b3..575a5c6761 100644 --- a/tencentcloud/data_source_tc_postgresql_db_instance_versions_test.go +++ b/tencentcloud/data_source_tc_postgresql_db_instance_versions_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlDbInstanceVersionsDataSource_basic(t *testing. t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlDbInstanceVersionsDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_db_instance_versions.db_instance_versions"), resource.TestCheckResourceAttrSet("data.tencentcloud_postgresql_db_instance_versions.db_instance_versions", "version_set.#"), diff --git a/tencentcloud/data_source_tc_postgresql_default_parameters_test.go b/tencentcloud/data_source_tc_postgresql_default_parameters_test.go index 09f33d71cd..8c88fe87a3 100644 --- a/tencentcloud/data_source_tc_postgresql_default_parameters_test.go +++ b/tencentcloud/data_source_tc_postgresql_default_parameters_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlDefaultParametersDataSource_basic(t *testing.T t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlDefaultParametersDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_default_parameters.default_parameters"), resource.TestCheckResourceAttr("data.tencentcloud_postgresql_default_parameters.default_parameters", "db_major_version", "13"), diff --git a/tencentcloud/data_source_tc_postgresql_instances_test.go b/tencentcloud/data_source_tc_postgresql_instances_test.go index 6d2e282803..4c72c5fd38 100644 --- a/tencentcloud/data_source_tc_postgresql_instances_test.go +++ b/tencentcloud/data_source_tc_postgresql_instances_test.go @@ -11,12 +11,19 @@ var testDataPostgresqlInstancesName = "data.tencentcloud_postgresql_instances.id func TestAccTencentCloudPostgresqlInstancesDataSource(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, CheckDestroy: testAccCheckLBDestroy, Steps: []resource.TestStep{ { Config: testAccTencentCloudDataPostgresqlInstanceBasic, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(testDataPostgresqlInstancesName, "instance_list.#", "1"), resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.id"), diff --git a/tencentcloud/data_source_tc_postgresql_log_backups.go b/tencentcloud/data_source_tc_postgresql_log_backups.go index 7ad2082139..7af65634e4 100644 --- a/tencentcloud/data_source_tc_postgresql_log_backups.go +++ b/tencentcloud/data_source_tc_postgresql_log_backups.go @@ -181,7 +181,7 @@ func dataSourceTencentCloudPostgresqlLogBackupsRead(d *schema.ResourceData, meta } tmpSet = append(tmpSet, &filter) } - paramMap["filters"] = tmpSet + paramMap["Filters"] = tmpSet } if v, ok := d.GetOk("order_by"); ok { diff --git a/tencentcloud/data_source_tc_postgresql_log_backups_test.go b/tencentcloud/data_source_tc_postgresql_log_backups_test.go index be88f37d76..28bfdde794 100644 --- a/tencentcloud/data_source_tc_postgresql_log_backups_test.go +++ b/tencentcloud/data_source_tc_postgresql_log_backups_test.go @@ -15,12 +15,17 @@ func TestAccTencentCloudPostgresqlLogBackupsDataSource_basic(t *testing.T) { endTime := time.Now().AddDate(0, 0, 1).In(loc).Format("2006-01-02 15:04:05") resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: fmt.Sprintf(testAccPostgresqlLogBackupsDataSource, startTime, endTime), + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_log_backups.log_backups"), resource.TestCheckResourceAttr("data.tencentcloud_postgresql_log_backups.log_backups", "min_finish_time", startTime), diff --git a/tencentcloud/data_source_tc_postgresql_parameter_templates_test.go b/tencentcloud/data_source_tc_postgresql_parameter_templates_test.go index 75b5851b39..bf35663dd3 100644 --- a/tencentcloud/data_source_tc_postgresql_parameter_templates_test.go +++ b/tencentcloud/data_source_tc_postgresql_parameter_templates_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlParameterTemplatesDataSource_basic(t *testing. t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlParameterTemplatesDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_parameter_templates.parameter_templates"), resource.TestCheckResourceAttr("data.tencentcloud_postgresql_parameter_templates.parameter_templates", "filters.#", "2"), diff --git a/tencentcloud/data_source_tc_postgresql_readonly_groups_test.go b/tencentcloud/data_source_tc_postgresql_readonly_groups_test.go index 8e38df066f..69839caefa 100644 --- a/tencentcloud/data_source_tc_postgresql_readonly_groups_test.go +++ b/tencentcloud/data_source_tc_postgresql_readonly_groups_test.go @@ -12,6 +12,7 @@ func TestAccTencentCloudPostgresqlReadonlyGroupsDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, diff --git a/tencentcloud/data_source_tc_postgresql_recovery_time_test.go b/tencentcloud/data_source_tc_postgresql_recovery_time_test.go index 3e92fb472f..fdac6e7175 100644 --- a/tencentcloud/data_source_tc_postgresql_recovery_time_test.go +++ b/tencentcloud/data_source_tc_postgresql_recovery_time_test.go @@ -12,12 +12,17 @@ func TestAccTencentCloudPostgresqlRecoveryTimeDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlRecoveryTimeDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID(testAccPostgresqlrecoverytimeObject), resource.TestCheckResourceAttrSet(testAccPostgresqlrecoverytimeObject, "db_instance_id"), diff --git a/tencentcloud/data_source_tc_postgresql_regions_test.go b/tencentcloud/data_source_tc_postgresql_regions_test.go index 9ea80e9058..acc84de856 100644 --- a/tencentcloud/data_source_tc_postgresql_regions_test.go +++ b/tencentcloud/data_source_tc_postgresql_regions_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlRegionsDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlRegionsDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_regions.regions"), resource.TestCheckResourceAttrSet("data.tencentcloud_postgresql_regions.regions", "region_set.#"), diff --git a/tencentcloud/data_source_tc_postgresql_specinfos_test.go b/tencentcloud/data_source_tc_postgresql_specinfos_test.go index eb9788d916..99ca796876 100644 --- a/tencentcloud/data_source_tc_postgresql_specinfos_test.go +++ b/tencentcloud/data_source_tc_postgresql_specinfos_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlSpecinfosDataSource(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccTencentCloudPostgresqlSpecinfosConfigBasic, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_specinfos.foo"), resource.TestCheckResourceAttrSet("data.tencentcloud_postgresql_specinfos.foo", "list.#"), diff --git a/tencentcloud/data_source_tc_postgresql_xlogs_test.go b/tencentcloud/data_source_tc_postgresql_xlogs_test.go index ae103a8c90..9376b4c593 100644 --- a/tencentcloud/data_source_tc_postgresql_xlogs_test.go +++ b/tencentcloud/data_source_tc_postgresql_xlogs_test.go @@ -14,11 +14,18 @@ func TestAccTencentCloudPostgresqlXlogsDataSource(t *testing.T) { startTime := time.Now().AddDate(0, 0, -7).Format("2006-01-02 15:04:05") endTime := time.Now().Format("2006-01-02 15:04:05") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccDataSourcePostgresqlXlogsBasic(startTime, endTime), + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.tencentcloud_postgresql_xlogs.foo", "start_time", startTime), resource.TestCheckResourceAttr("data.tencentcloud_postgresql_xlogs.foo", "end_time", endTime), diff --git a/tencentcloud/data_source_tc_postgresql_zones_test.go b/tencentcloud/data_source_tc_postgresql_zones_test.go index 62141efc95..6808f0b08a 100644 --- a/tencentcloud/data_source_tc_postgresql_zones_test.go +++ b/tencentcloud/data_source_tc_postgresql_zones_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlZonesDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlZonesDataSource, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckTencentCloudDataSourceID("data.tencentcloud_postgresql_zones.zones"), resource.TestCheckResourceAttrSet("data.tencentcloud_postgresql_zones.zones", "zone_set.#"), diff --git a/tencentcloud/resource_tc_postgresql_backup_download_restriction_config_test.go b/tencentcloud/resource_tc_postgresql_backup_download_restriction_config_test.go index 3ac84bfa77..19fe41a6d6 100644 --- a/tencentcloud/resource_tc_postgresql_backup_download_restriction_config_test.go +++ b/tencentcloud/resource_tc_postgresql_backup_download_restriction_config_test.go @@ -11,12 +11,17 @@ const TestAccPostgresqlBackupDownloadRestrictionObject = "tencentcloud_postgresq func TestAccTencentCloudPostgresqlBackupDownloadRestrictionConfigResource_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlBackupDownloadRestrictionConfig_NONE, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestAccPostgresqlBackupDownloadRestrictionObject, "id"), resource.TestCheckResourceAttr(TestAccPostgresqlBackupDownloadRestrictionObject, "restriction_type", "NONE"), @@ -34,12 +39,17 @@ func TestAccTencentCloudPostgresqlBackupDownloadRestrictionConfigResource_basic( func TestAccTencentCloudPostgresqlBackupDownloadRestrictionConfigResource_CUSTOMIZE(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlBackupDownloadRestrictionConfig_CUSTOMIZE_ALLOW, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestAccPostgresqlBackupDownloadRestrictionObject, "id"), resource.TestCheckResourceAttr(TestAccPostgresqlBackupDownloadRestrictionObject, "restriction_type", "CUSTOMIZE"), @@ -51,6 +61,10 @@ func TestAccTencentCloudPostgresqlBackupDownloadRestrictionConfigResource_CUSTOM }, { Config: testAccPostgresqlBackupDownloadRestrictionConfig_CUSTOMIZE_DENY, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestAccPostgresqlBackupDownloadRestrictionObject, "id"), resource.TestCheckResourceAttr(TestAccPostgresqlBackupDownloadRestrictionObject, "restriction_type", "CUSTOMIZE"), @@ -72,12 +86,17 @@ func TestAccTencentCloudPostgresqlBackupDownloadRestrictionConfigResource_CUSTOM func TestAccTencentCloudPostgresqlBackupDownloadRestrictionConfigResource_INTRANET(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlBackupDownloadRestrictionConfig_INTRANET, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestAccPostgresqlBackupDownloadRestrictionObject, "id"), resource.TestCheckResourceAttr(TestAccPostgresqlBackupDownloadRestrictionObject, "restriction_type", "INTRANET"), diff --git a/tencentcloud/resource_tc_postgresql_backup_plan_config_test.go b/tencentcloud/resource_tc_postgresql_backup_plan_config_test.go index 7d2b5f72ed..cecfa90c1a 100644 --- a/tencentcloud/resource_tc_postgresql_backup_plan_config_test.go +++ b/tencentcloud/resource_tc_postgresql_backup_plan_config_test.go @@ -12,12 +12,17 @@ func TestAccTencentCloudPostgresqlBackupPlanConfigResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresBackupPlanConfig, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testAccPostgresqlBackupPlanConfigObject, "id"), resource.TestCheckResourceAttrSet(testAccPostgresqlBackupPlanConfigObject, "db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_common_db_instance_operation_test.go b/tencentcloud/resource_tc_postgresql_common_db_instance_operation_test.go index abb049db17..a1ce80c9b6 100644 --- a/tencentcloud/resource_tc_postgresql_common_db_instance_operation_test.go +++ b/tencentcloud/resource_tc_postgresql_common_db_instance_operation_test.go @@ -14,28 +14,40 @@ const testAccPostgresqlInstanceOperation_restart = "tencentcloud_postgresql_rest func TestAccTencentCloudPostgresqlCommonDbInstanceOperationResource_all(t *testing.T) { // t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccPostgresqlCommonDbInstanceOperation_restart, - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, + Config: testAccPostgresqlCommonDbInstanceOperation_restart, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testAccPostgresqlInstanceOperation_restart, "id"), resource.TestCheckResourceAttrSet(testAccPostgresqlInstanceOperation_restart, "db_instance_id"), ), }, { - Config: testAccPostgresqlCommonDbInstanceOperation_isolate, - PreConfig: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) }, + Config: testAccPostgresqlCommonDbInstanceOperation_isolate, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testAccPostgresqlInstanceOperation_isolate, "id"), resource.TestCheckResourceAttr(testAccPostgresqlInstanceOperation_isolate, "db_instance_id_set.#", "1"), ), }, { - Config: testAccPostgresqlCommonDbInstanceOperation_disisolate, - PreConfig: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) }, + Config: testAccPostgresqlCommonDbInstanceOperation_disisolate, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testAccPostgresqlInstanceOperation_disisolate, "id"), resource.TestCheckResourceAttr(testAccPostgresqlInstanceOperation_disisolate, "db_instance_id_set.#", "1"), @@ -50,12 +62,18 @@ func TestAccTencentCloudPostgresqlCommonDbInstanceOperationResource_all(t *testi func TestAccTencentCloudPostgresqlCommonDbInstanceOperationResource_renew(t *testing.T) { // t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccPostgresqlCommonDbInstanceOperation_renew, - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) }, + Config: testAccPostgresqlCommonDbInstanceOperation_renew, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testAccPostgresqlInstanceOperation_renew, "id"), resource.TestCheckResourceAttrSet(testAccPostgresqlInstanceOperation_renew, "db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_delete_log_backup_operation_test.go b/tencentcloud/resource_tc_postgresql_delete_log_backup_operation_test.go index 96195f9519..2eac183ff1 100644 --- a/tencentcloud/resource_tc_postgresql_delete_log_backup_operation_test.go +++ b/tencentcloud/resource_tc_postgresql_delete_log_backup_operation_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudNeedFixPostgresqlDeleteLogBackupOperationResource_basic( t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlDeleteLogBackupOperation, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("tencentcloud_postgresql_delete_log_backup_operation.delete_log_backup_operation", "id"), resource.TestCheckResourceAttrSet("tencentcloud_postgresql_delete_log_backup_operation.delete_log_backup_operation", "db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_instance_test.go b/tencentcloud/resource_tc_postgresql_instance_test.go index aa1cd75ca4..19ef5c0ae5 100644 --- a/tencentcloud/resource_tc_postgresql_instance_test.go +++ b/tencentcloud/resource_tc_postgresql_instance_test.go @@ -91,13 +91,19 @@ func init() { func TestAccTencentCloudPostgresqlInstanceResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + testAccStepSetRegion(t, "ap-guangzhou") + }, Providers: testAccProviders, CheckDestroy: testAccCheckPostgresqlInstanceDestroy, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlInstance, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlInstance, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -132,8 +138,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_basic(t *testing.T) { ImportStateVerifyIgnore: []string{"root_password", "spec_code", "public_access_switch", "charset", "backup_plan"}, }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlInstanceOpenPublic, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlInstanceOpenPublic, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -146,8 +155,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_basic(t *testing.T) { ), }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlInstanceUpdate, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlInstanceUpdate, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -170,8 +182,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_basic(t *testing.T) { ), }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlInstanceUpgradeKernelVersion, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlInstanceUpgradeKernelVersion, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -204,8 +219,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_prepaid(t *testing.T) { CheckDestroy: testAccCheckPostgresqlInstanceDestroy, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) }, - Config: testAccPostgresqlInstancePrepaid, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) + }, + Config: testAccPostgresqlInstancePrepaid, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -241,8 +259,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_postpaid_to_prepaid(t *testin CheckDestroy: testAccCheckPostgresqlInstanceDestroy, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) }, - Config: testAccPostgresqlInstancePostpaid, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) + }, + Config: testAccPostgresqlInstancePostpaid, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -252,8 +273,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_postpaid_to_prepaid(t *testin ), }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) }, - Config: testAccPostgresqlInstancePostpaid_to_Prepaid, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_PREPAY) + }, + Config: testAccPostgresqlInstancePostpaid_to_Prepaid, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -275,13 +299,19 @@ func TestAccTencentCloudPostgresqlInstanceResource_postpaid_to_prepaid(t *testin func TestAccTencentCloudPostgresqlInstanceResource_MAZ(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + testAccStepSetRegion(t, "ap-guangzhou") + }, Providers: testAccProviders, CheckDestroy: testAccCheckPostgresqlInstanceDestroy, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlMAZInstance, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlMAZInstance, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), @@ -298,8 +328,11 @@ func TestAccTencentCloudPostgresqlInstanceResource_MAZ(t *testing.T) { }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlMAZInstanceUpdate, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlMAZInstanceUpdate, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlInstanceExists(testPostgresqlInstanceResourceKey), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "id"), diff --git a/tencentcloud/resource_tc_postgresql_modify_account_remark_operation_test.go b/tencentcloud/resource_tc_postgresql_modify_account_remark_operation_test.go index 8df83447b1..a9eb317298 100644 --- a/tencentcloud/resource_tc_postgresql_modify_account_remark_operation_test.go +++ b/tencentcloud/resource_tc_postgresql_modify_account_remark_operation_test.go @@ -12,12 +12,17 @@ func TestAccTencentCloudPostgresqlModifyAccountRemarkOperationResource_basic(t * t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlModifyAccountRemarkOperation, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestObjectPgModifyAccountRemark, "id"), resource.TestCheckResourceAttrSet(TestObjectPgModifyAccountRemark, "db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_modify_switch_time_period_operation_test.go b/tencentcloud/resource_tc_postgresql_modify_switch_time_period_operation_test.go index a4ce36cd0d..64e22e14bf 100644 --- a/tencentcloud/resource_tc_postgresql_modify_switch_time_period_operation_test.go +++ b/tencentcloud/resource_tc_postgresql_modify_switch_time_period_operation_test.go @@ -13,12 +13,17 @@ func TestAccTencentCloudNeedFixPostgresqlModifySwitchTimePeriodOperationResource t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlModifySwitchTimePeriodOperation, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestObjectPgModifySwitchTimePeriod, "id"), resource.TestCheckResourceAttrSet(TestObjectPgModifySwitchTimePeriod, "db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_parameter_template_test.go b/tencentcloud/resource_tc_postgresql_parameter_template_test.go index 0275481623..4378d875b8 100644 --- a/tencentcloud/resource_tc_postgresql_parameter_template_test.go +++ b/tencentcloud/resource_tc_postgresql_parameter_template_test.go @@ -51,6 +51,7 @@ func TestAccTencentCloudPostgresqlParameterTemplateResource_basic(t *testing.T) t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, CheckDestroy: testAccCheckPostgresqlParameterTemplateDestroy, @@ -58,6 +59,10 @@ func TestAccTencentCloudPostgresqlParameterTemplateResource_basic(t *testing.T) Steps: []resource.TestStep{ { Config: testAccPostgresqlParameterTemplate, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlParameterTemplateExists("tencentcloud_postgresql_parameter_template.parameter_template"), resource.TestCheckResourceAttrSet("tencentcloud_postgresql_parameter_template.parameter_template", "id"), @@ -80,6 +85,10 @@ func TestAccTencentCloudPostgresqlParameterTemplateResource_basic(t *testing.T) }, { Config: testAccPostgresqlParameterTemplate_update_desc, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlParameterTemplateExists("tencentcloud_postgresql_parameter_template.parameter_template"), resource.TestCheckResourceAttr("tencentcloud_postgresql_parameter_template.parameter_template", "modify_param_entry_set.#", "2"), @@ -88,6 +97,10 @@ func TestAccTencentCloudPostgresqlParameterTemplateResource_basic(t *testing.T) }, { Config: testAccPostgresqlParameterTemplate_update_name, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlParameterTemplateExists("tencentcloud_postgresql_parameter_template.parameter_template"), resource.TestCheckResourceAttr("tencentcloud_postgresql_parameter_template.parameter_template", "modify_param_entry_set.#", "2"), @@ -96,6 +109,10 @@ func TestAccTencentCloudPostgresqlParameterTemplateResource_basic(t *testing.T) }, { Config: testAccPostgresqlParameterTemplate_update_multiple_attr, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( testAccCheckPostgresqlParameterTemplateExists("tencentcloud_postgresql_parameter_template.parameter_template"), resource.TestCheckResourceAttr("tencentcloud_postgresql_parameter_template.parameter_template", "modify_param_entry_set.#", "2"), diff --git a/tencentcloud/resource_tc_postgresql_readonly_group_test.go b/tencentcloud/resource_tc_postgresql_readonly_group_test.go index 961784e908..dbb8ccc411 100644 --- a/tencentcloud/resource_tc_postgresql_readonly_group_test.go +++ b/tencentcloud/resource_tc_postgresql_readonly_group_test.go @@ -11,12 +11,18 @@ var testPostgresqlReadonlyGroupResourceKey = "tencentcloud_postgresql_readonly_g func TestAccTencentCloudPostgresqlReadonlyGroupResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlReadonlyGroupInstance, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlReadonlyGroupInstance, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testPostgresqlReadonlyGroupResourceKey, "id"), resource.TestCheckResourceAttrSet(testPostgresqlReadonlyGroupResourceKey, "master_db_instance_id"), @@ -32,8 +38,11 @@ func TestAccTencentCloudPostgresqlReadonlyGroupResource_basic(t *testing.T) { ), }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlReadonlyGroupInstance_update, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlReadonlyGroupInstance_update, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testPostgresqlReadonlyGroupResourceKey, "id"), resource.TestCheckResourceAttrSet(testPostgresqlReadonlyGroupResourceKey, "master_db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_readonly_instance_test.go b/tencentcloud/resource_tc_postgresql_readonly_instance_test.go index 3a2e949d95..c9c783c4da 100644 --- a/tencentcloud/resource_tc_postgresql_readonly_instance_test.go +++ b/tencentcloud/resource_tc_postgresql_readonly_instance_test.go @@ -11,12 +11,18 @@ var testPostgresqlReadonlyInstanceResourceKey = "tencentcloud_postgresql_readonl func TestAccTencentCloudPostgresqlReadonlyInstanceResource_basic(t *testing.T) { // t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlReadonlyInstanceInstance_basic_without_rogroup, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlReadonlyInstanceInstance_basic_without_rogroup, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "id"), resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "master_db_instance_id"), @@ -35,8 +41,11 @@ func TestAccTencentCloudPostgresqlReadonlyInstanceResource_basic(t *testing.T) { ), }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlReadonlyInstanceInstance_basic_update_rogroup, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlReadonlyInstanceInstance_basic_update_rogroup, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "id"), resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "master_db_instance_id"), @@ -62,12 +71,18 @@ func TestAccTencentCloudPostgresqlReadonlyInstanceResource_basic(t *testing.T) { func TestAccTencentCloudPostgresqlReadonlyInstanceResource_update_ro_group(t *testing.T) { // t.Parallel() resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheck(t) + }, Providers: testAccProviders, Steps: []resource.TestStep{ { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlReadonlyInstanceInstance_with_rogroup, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlReadonlyInstanceInstance_with_rogroup, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "id"), resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "master_db_instance_id"), @@ -86,8 +101,11 @@ func TestAccTencentCloudPostgresqlReadonlyInstanceResource_update_ro_group(t *te ), }, { - PreConfig: func() { testAccStepPreConfigSetTempAKSK(t, ACCOUNT_TYPE_COMMON) }, - Config: testAccPostgresqlReadonlyInstanceInstance_update_rogroup, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, + Config: testAccPostgresqlReadonlyInstanceInstance_update_rogroup, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "id"), resource.TestCheckResourceAttrSet(testPostgresqlReadonlyInstanceResourceKey, "master_db_instance_id"), diff --git a/tencentcloud/resource_tc_postgresql_rebalance_readonly_group_operation_test.go b/tencentcloud/resource_tc_postgresql_rebalance_readonly_group_operation_test.go index d2fed58763..b8dfa4d38a 100644 --- a/tencentcloud/resource_tc_postgresql_rebalance_readonly_group_operation_test.go +++ b/tencentcloud/resource_tc_postgresql_rebalance_readonly_group_operation_test.go @@ -10,12 +10,17 @@ func TestAccTencentCloudPostgresqlRebalanceReadonlyGroupOperationResource_basic( t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlRebalanceReadonlyGroupOperation, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("tencentcloud_postgresql_rebalance_readonly_group_operation.rebalance_readonly_group_operation", "id"), resource.TestCheckResourceAttrSet("tencentcloud_postgresql_rebalance_readonly_group_operation.rebalance_readonly_group_operation", "read_only_group_id"), diff --git a/tencentcloud/resource_tc_postgresql_security_group_config_test.go b/tencentcloud/resource_tc_postgresql_security_group_config_test.go index 0f3175f99b..300dcdba27 100644 --- a/tencentcloud/resource_tc_postgresql_security_group_config_test.go +++ b/tencentcloud/resource_tc_postgresql_security_group_config_test.go @@ -12,12 +12,17 @@ func TestAccTencentCloudPostgresqlSecurityGroupConfigResource_basic(t *testing.T t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlSecurityGroupConfig_ins, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestAccPostgresqlSecurityGroupConfigObject, "id"), resource.TestCheckResourceAttr(TestAccPostgresqlSecurityGroupConfigObject, "security_group_id_set.#", "2"), @@ -32,12 +37,17 @@ func TestAccTencentCloudPostgresqlSecurityGroupConfigResource_ro(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccStepSetRegion(t, "ap-guangzhou") testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccPostgresqlSecurityGroupConfig_ro, + PreConfig: func() { + testAccStepSetRegion(t, "ap-guangzhou") + testAccPreCheckCommon(t, ACCOUNT_TYPE_COMMON) + }, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(TestAccPostgresqlSecurityGroupConfigObject, "id"), resource.TestCheckResourceAttr(TestAccPostgresqlSecurityGroupConfigObject, "security_group_id_set.#", "2"), From 6ab343e620dbc7957523ccb8f06e979ef991f3ef Mon Sep 17 00:00:00 2001 From: nickyinluo Date: Thu, 20 Jul 2023 20:41:50 +0800 Subject: [PATCH 4/4] update example --- tencentcloud/basic_test.go | 2 +- ...tc_tcr_create_image_signature_operation.go | 39 ++++- .../resource_tc_tcr_customized_domain.go | 20 ++- .../resource_tc_tcr_delete_image_operation.go | 33 ++++- .../resource_tc_tcr_immutable_tag_rule.go | 91 ++++++++++-- tencentcloud/resource_tc_tcr_instance.go | 24 +-- ...rce_tc_tcr_manage_replication_operation.go | 137 +++++++++++++----- tencentcloud/resource_tc_tcr_namespace.go | 16 +- tencentcloud/resource_tc_tcr_repository.go | 32 +++- .../resource_tc_tcr_service_account.go | 4 +- ...e_tc_tcr_tag_retention_execution_config.go | 29 ++-- .../resource_tc_tcr_tag_retention_rule.go | 23 ++- tencentcloud/resource_tc_tcr_token.go | 19 ++- .../resource_tc_tcr_vpc_attachment.go | 36 ++++- .../resource_tc_tcr_webhook_trigger.go | 32 ++-- ...te_image_signature_operation.html.markdown | 41 +++++- .../r/tcr_customized_domain.html.markdown | 20 ++- .../tcr_delete_image_operation.html.markdown | 34 ++++- .../r/tcr_immutable_tag_rule.html.markdown | 87 ++++++++++- website/docs/r/tcr_instance.html.markdown | 22 +-- ...manage_replication_operation.html.markdown | 92 ++++++++++-- website/docs/r/tcr_namespace.html.markdown | 16 +- website/docs/r/tcr_repository.html.markdown | 32 +++- .../docs/r/tcr_service_account.html.markdown | 6 +- ...g_retention_execution_config.html.markdown | 31 ++-- .../r/tcr_tag_retention_rule.html.markdown | 25 +++- website/docs/r/tcr_token.html.markdown | 19 ++- .../docs/r/tcr_vpc_attachment.html.markdown | 38 ++++- .../docs/r/tcr_webhook_trigger.html.markdown | 34 +++-- 29 files changed, 799 insertions(+), 235 deletions(-) diff --git a/tencentcloud/basic_test.go b/tencentcloud/basic_test.go index 6b9dd0db7b..157f7464b2 100644 --- a/tencentcloud/basic_test.go +++ b/tencentcloud/basic_test.go @@ -569,7 +569,7 @@ variable "cam_user_basic" { // TCR Service const defaultTCRInstanceName = "keep-tcr-instance-sh" -const defaultTCRInstanceId = "tcr-800uf6j9" +const defaultTCRInstanceId = "tcr-aoz8mxoz" const defaultTCRNamespace = "keep-tcr-namespace-sh" const defaultTCRRepoName = "keep-tcr-repo-sh" const defaultTCRSSL = "zjUMifFK" diff --git a/tencentcloud/resource_tc_tcr_create_image_signature_operation.go b/tencentcloud/resource_tc_tcr_create_image_signature_operation.go index 31b9398fad..995a88cbcc 100644 --- a/tencentcloud/resource_tc_tcr_create_image_signature_operation.go +++ b/tencentcloud/resource_tc_tcr_create_image_signature_operation.go @@ -1,15 +1,42 @@ /* -Provides a resource to create a tcr image_signature_operation +Provides a resource to operate a tcr image signature. Example Usage ```hcl -resource "tencentcloud_tcr_create_image_signature_operation" "image_signature_operation" { - registry_id = "tcr-xxx" - namespace_name = "ns" - repository_name = "repo" - image_version = "v1" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +resource "tencentcloud_tcr_repository" "example" { + instance_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + name = "test" + brief_desc = "111" + description = "111111111111111111111111111111111111" +} +resource "tencentcloud_tcr_create_image_signature_operation" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + repository_name = tencentcloud_tcr_repository.example.name + image_version = "v1" } ``` diff --git a/tencentcloud/resource_tc_tcr_customized_domain.go b/tencentcloud/resource_tc_tcr_customized_domain.go index 409725b472..a78d147871 100644 --- a/tencentcloud/resource_tc_tcr_customized_domain.go +++ b/tencentcloud/resource_tc_tcr_customized_domain.go @@ -1,13 +1,23 @@ /* -Provides a resource to create a tcr customized_domain +Provides a resource to create a tcr customized domain Example Usage +Create a tcr customized domain + ```hcl -resource "tencentcloud_tcr_customized_domain" "my_domain" { - registry_id = local.tcr_id - domain_name = "www.test.com" - certificate_id = "%s" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_customized_domain" "example" { + registry_id = tencentcloud_tcr_instance.example.id + domain_name = "www.test.com" + certificate_id = "your_cert_id" tags = { "createdBy" = "terraform" } diff --git a/tencentcloud/resource_tc_tcr_delete_image_operation.go b/tencentcloud/resource_tc_tcr_delete_image_operation.go index 825d9b6c45..3805461228 100644 --- a/tencentcloud/resource_tc_tcr_delete_image_operation.go +++ b/tencentcloud/resource_tc_tcr_delete_image_operation.go @@ -1,17 +1,38 @@ /* -Provides a resource to create a tcr delete_image_operation +Provides a resource to delete the specified tcr image. Example Usage +To delete the specified image + ```hcl -resource "tencentcloud_tcr_delete_image_operation" "delete_image_operation" { - registry_id = "tcr-xxx" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +resource "tencentcloud_tcr_delete_image_operation" "example" { + registry_id = tencentcloud_tcr_instance.example.id repository_name = "repo" - image_version = "v1" - namespace_name = "ns" + image_version = "v1" # the image want to delete + namespace_name = tencentcloud_tcr_namespace.example.name } ``` - */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_immutable_tag_rule.go b/tencentcloud/resource_tc_tcr_immutable_tag_rule.go index dcbdabb6c4..9c759413ee 100644 --- a/tencentcloud/resource_tc_tcr_immutable_tag_rule.go +++ b/tencentcloud/resource_tc_tcr_immutable_tag_rule.go @@ -1,18 +1,91 @@ /* -Provides a resource to create a tcr immutable_tag_rule +Provides a resource to create a tcr immutable tag rule. Example Usage +Create a immutable tag rule with specified tags and exclude specified repositories + ```hcl -resource "tencentcloud_tcr_immutable_tag_rule" "my_rule" { - registry_id = "%s" - namespace_name = "%s" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + delete_bucket = true +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +resource "tencentcloud_tcr_immutable_tag_rule" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + rule { + repository_pattern = "deprecated_repo" # specify exclude repo + tag_pattern = "**" # all tags + repository_decoration = "repoExcludes" + tag_decoration = "matches" + disabled = false + } + tags = { + "createdBy" = "terraform" + } +} +``` + +With specified repositories and exclude specified version tag + +```hcl +resource "tencentcloud_tcr_immutable_tag_rule" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + rule { + repository_pattern = "**" # all repo + tag_pattern = "v1" # exlude v1 tags + repository_decoration = "repoMatches" + tag_decoration = "excludes" + disabled = false + } + tags = { + "createdBy" = "terraform" + } +} +``` + +Disabled the specified rule + +```hcl +resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_A" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + rule { + repository_pattern = "deprecated_repo" # specify exclude repo + tag_pattern = "**" # all tags + repository_decoration = "repoExcludes" + tag_decoration = "matches" + disabled = false + } + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_B" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name rule { - repository_pattern = "**" - tag_pattern = "**" - repository_decoration = "repoMatches" - tag_decoration = "matches" - disabled = false + repository_pattern = "**" # all repo + tag_pattern = "v1" # exlude v1 tags + repository_decoration = "repoMatches" + tag_decoration = "excludes" + disabled = true # disable it } tags = { "createdBy" = "terraform" diff --git a/tencentcloud/resource_tc_tcr_instance.go b/tencentcloud/resource_tc_tcr_instance.go index 72b329ba6d..4b3f862333 100644 --- a/tencentcloud/resource_tc_tcr_instance.go +++ b/tencentcloud/resource_tc_tcr_instance.go @@ -3,21 +3,24 @@ Use this resource to create tcr instance. Example Usage +Create a basic tcr instance. + ```hcl -resource "tencentcloud_tcr_instance" "foo" { - name = "example" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "basic" tags = { - test = "tf" + "createdBy" = "terraform" } } ``` -Using public network access whitelist +Create instance with the public network access whitelist. + ```hcl -resource "tencentcloud_tcr_instance" "foo" { - name = "example" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "basic" open_public_operation = true security_policy { @@ -29,12 +32,11 @@ resource "tencentcloud_tcr_instance" "foo" { } ``` -Create with Replications +Create instance with Replications. ```hcl - -resource "tencentcloud_tcr_instance" "foo" { - name = "example" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "premium" replications { region_id = var.tcr_region_map["ap-guangzhou"] # 1 @@ -73,7 +75,7 @@ Import tcr instance can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_instance.foo cls-cda1iex1 +$ terraform import tencentcloud_tcr_instance.foo instance_id ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_manage_replication_operation.go b/tencentcloud/resource_tc_tcr_manage_replication_operation.go index f25e7a4cdc..bf9d7980b1 100644 --- a/tencentcloud/resource_tc_tcr_manage_replication_operation.go +++ b/tencentcloud/resource_tc_tcr_manage_replication_operation.go @@ -1,53 +1,114 @@ /* -Provides a resource to create a tcr manage_replication_operation +Provides a resource to start a tcr instance replication operation Example Usage +Sync source tcr instance to target instance + +Synchronize an existing tcr instance to the destination instance. This operation is often used in the cross-multiple region scenario. +Assume you have had two TCR instances before this operation. This example shows how to sync a tcr instance from ap-guangzhou(gz) to ap-shanghai(sh). + ```hcl -resource "tencentcloud_tcr_instance" "mytcr_dest" { - name = "tf-test-tcr-%s" - instance_type = "premium" - delete_bucket = true +# tcr instance on ap-guangzhou +resource "tencentcloud_tcr_instance" "example_gz" { + name = "tf-example-tcr-gz" + instance_type = "premium" + tags = { + "createdBy" = "terraform" } +} -resource "tencentcloud_tcr_namespace" "myns_dest" { - instance_id = tencentcloud_tcr_instance.mytcr_dest.id - name = "tf_test_ns_dest" - is_public = true - is_auto_scan = true - is_prevent_vul = true - severity = "medium" - cve_whitelist_items { - cve_id = "cve-xxxxx" - } +resource "tencentcloud_tcr_namespace" "example_gz" { + instance_id = tencentcloud_tcr_instance.example_gz.id + name = "tf_example_ns_gz" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } } -resource "tencentcloud_tcr_manage_replication_operation" "my_replica" { - source_registry_id = local.tcr_id - destination_registry_id = tencentcloud_tcr_instance.mytcr_dest.id +# tcr instance on ap-shanghai +resource "tencentcloud_tcr_instance" "example_sh" { + name = "tf-example-tcr-sh" + instance_type = "premium" + delete_bucket = true +} + +resource "tencentcloud_tcr_namespace" "example_sh" { + instance_id = tencentcloud_tcr_instance.example_sh.id + name = "tf_example_ns_sh" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +``` + +```hcl +# Run this on region ap-guangzhou +locals { + src_id = tencentcloud_tcr_instance.example_gz.id + dest_id = tencentcloud_tcr_instance.example_sh.id + src_ns = tencentcloud_tcr_namespace.example_gz.name + dest_ns = tencentcloud_tcr_instance.example_sh.id +} + +variable "tcr_region_map" { + default = { + "ap-guangzhou" = 1 + "ap-shanghai" = 4 + "ap-hongkong" = 5 + "ap-beijing" = 8 + "ap-singapore" = 9 + "na-siliconvalley" = 15 + "ap-chengdu" = 16 + "eu-frankfurt" = 17 + "ap-seoul" = 18 + "ap-chongqing" = 19 + "ap-mumbai" = 21 + "na-ashburn" = 22 + "ap-bangkok" = 23 + "eu-moscow" = 24 + "ap-tokyo" = 25 + "ap-nanjing" = 33 + "ap-taipei" = 39 + "ap-jakarta" = 72 + } +} + +resource "tencentcloud_tcr_manage_replication_operation" "example_sync" { + source_registry_id = local.src_id + destination_registry_id = local.dest_id rule { - name = "test_sync_%d" - dest_namespace = tencentcloud_tcr_namespace.myns_dest.name - override = true - filters { - type = "name" - value = join("/", [var.tcr_namespace, "**"]) - } - filters { - type = "tag" - value = "" - } - filters { - type = "resource" - value = "" - } + name = "tf_example_sync_gz_to_sh" + dest_namespace = local.dest_ns + override = true + filters { + type = "name" + value = join("/", [local.src_ns, "**"]) + } + filters { + type = "tag" + value = "" + } + filters { + type = "resource" + value = "" + } } - description = "this is the tcr sync operation" - destination_region_id = 1 // "ap-guangzhou" + description = "example for tcr sync operation" + destination_region_id = var.tcr_region_map["ap-shanghai"] # 4 peer_replication_option { - peer_registry_uin = "" - peer_registry_token = "" - enable_peer_replication = false + peer_registry_uin = "" + peer_registry_token = "" + enable_peer_replication = false } } ``` diff --git a/tencentcloud/resource_tc_tcr_namespace.go b/tencentcloud/resource_tc_tcr_namespace.go index f4c83c7120..d94e280ee7 100644 --- a/tencentcloud/resource_tc_tcr_namespace.go +++ b/tencentcloud/resource_tc_tcr_namespace.go @@ -3,9 +3,19 @@ Use this resource to create tcr namespace. Example Usage +Create a tcr namespace instance + ```hcl -resource "tencentcloud_tcr_namespace" "foo" { - instance_id = "" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id name = "example" is_public = true is_auto_scan = true @@ -22,7 +32,7 @@ Import tcr namespace can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_namespace.foo cls-cda1iex1#namespace +$ terraform import tencentcloud_tcr_namespace.example tcr_instance_id#namespace_name ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_repository.go b/tencentcloud/resource_tc_tcr_repository.go index 3ceb1c27f1..5da8f2ffef 100644 --- a/tencentcloud/resource_tc_tcr_repository.go +++ b/tencentcloud/resource_tc_tcr_repository.go @@ -3,15 +3,33 @@ Use this resource to create tcr repository. Example Usage +Create a tcr repository instance + ```hcl -data "tencentcloud_tcr_instances" "test" { - name = "test" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + delete_bucket = true +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } } -resource "tencentcloud_tcr_repository" "foo" { - instance_id = data.tencentcloud_tcr_instances.test.instance_list[0].id - namespace_name = "exampleNamespace" - name = "example" +resource "tencentcloud_tcr_repository" "example" { + instance_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + name = "test" + brief_desc = "111" + description = "111111111111111111111111111111111111" } ``` @@ -20,7 +38,7 @@ Import tcr repository can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_repository.foo cls-cda1iex1#namespace#repository +$ terraform import tencentcloud_tcr_repository.foo instance_id#namespace_name#repository_name ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_service_account.go b/tencentcloud/resource_tc_tcr_service_account.go index 7a88192098..eb91a7742c 100644 --- a/tencentcloud/resource_tc_tcr_service_account.go +++ b/tencentcloud/resource_tc_tcr_service_account.go @@ -1,5 +1,5 @@ /* -Provides a resource to create a tcr service_account +Provides a resource to create a tcr service account. Example Usage @@ -67,7 +67,7 @@ Import tcr service_account can be imported using the id, e.g. ``` -terraform import tencentcloud_tcr_service_account.service_account registry_id#name +terraform import tencentcloud_tcr_service_account.service_account registry_id#account_name ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_tag_retention_execution_config.go b/tencentcloud/resource_tc_tcr_tag_retention_execution_config.go index e5e31b0041..086bf85a5e 100644 --- a/tencentcloud/resource_tc_tcr_tag_retention_execution_config.go +++ b/tencentcloud/resource_tc_tcr_tag_retention_execution_config.go @@ -1,12 +1,21 @@ /* -Provides a resource to create a tcr tag_retention_execution_config +Provides a resource to configure a tcr tag retention execution. Example Usage ```hcl -resource "tencentcloud_tcr_namespace" "my_ns" { - instance_id = tencentcloud_tcr_instance.mytcr_retention.id - name = "tf_test_ns_retention" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns_retention" is_public = true is_auto_scan = true is_prevent_vul = true @@ -16,9 +25,9 @@ resource "tencentcloud_tcr_namespace" "my_ns" { } } -resource "tencentcloud_tcr_tag_retention_rule" "my_rule" { - registry_id = tencentcloud_tcr_instance.mytcr_retention.id - namespace_name = tencentcloud_tcr_namespace.my_ns.name +resource "tencentcloud_tcr_tag_retention_rule" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name retention_rule { key = "nDaysSinceLastPush" value = 2 @@ -27,9 +36,9 @@ resource "tencentcloud_tcr_tag_retention_rule" "my_rule" { disabled = true } -resource "tencentcloud_tcr_tag_retention_execution_config" "tag_retention_execution_config" { - registry_id = tencentcloud_tcr_tag_retention_rule.my_rule.registry_id - retention_id = tencentcloud_tcr_tag_retention_rule.my_rule.retention_id +resource "tencentcloud_tcr_tag_retention_execution_config" "example" { + registry_id = tencentcloud_tcr_tag_retention_rule.example.registry_id + retention_id = tencentcloud_tcr_tag_retention_rule.example.retention_id dry_run = false } ``` diff --git a/tencentcloud/resource_tc_tcr_tag_retention_rule.go b/tencentcloud/resource_tc_tcr_tag_retention_rule.go index 145098339e..d17904d346 100644 --- a/tencentcloud/resource_tc_tcr_tag_retention_rule.go +++ b/tencentcloud/resource_tc_tcr_tag_retention_rule.go @@ -1,12 +1,23 @@ /* -Provides a resource to create a tcr tag_retention_rule +Provides a resource to create a tcr tag retention rule. Example Usage +Create a tcr tag retention rule instance + ```hcl -resource "tencentcloud_tcr_namespace" "my_ns" { - instance_id = local.tcr_id - name = "tf_test_ns_retention" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns_retention" is_public = true is_auto_scan = true is_prevent_vul = true @@ -17,8 +28,8 @@ resource "tencentcloud_tcr_namespace" "my_ns" { } resource "tencentcloud_tcr_tag_retention_rule" "my_rule" { - registry_id = local.tcr_id - namespace_name = tencentcloud_tcr_namespace.my_ns.name + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name retention_rule { key = "nDaysSinceLastPush" value = 2 diff --git a/tencentcloud/resource_tc_tcr_token.go b/tencentcloud/resource_tc_tcr_token.go index e55c591c4f..083e15ed12 100644 --- a/tencentcloud/resource_tc_tcr_token.go +++ b/tencentcloud/resource_tc_tcr_token.go @@ -3,10 +3,21 @@ Use this resource to create tcr long term token. Example Usage +Create a token for tcr instance + ```hcl -resource "tencentcloud_tcr_token" "foo" { - instance_id = "cls-cda1iex1" - description = "test" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_token" "example" { + instance_id = tencentcloud_tcr_instance.example.id + description = "example for the tcr token" } ``` @@ -15,7 +26,7 @@ Import tcr token can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_token.foo cls-cda1iex1#namespace#buv3h3j96j2d1rk1cllg +$ terraform import tencentcloud_tcr_token.example instance_id#token_id ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_vpc_attachment.go b/tencentcloud/resource_tc_tcr_vpc_attachment.go index ee13dafac6..4a28eaf73e 100644 --- a/tencentcloud/resource_tc_tcr_vpc_attachment.go +++ b/tencentcloud/resource_tc_tcr_vpc_attachment.go @@ -1,13 +1,39 @@ /* -Use this resource to create tcr vpc attachment to manage access of internal endpoint. +Use this resource to attach tcr instance with the vpc and subnet network. Example Usage +Attach a tcr instance with vpc resource + ```hcl +locals { + vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id + subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id + tcr_id = tencentcloud_tcr_instance.example.id +} + +data "tencentcloud_vpc_subnets" "vpc" { + is_default = true + availability_zone = var.availability_zone +} + +data "tencentcloud_security_groups" "sg" { + name = "default" +} + +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + resource "tencentcloud_tcr_vpc_attachment" "foo" { - instance_id = "cls-satg5125" - vpc_id = "vpc-asg3sfa3" - subnet_id = "subnet-1uwh63so" + instance_id = local.tcr_id + vpc_id = local.vpc_id + subnet_id = local.subnet_id } ``` @@ -16,7 +42,7 @@ Import tcr vpc attachment can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_vpc_attachment.foo tcrId#vpcId#subnetId +$ terraform import tencentcloud_tcr_vpc_attachment.foo instance_id#vpc_id#subnet_id ``` */ package tencentcloud diff --git a/tencentcloud/resource_tc_tcr_webhook_trigger.go b/tencentcloud/resource_tc_tcr_webhook_trigger.go index d88676f8a9..031b3e7208 100644 --- a/tencentcloud/resource_tc_tcr_webhook_trigger.go +++ b/tencentcloud/resource_tc_tcr_webhook_trigger.go @@ -1,11 +1,13 @@ /* -Provides a resource to create a tcr webhook_trigger +Provides a resource to create a tcr webhook trigger Example Usage +Create a tcr webhook trigger instance + ```hcl -resource "tencentcloud_tcr_instance" "mytcr_webhooktrigger" { - name = "tf-test-tcr-%s" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "basic" delete_bucket = true @@ -14,9 +16,9 @@ resource "tencentcloud_tcr_instance" "mytcr_webhooktrigger" { } } -resource "tencentcloud_tcr_namespace" "my_ns" { - instance_id = tencentcloud_tcr_instance.mytcr_webhooktrigger.id - name = "tf_test_ns_%s" +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns_retention" is_public = true is_auto_scan = true is_prevent_vul = true @@ -26,19 +28,19 @@ resource "tencentcloud_tcr_namespace" "my_ns" { } } -data "tencentcloud_tcr_namespaces" "id_test" { - instance_id = tencentcloud_tcr_namespace.my_ns.instance_id +data "tencentcloud_tcr_namespaces" "example" { + instance_id = tencentcloud_tcr_namespace.example.instance_id } locals { - ns_id = data.tencentcloud_tcr_namespaces.id_test.namespace_list.0.id + ns_id = data.tencentcloud_tcr_namespaces.example.namespace_list.0.id } -resource "tencentcloud_tcr_webhook_trigger" "my_trigger" { - registry_id = tencentcloud_tcr_instance.mytcr_webhooktrigger.id - namespace = tencentcloud_tcr_namespace.my_ns.name +resource "tencentcloud_tcr_webhook_trigger" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace = tencentcloud_tcr_namespace.example.name trigger { - name = "trigger-%s" + name = "trigger-example" targets { address = "http://example.org/post" headers { @@ -49,7 +51,7 @@ resource "tencentcloud_tcr_webhook_trigger" "my_trigger" { event_types = ["pushImage"] condition = ".*" enabled = true - description = "this is trigger description" + description = "example for trigger description" namespace_id = local.ns_id } @@ -64,7 +66,7 @@ Import tcr webhook_trigger can be imported using the id, e.g. ``` -terraform import tencentcloud_tcr_webhook_trigger.webhook_trigger webhook_trigger_id +terraform import tencentcloud_tcr_webhook_trigger.example webhook_trigger_id ``` */ package tencentcloud diff --git a/website/docs/r/tcr_create_image_signature_operation.html.markdown b/website/docs/r/tcr_create_image_signature_operation.html.markdown index 4a53634080..9e8fe86dea 100644 --- a/website/docs/r/tcr_create_image_signature_operation.html.markdown +++ b/website/docs/r/tcr_create_image_signature_operation.html.markdown @@ -4,22 +4,49 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_create_image_signature_operation" sidebar_current: "docs-tencentcloud-resource-tcr_create_image_signature_operation" description: |- - Provides a resource to create a tcr image_signature_operation + Provides a resource to operate a tcr image signature. --- # tencentcloud_tcr_create_image_signature_operation -Provides a resource to create a tcr image_signature_operation +Provides a resource to operate a tcr image signature. ## Example Usage ```hcl -resource "tencentcloud_tcr_create_image_signature_operation" "image_signature_operation" { - registry_id = "tcr-xxx" - namespace_name = "ns" - repository_name = "repo" - image_version = "v1" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} +resource "tencentcloud_tcr_repository" "example" { + instance_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + name = "test" + brief_desc = "111" + description = "111111111111111111111111111111111111" +} + +resource "tencentcloud_tcr_create_image_signature_operation" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + repository_name = tencentcloud_tcr_repository.example.name + image_version = "v1" } ``` diff --git a/website/docs/r/tcr_customized_domain.html.markdown b/website/docs/r/tcr_customized_domain.html.markdown index 48ed329557..31b037e308 100644 --- a/website/docs/r/tcr_customized_domain.html.markdown +++ b/website/docs/r/tcr_customized_domain.html.markdown @@ -4,20 +4,30 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_customized_domain" sidebar_current: "docs-tencentcloud-resource-tcr_customized_domain" description: |- - Provides a resource to create a tcr customized_domain + Provides a resource to create a tcr customized domain --- # tencentcloud_tcr_customized_domain -Provides a resource to create a tcr customized_domain +Provides a resource to create a tcr customized domain ## Example Usage +### Create a tcr customized domain + ```hcl -resource "tencentcloud_tcr_customized_domain" "my_domain" { - registry_id = local.tcr_id +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_customized_domain" "example" { + registry_id = tencentcloud_tcr_instance.example.id domain_name = "www.test.com" - certificate_id = "%s" + certificate_id = "your_cert_id" tags = { "createdBy" = "terraform" } diff --git a/website/docs/r/tcr_delete_image_operation.html.markdown b/website/docs/r/tcr_delete_image_operation.html.markdown index 23139ae152..0cf02cff36 100644 --- a/website/docs/r/tcr_delete_image_operation.html.markdown +++ b/website/docs/r/tcr_delete_image_operation.html.markdown @@ -4,21 +4,43 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_delete_image_operation" sidebar_current: "docs-tencentcloud-resource-tcr_delete_image_operation" description: |- - Provides a resource to create a tcr delete_image_operation + Provides a resource to delete the specified tcr image. --- # tencentcloud_tcr_delete_image_operation -Provides a resource to create a tcr delete_image_operation +Provides a resource to delete the specified tcr image. ## Example Usage +### To delete the specified image + ```hcl -resource "tencentcloud_tcr_delete_image_operation" "delete_image_operation" { - registry_id = "tcr-xxx" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +resource "tencentcloud_tcr_delete_image_operation" "example" { + registry_id = tencentcloud_tcr_instance.example.id repository_name = "repo" - image_version = "v1" - namespace_name = "ns" + image_version = "v1" # the image want to delete + namespace_name = tencentcloud_tcr_namespace.example.name } ``` diff --git a/website/docs/r/tcr_immutable_tag_rule.html.markdown b/website/docs/r/tcr_immutable_tag_rule.html.markdown index 902f8720ff..d428f582c7 100644 --- a/website/docs/r/tcr_immutable_tag_rule.html.markdown +++ b/website/docs/r/tcr_immutable_tag_rule.html.markdown @@ -4,23 +4,81 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_immutable_tag_rule" sidebar_current: "docs-tencentcloud-resource-tcr_immutable_tag_rule" description: |- - Provides a resource to create a tcr immutable_tag_rule + Provides a resource to create a tcr immutable tag rule. --- # tencentcloud_tcr_immutable_tag_rule -Provides a resource to create a tcr immutable_tag_rule +Provides a resource to create a tcr immutable tag rule. ## Example Usage +### Create a immutable tag rule with specified tags and exclude specified repositories + ```hcl -resource "tencentcloud_tcr_immutable_tag_rule" "my_rule" { - registry_id = "%s" - namespace_name = "%s" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + delete_bucket = true +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +resource "tencentcloud_tcr_immutable_tag_rule" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name rule { - repository_pattern = "**" - tag_pattern = "**" + repository_pattern = "deprecated_repo" # specify exclude repo + tag_pattern = "**" # all tags + repository_decoration = "repoExcludes" + tag_decoration = "matches" + disabled = false + } + tags = { + "createdBy" = "terraform" + } +} +``` + +### With specified repositories and exclude specified version tag + +```hcl +resource "tencentcloud_tcr_immutable_tag_rule" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + rule { + repository_pattern = "**" # all repo + tag_pattern = "v1" # exlude v1 tags repository_decoration = "repoMatches" + tag_decoration = "excludes" + disabled = false + } + tags = { + "createdBy" = "terraform" + } +} +``` + +### Disabled the specified rule + +```hcl +resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_A" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + rule { + repository_pattern = "deprecated_repo" # specify exclude repo + tag_pattern = "**" # all tags + repository_decoration = "repoExcludes" tag_decoration = "matches" disabled = false } @@ -28,6 +86,21 @@ resource "tencentcloud_tcr_immutable_tag_rule" "my_rule" { "createdBy" = "terraform" } } + +resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_B" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + rule { + repository_pattern = "**" # all repo + tag_pattern = "v1" # exlude v1 tags + repository_decoration = "repoMatches" + tag_decoration = "excludes" + disabled = true # disable it + } + tags = { + "createdBy" = "terraform" + } +} ``` ## Argument Reference diff --git a/website/docs/r/tcr_instance.html.markdown b/website/docs/r/tcr_instance.html.markdown index 4ec7d37eeb..9a2f3bf81e 100644 --- a/website/docs/r/tcr_instance.html.markdown +++ b/website/docs/r/tcr_instance.html.markdown @@ -13,22 +13,24 @@ Use this resource to create tcr instance. ## Example Usage +### Create a basic tcr instance. + ```hcl -resource "tencentcloud_tcr_instance" "foo" { - name = "example" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "basic" tags = { - test = "tf" + "createdBy" = "terraform" } } ``` -### Using public network access whitelist +### Create instance with the public network access whitelist. ```hcl -resource "tencentcloud_tcr_instance" "foo" { - name = "example" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "basic" open_public_operation = true security_policy { @@ -40,11 +42,11 @@ resource "tencentcloud_tcr_instance" "foo" { } ``` -### Create with Replications +### Create instance with Replications. ```hcl -resource "tencentcloud_tcr_instance" "foo" { - name = "example" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "premium" replications { region_id = var.tcr_region_map["ap-guangzhou"] # 1 @@ -120,6 +122,6 @@ In addition to all arguments above, the following attributes are exported: tcr instance can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_instance.foo cls-cda1iex1 +$ terraform import tencentcloud_tcr_instance.foo instance_id ``` diff --git a/website/docs/r/tcr_manage_replication_operation.html.markdown b/website/docs/r/tcr_manage_replication_operation.html.markdown index 821ad73d50..a99a9d20a3 100644 --- a/website/docs/r/tcr_manage_replication_operation.html.markdown +++ b/website/docs/r/tcr_manage_replication_operation.html.markdown @@ -4,25 +4,52 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_manage_replication_operation" sidebar_current: "docs-tencentcloud-resource-tcr_manage_replication_operation" description: |- - Provides a resource to create a tcr manage_replication_operation + Provides a resource to start a tcr instance replication operation --- # tencentcloud_tcr_manage_replication_operation -Provides a resource to create a tcr manage_replication_operation +Provides a resource to start a tcr instance replication operation ## Example Usage +### Sync source tcr instance to target instance + +Synchronize an existing tcr instance to the destination instance. This operation is often used in the cross-multiple region scenario. +Assume you have had two TCR instances before this operation. This example shows how to sync a tcr instance from ap-guangzhou(gz) to ap-shanghai(sh). + ```hcl -resource "tencentcloud_tcr_instance" "mytcr_dest" { - name = "tf-test-tcr-%s" +# tcr instance on ap-guangzhou +resource "tencentcloud_tcr_instance" "example_gz" { + name = "tf-example-tcr-gz" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example_gz" { + instance_id = tencentcloud_tcr_instance.example_gz.id + name = "tf_example_ns_gz" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } +} + +# tcr instance on ap-shanghai +resource "tencentcloud_tcr_instance" "example_sh" { + name = "tf-example-tcr-sh" instance_type = "premium" delete_bucket = true } -resource "tencentcloud_tcr_namespace" "myns_dest" { - instance_id = tencentcloud_tcr_instance.mytcr_dest.id - name = "tf_test_ns_dest" +resource "tencentcloud_tcr_namespace" "example_sh" { + instance_id = tencentcloud_tcr_instance.example_sh.id + name = "tf_example_ns_sh" is_public = true is_auto_scan = true is_prevent_vul = true @@ -31,17 +58,52 @@ resource "tencentcloud_tcr_namespace" "myns_dest" { cve_id = "cve-xxxxx" } } +``` + + + +```hcl +# Run this on region ap-guangzhou +locals { + src_id = tencentcloud_tcr_instance.example_gz.id + dest_id = tencentcloud_tcr_instance.example_sh.id + src_ns = tencentcloud_tcr_namespace.example_gz.name + dest_ns = tencentcloud_tcr_instance.example_sh.id +} + +variable "tcr_region_map" { + default = { + "ap-guangzhou" = 1 + "ap-shanghai" = 4 + "ap-hongkong" = 5 + "ap-beijing" = 8 + "ap-singapore" = 9 + "na-siliconvalley" = 15 + "ap-chengdu" = 16 + "eu-frankfurt" = 17 + "ap-seoul" = 18 + "ap-chongqing" = 19 + "ap-mumbai" = 21 + "na-ashburn" = 22 + "ap-bangkok" = 23 + "eu-moscow" = 24 + "ap-tokyo" = 25 + "ap-nanjing" = 33 + "ap-taipei" = 39 + "ap-jakarta" = 72 + } +} -resource "tencentcloud_tcr_manage_replication_operation" "my_replica" { - source_registry_id = local.tcr_id - destination_registry_id = tencentcloud_tcr_instance.mytcr_dest.id +resource "tencentcloud_tcr_manage_replication_operation" "example_sync" { + source_registry_id = local.src_id + destination_registry_id = local.dest_id rule { - name = "test_sync_%d" - dest_namespace = tencentcloud_tcr_namespace.myns_dest.name + name = "tf_example_sync_gz_to_sh" + dest_namespace = local.dest_ns override = true filters { type = "name" - value = join("/", [var.tcr_namespace, "**"]) + value = join("/", [local.src_ns, "**"]) } filters { type = "tag" @@ -52,8 +114,8 @@ resource "tencentcloud_tcr_manage_replication_operation" "my_replica" { value = "" } } - description = "this is the tcr sync operation" - destination_region_id = 1 // "ap-guangzhou" + description = "example for tcr sync operation" + destination_region_id = var.tcr_region_map["ap-shanghai"] # 4 peer_replication_option { peer_registry_uin = "" peer_registry_token = "" diff --git a/website/docs/r/tcr_namespace.html.markdown b/website/docs/r/tcr_namespace.html.markdown index 0a303374b5..23cfc43d8a 100644 --- a/website/docs/r/tcr_namespace.html.markdown +++ b/website/docs/r/tcr_namespace.html.markdown @@ -13,9 +13,19 @@ Use this resource to create tcr namespace. ## Example Usage +### Create a tcr namespace instance + ```hcl -resource "tencentcloud_tcr_namespace" "foo" { - instance_id = "" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id name = "example" is_public = true is_auto_scan = true @@ -56,6 +66,6 @@ In addition to all arguments above, the following attributes are exported: tcr namespace can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_namespace.foo cls-cda1iex1#namespace +$ terraform import tencentcloud_tcr_namespace.example tcr_instance_id#namespace_name ``` diff --git a/website/docs/r/tcr_repository.html.markdown b/website/docs/r/tcr_repository.html.markdown index d4e9315076..979f293c0d 100644 --- a/website/docs/r/tcr_repository.html.markdown +++ b/website/docs/r/tcr_repository.html.markdown @@ -13,15 +13,33 @@ Use this resource to create tcr repository. ## Example Usage +### Create a tcr repository instance + ```hcl -data "tencentcloud_tcr_instances" "test" { - name = "test" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "premium" + delete_bucket = true +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns" + is_public = true + is_auto_scan = true + is_prevent_vul = true + severity = "medium" + cve_whitelist_items { + cve_id = "cve-xxxxx" + } } -resource "tencentcloud_tcr_repository" "foo" { - instance_id = data.tencentcloud_tcr_instances.test.instance_list[0].id - namespace_name = "exampleNamespace" - name = "example" +resource "tencentcloud_tcr_repository" "example" { + instance_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name + name = "test" + brief_desc = "111" + description = "111111111111111111111111111111111111" } ``` @@ -51,6 +69,6 @@ In addition to all arguments above, the following attributes are exported: tcr repository can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_repository.foo cls-cda1iex1#namespace#repository +$ terraform import tencentcloud_tcr_repository.foo instance_id#namespace_name#repository_name ``` diff --git a/website/docs/r/tcr_service_account.html.markdown b/website/docs/r/tcr_service_account.html.markdown index 5bb5a700cd..b18cb1dddd 100644 --- a/website/docs/r/tcr_service_account.html.markdown +++ b/website/docs/r/tcr_service_account.html.markdown @@ -4,12 +4,12 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_service_account" sidebar_current: "docs-tencentcloud-resource-tcr_service_account" description: |- - Provides a resource to create a tcr service_account + Provides a resource to create a tcr service account. --- # tencentcloud_tcr_service_account -Provides a resource to create a tcr service_account +Provides a resource to create a tcr service account. ## Example Usage @@ -103,6 +103,6 @@ In addition to all arguments above, the following attributes are exported: tcr service_account can be imported using the id, e.g. ``` -terraform import tencentcloud_tcr_service_account.service_account registry_id#name +terraform import tencentcloud_tcr_service_account.service_account registry_id#account_name ``` diff --git a/website/docs/r/tcr_tag_retention_execution_config.html.markdown b/website/docs/r/tcr_tag_retention_execution_config.html.markdown index 4ffbd201b9..8f6c3164ad 100644 --- a/website/docs/r/tcr_tag_retention_execution_config.html.markdown +++ b/website/docs/r/tcr_tag_retention_execution_config.html.markdown @@ -4,19 +4,28 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_tag_retention_execution_config" sidebar_current: "docs-tencentcloud-resource-tcr_tag_retention_execution_config" description: |- - Provides a resource to create a tcr tag_retention_execution_config + Provides a resource to configure a tcr tag retention execution. --- # tencentcloud_tcr_tag_retention_execution_config -Provides a resource to create a tcr tag_retention_execution_config +Provides a resource to configure a tcr tag retention execution. ## Example Usage ```hcl -resource "tencentcloud_tcr_namespace" "my_ns" { - instance_id = tencentcloud_tcr_instance.mytcr_retention.id - name = "tf_test_ns_retention" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns_retention" is_public = true is_auto_scan = true is_prevent_vul = true @@ -26,9 +35,9 @@ resource "tencentcloud_tcr_namespace" "my_ns" { } } -resource "tencentcloud_tcr_tag_retention_rule" "my_rule" { - registry_id = tencentcloud_tcr_instance.mytcr_retention.id - namespace_name = tencentcloud_tcr_namespace.my_ns.name +resource "tencentcloud_tcr_tag_retention_rule" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name retention_rule { key = "nDaysSinceLastPush" value = 2 @@ -37,9 +46,9 @@ resource "tencentcloud_tcr_tag_retention_rule" "my_rule" { disabled = true } -resource "tencentcloud_tcr_tag_retention_execution_config" "tag_retention_execution_config" { - registry_id = tencentcloud_tcr_tag_retention_rule.my_rule.registry_id - retention_id = tencentcloud_tcr_tag_retention_rule.my_rule.retention_id +resource "tencentcloud_tcr_tag_retention_execution_config" "example" { + registry_id = tencentcloud_tcr_tag_retention_rule.example.registry_id + retention_id = tencentcloud_tcr_tag_retention_rule.example.retention_id dry_run = false } ``` diff --git a/website/docs/r/tcr_tag_retention_rule.html.markdown b/website/docs/r/tcr_tag_retention_rule.html.markdown index eefd753c8c..0306e0b836 100644 --- a/website/docs/r/tcr_tag_retention_rule.html.markdown +++ b/website/docs/r/tcr_tag_retention_rule.html.markdown @@ -4,19 +4,30 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_tag_retention_rule" sidebar_current: "docs-tencentcloud-resource-tcr_tag_retention_rule" description: |- - Provides a resource to create a tcr tag_retention_rule + Provides a resource to create a tcr tag retention rule. --- # tencentcloud_tcr_tag_retention_rule -Provides a resource to create a tcr tag_retention_rule +Provides a resource to create a tcr tag retention rule. ## Example Usage +### Create a tcr tag retention rule instance + ```hcl -resource "tencentcloud_tcr_namespace" "my_ns" { - instance_id = local.tcr_id - name = "tf_test_ns_retention" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns_retention" is_public = true is_auto_scan = true is_prevent_vul = true @@ -27,8 +38,8 @@ resource "tencentcloud_tcr_namespace" "my_ns" { } resource "tencentcloud_tcr_tag_retention_rule" "my_rule" { - registry_id = local.tcr_id - namespace_name = tencentcloud_tcr_namespace.my_ns.name + registry_id = tencentcloud_tcr_instance.example.id + namespace_name = tencentcloud_tcr_namespace.example.name retention_rule { key = "nDaysSinceLastPush" value = 2 diff --git a/website/docs/r/tcr_token.html.markdown b/website/docs/r/tcr_token.html.markdown index c26a286ec6..742850e0b2 100644 --- a/website/docs/r/tcr_token.html.markdown +++ b/website/docs/r/tcr_token.html.markdown @@ -13,10 +13,21 @@ Use this resource to create tcr long term token. ## Example Usage +### Create a token for tcr instance + ```hcl -resource "tencentcloud_tcr_token" "foo" { - instance_id = "cls-cda1iex1" - description = "test" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_tcr_token" "example" { + instance_id = tencentcloud_tcr_instance.example.id + description = "example for the tcr token" } ``` @@ -44,6 +55,6 @@ In addition to all arguments above, the following attributes are exported: tcr token can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_token.foo cls-cda1iex1#namespace#buv3h3j96j2d1rk1cllg +$ terraform import tencentcloud_tcr_token.example instance_id#token_id ``` diff --git a/website/docs/r/tcr_vpc_attachment.html.markdown b/website/docs/r/tcr_vpc_attachment.html.markdown index 02a3694561..826c9997dd 100644 --- a/website/docs/r/tcr_vpc_attachment.html.markdown +++ b/website/docs/r/tcr_vpc_attachment.html.markdown @@ -4,20 +4,46 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_vpc_attachment" sidebar_current: "docs-tencentcloud-resource-tcr_vpc_attachment" description: |- - Use this resource to create tcr vpc attachment to manage access of internal endpoint. + Use this resource to attach tcr instance with the vpc and subnet network. --- # tencentcloud_tcr_vpc_attachment -Use this resource to create tcr vpc attachment to manage access of internal endpoint. +Use this resource to attach tcr instance with the vpc and subnet network. ## Example Usage +### Attach a tcr instance with vpc resource + ```hcl +locals { + vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id + subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id + tcr_id = tencentcloud_tcr_instance.example.id +} + +data "tencentcloud_vpc_subnets" "vpc" { + is_default = true + availability_zone = var.availability_zone +} + +data "tencentcloud_security_groups" "sg" { + name = "default" +} + +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" + instance_type = "basic" + delete_bucket = true + tags = { + "createdBy" = "terraform" + } +} + resource "tencentcloud_tcr_vpc_attachment" "foo" { - instance_id = "cls-satg5125" - vpc_id = "vpc-asg3sfa3" - subnet_id = "subnet-1uwh63so" + instance_id = local.tcr_id + vpc_id = local.vpc_id + subnet_id = local.subnet_id } ``` @@ -47,6 +73,6 @@ In addition to all arguments above, the following attributes are exported: tcr vpc attachment can be imported using the id, e.g. ``` -$ terraform import tencentcloud_tcr_vpc_attachment.foo tcrId#vpcId#subnetId +$ terraform import tencentcloud_tcr_vpc_attachment.foo instance_id#vpc_id#subnet_id ``` diff --git a/website/docs/r/tcr_webhook_trigger.html.markdown b/website/docs/r/tcr_webhook_trigger.html.markdown index 6072929ea8..d5193efcbf 100644 --- a/website/docs/r/tcr_webhook_trigger.html.markdown +++ b/website/docs/r/tcr_webhook_trigger.html.markdown @@ -4,18 +4,20 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_tcr_webhook_trigger" sidebar_current: "docs-tencentcloud-resource-tcr_webhook_trigger" description: |- - Provides a resource to create a tcr webhook_trigger + Provides a resource to create a tcr webhook trigger --- # tencentcloud_tcr_webhook_trigger -Provides a resource to create a tcr webhook_trigger +Provides a resource to create a tcr webhook trigger ## Example Usage +### Create a tcr webhook trigger instance + ```hcl -resource "tencentcloud_tcr_instance" "mytcr_webhooktrigger" { - name = "tf-test-tcr-%s" +resource "tencentcloud_tcr_instance" "example" { + name = "tf-example-tcr" instance_type = "basic" delete_bucket = true @@ -24,9 +26,9 @@ resource "tencentcloud_tcr_instance" "mytcr_webhooktrigger" { } } -resource "tencentcloud_tcr_namespace" "my_ns" { - instance_id = tencentcloud_tcr_instance.mytcr_webhooktrigger.id - name = "tf_test_ns_%s" +resource "tencentcloud_tcr_namespace" "example" { + instance_id = tencentcloud_tcr_instance.example.id + name = "tf_example_ns_retention" is_public = true is_auto_scan = true is_prevent_vul = true @@ -36,19 +38,19 @@ resource "tencentcloud_tcr_namespace" "my_ns" { } } -data "tencentcloud_tcr_namespaces" "id_test" { - instance_id = tencentcloud_tcr_namespace.my_ns.instance_id +data "tencentcloud_tcr_namespaces" "example" { + instance_id = tencentcloud_tcr_namespace.example.instance_id } locals { - ns_id = data.tencentcloud_tcr_namespaces.id_test.namespace_list.0.id + ns_id = data.tencentcloud_tcr_namespaces.example.namespace_list.0.id } -resource "tencentcloud_tcr_webhook_trigger" "my_trigger" { - registry_id = tencentcloud_tcr_instance.mytcr_webhooktrigger.id - namespace = tencentcloud_tcr_namespace.my_ns.name +resource "tencentcloud_tcr_webhook_trigger" "example" { + registry_id = tencentcloud_tcr_instance.example.id + namespace = tencentcloud_tcr_namespace.example.name trigger { - name = "trigger-%s" + name = "trigger-example" targets { address = "http://example.org/post" headers { @@ -59,7 +61,7 @@ resource "tencentcloud_tcr_webhook_trigger" "my_trigger" { event_types = ["pushImage"] condition = ".*" enabled = true - description = "this is trigger description" + description = "example for trigger description" namespace_id = local.ns_id } @@ -111,6 +113,6 @@ In addition to all arguments above, the following attributes are exported: tcr webhook_trigger can be imported using the id, e.g. ``` -terraform import tencentcloud_tcr_webhook_trigger.webhook_trigger webhook_trigger_id +terraform import tencentcloud_tcr_webhook_trigger.example webhook_trigger_id ```