|
1 | 1 | /* |
2 | | -Provides a resource to create a tcr immutable_tag_rule |
| 2 | +Provides a resource to create a tcr immutable tag rule. |
3 | 3 |
|
4 | 4 | Example Usage |
5 | 5 |
|
| 6 | +Create a immutable tag rule with specified tags and exclude specified repositories |
| 7 | +
|
6 | 8 | ```hcl |
7 | | -resource "tencentcloud_tcr_immutable_tag_rule" "my_rule" { |
8 | | - registry_id = "%s" |
9 | | - namespace_name = "%s" |
| 9 | +resource "tencentcloud_tcr_instance" "example" { |
| 10 | + name = "tf-example-tcr" |
| 11 | + instance_type = "premium" |
| 12 | + delete_bucket = true |
| 13 | +} |
| 14 | +
|
| 15 | +resource "tencentcloud_tcr_namespace" "example" { |
| 16 | + instance_id = tencentcloud_tcr_instance.example.id |
| 17 | + name = "tf_example_ns" |
| 18 | + is_public = true |
| 19 | + is_auto_scan = true |
| 20 | + is_prevent_vul = true |
| 21 | + severity = "medium" |
| 22 | + cve_whitelist_items { |
| 23 | + cve_id = "cve-xxxxx" |
| 24 | + } |
| 25 | +} |
| 26 | +
|
| 27 | +resource "tencentcloud_tcr_immutable_tag_rule" "example" { |
| 28 | + registry_id = tencentcloud_tcr_instance.example.id |
| 29 | + namespace_name = tencentcloud_tcr_namespace.example.name |
| 30 | + rule { |
| 31 | + repository_pattern = "deprecated_repo" # specify exclude repo |
| 32 | + tag_pattern = "**" # all tags |
| 33 | + repository_decoration = "repoExcludes" |
| 34 | + tag_decoration = "matches" |
| 35 | + disabled = false |
| 36 | + } |
| 37 | + tags = { |
| 38 | + "createdBy" = "terraform" |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | +
|
| 43 | +With specified repositories and exclude specified version tag |
| 44 | +
|
| 45 | +```hcl |
| 46 | +resource "tencentcloud_tcr_immutable_tag_rule" "example" { |
| 47 | + registry_id = tencentcloud_tcr_instance.example.id |
| 48 | + namespace_name = tencentcloud_tcr_namespace.example.name |
| 49 | + rule { |
| 50 | + repository_pattern = "**" # all repo |
| 51 | + tag_pattern = "v1" # exlude v1 tags |
| 52 | + repository_decoration = "repoMatches" |
| 53 | + tag_decoration = "excludes" |
| 54 | + disabled = false |
| 55 | + } |
| 56 | + tags = { |
| 57 | + "createdBy" = "terraform" |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | +
|
| 62 | +Disabled the specified rule |
| 63 | +
|
| 64 | +```hcl |
| 65 | +resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_A" { |
| 66 | + registry_id = tencentcloud_tcr_instance.example.id |
| 67 | + namespace_name = tencentcloud_tcr_namespace.example.name |
| 68 | + rule { |
| 69 | + repository_pattern = "deprecated_repo" # specify exclude repo |
| 70 | + tag_pattern = "**" # all tags |
| 71 | + repository_decoration = "repoExcludes" |
| 72 | + tag_decoration = "matches" |
| 73 | + disabled = false |
| 74 | + } |
| 75 | + tags = { |
| 76 | + "createdBy" = "terraform" |
| 77 | + } |
| 78 | +} |
| 79 | +
|
| 80 | +resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_B" { |
| 81 | + registry_id = tencentcloud_tcr_instance.example.id |
| 82 | + namespace_name = tencentcloud_tcr_namespace.example.name |
10 | 83 | rule { |
11 | | - repository_pattern = "**" |
12 | | - tag_pattern = "**" |
13 | | - repository_decoration = "repoMatches" |
14 | | - tag_decoration = "matches" |
15 | | - disabled = false |
| 84 | + repository_pattern = "**" # all repo |
| 85 | + tag_pattern = "v1" # exlude v1 tags |
| 86 | + repository_decoration = "repoMatches" |
| 87 | + tag_decoration = "excludes" |
| 88 | + disabled = true # disable it |
16 | 89 | } |
17 | 90 | tags = { |
18 | 91 | "createdBy" = "terraform" |
|
0 commit comments