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 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 ```