Skip to content

Commit 8f84a28

Browse files
feat: added access tag support (#8)
1 parent e01dbb6 commit 8f84a28

File tree

8 files changed

+94
-21
lines changed

8 files changed

+94
-21
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ You need the following permissions to run this module.
6161
| [ibm_database.rabbitmq_database](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database) | resource |
6262
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
6363
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
64+
| [ibm_resource_tag.rabbitmq_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
6465
| [ibm_database_connection.database_connection](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/database_connection) | data source |
6566

6667
### Inputs
6768

6869
| Name | Description | Type | Default | Required |
6970
|------|-------------|------|---------|:--------:|
71+
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the rabbitmq instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
7072
| <a name="input_admin_pass"></a> [admin\_pass](#input\_admin\_pass) | The password for the database administrator. If the admin password is null then the admin user ID cannot be accessed. More users can be specified in a user block. The admin password must be in the range of 10-32 characters. | `string` | `null` | no |
7173
| <a name="input_auto_scaling"></a> [auto\_scaling](#input\_auto\_scaling) | Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-autoscaling in the IBM Cloud Docs. | <pre>object({<br> disk = object({<br> capacity_enabled = optional(bool, false)<br> free_space_less_than_percent = optional(number, 10)<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 3670016)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> memory = object({<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 114688)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> })</pre> | `null` | no |
7274
| <a name="input_backup_encryption_key_crn"></a> [backup\_encryption\_key\_crn](#input\_backup\_encryption\_key\_crn) | The CRN of a Key Protect key, that you want to use for encrypting disk that holds deployment backups. Only used if var.kms\_encryption\_enabled is set to true. If no value passed, the value passed for the 'kms\_key\_crn' variable will be used. BYOK for backups is available only in US regions us-south and us-east, and eu-de. Only keys in the us-south and eu-de are durable to region failures. To ensure that your backups are available even if a region failure occurs, you must use a key from us-south or eu-de. Take note that Hyper Protect Crypto Services for IBM Cloud® Databases backups is not currently supported, so if no value is passed here, but a HPCS value is passed for var.kms\_key\_crn, databases backup encryption will use the default encryption keys. | `string` | `null` | no |

examples/basic/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ module "icd_rabbitmq" {
2020
instance_name = "${var.prefix}-rabbitmq"
2121
region = var.region
2222
tags = var.resource_tags
23+
access_tags = var.access_tags
2324
}

examples/basic/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ variable "resource_tags" {
2727
description = "Optional list of tags to be added to created resources"
2828
default = []
2929
}
30+
31+
variable "access_tags" {
32+
type = list(string)
33+
description = "A list of access tags to apply to the rabbitmq instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
34+
default = []
35+
}

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ module "icd_rabbitmq" {
8383
rabbitmq_version = var.rabbitmq_version
8484
kms_key_crn = module.key_protect_all_inclusive.keys["icd.${var.prefix}-rabbitmq"].crn
8585
tags = var.resource_tags
86+
access_tags = var.access_tags
8687
auto_scaling = var.auto_scaling
8788
cbr_rules = [
8889
{

examples/complete/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ variable "resource_tags" {
6464
default = []
6565
}
6666

67+
variable "access_tags" {
68+
type = list(string)
69+
description = "A list of access tags to apply to the rabbitmq instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
70+
default = []
71+
}
72+
6773
variable "auto_scaling" {
6874
type = object({
6975
disk = object({

main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ resource "ibm_database" "rabbitmq_database" {
119119
}
120120
}
121121

122+
resource "ibm_resource_tag" "rabbitmq_tag" {
123+
count = length(var.access_tags) == 0 ? 0 : 1
124+
resource_id = ibm_database.rabbitmq_database.resource_crn
125+
tags = var.access_tags
126+
tag_type = "access"
127+
}
128+
122129
##############################################################################
123130
# Context Based Restrictions
124131
##############################################################################

module-metadata.json

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
{
22
"path": ".",
33
"variables": {
4+
"access_tags": {
5+
"name": "access_tags",
6+
"type": "list(string)",
7+
"description": "A list of access tags to apply to the rabbitmq instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details",
8+
"default": [],
9+
"source": [
10+
"ibm_resource_tag.rabbitmq_tag.count",
11+
"ibm_resource_tag.rabbitmq_tag.tags"
12+
],
13+
"pos": {
14+
"filename": "variables.tf",
15+
"line": 27
16+
},
17+
"min_length": 1,
18+
"max_length": 128,
19+
"matches": "^[A-Za-z0-9:_ .-]+$",
20+
"computed": true,
21+
"elem": {
22+
"type": "TypeString"
23+
}
24+
},
425
"admin_pass": {
526
"name": "admin_pass",
627
"type": "string",
@@ -11,7 +32,7 @@
1132
],
1233
"pos": {
1334
"filename": "variables.tf",
14-
"line": 132
35+
"line": 145
1536
}
1637
},
1738
"auto_scaling": {
@@ -20,7 +41,7 @@
2041
"description": "Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-autoscaling in the IBM Cloud Docs.",
2142
"pos": {
2243
"filename": "variables.tf",
23-
"line": 94
44+
"line": 107
2445
}
2546
},
2647
"backup_encryption_key_crn": {
@@ -29,7 +50,7 @@
2950
"description": "The CRN of a Key Protect key, that you want to use for encrypting disk that holds deployment backups. Only used if var.kms_encryption_enabled is set to true. If no value passed, the value passed for the 'kms_key_crn' variable will be used. BYOK for backups is available only in US regions us-south and us-east, and eu-de. Only keys in the us-south and eu-de are durable to region failures. To ensure that your backups are available even if a region failure occurs, you must use a key from us-south or eu-de. Take note that Hyper Protect Crypto Services for IBM Cloud® Databases backups is not currently supported, so if no value is passed here, but a HPCS value is passed for var.kms_key_crn, databases backup encryption will use the default encryption keys.",
3051
"pos": {
3152
"filename": "variables.tf",
32-
"line": 175
53+
"line": 188
3354
}
3455
},
3556
"cbr_rules": {
@@ -46,7 +67,7 @@
4667
],
4768
"pos": {
4869
"filename": "variables.tf",
49-
"line": 201
70+
"line": 214
5071
}
5172
},
5273
"cpu_count": {
@@ -56,7 +77,7 @@
5677
"default": 0,
5778
"pos": {
5879
"filename": "variables.tf",
59-
"line": 82
80+
"line": 95
6081
}
6182
},
6283
"disk_mb": {
@@ -66,7 +87,7 @@
6687
"default": 1024,
6788
"pos": {
6889
"filename": "variables.tf",
69-
"line": 88
90+
"line": 101
7091
}
7192
},
7293
"endpoints": {
@@ -81,7 +102,7 @@
81102
],
82103
"pos": {
83104
"filename": "variables.tf",
84-
"line": 33
105+
"line": 46
85106
},
86107
"options": "public, private, public-and-private"
87108
},
@@ -94,7 +115,7 @@
94115
],
95116
"pos": {
96117
"filename": "variables.tf",
97-
"line": 191
118+
"line": 204
98119
},
99120
"immutable": true,
100121
"computed": true
@@ -122,7 +143,7 @@
122143
],
123144
"pos": {
124145
"filename": "variables.tf",
125-
"line": 155
146+
"line": 168
126147
}
127148
},
128149
"kms_key_crn": {
@@ -134,7 +155,7 @@
134155
],
135156
"pos": {
136157
"filename": "variables.tf",
137-
"line": 161
158+
"line": 174
138159
},
139160
"immutable": true
140161
},
@@ -145,7 +166,7 @@
145166
"default": 3,
146167
"pos": {
147168
"filename": "variables.tf",
148-
"line": 69
169+
"line": 82
149170
}
150171
},
151172
"memory_mb": {
@@ -155,7 +176,7 @@
155176
"default": 1024,
156177
"pos": {
157178
"filename": "variables.tf",
158-
"line": 76
179+
"line": 89
159180
}
160181
},
161182
"plan": {
@@ -169,7 +190,7 @@
169190
],
170191
"pos": {
171192
"filename": "variables.tf",
172-
"line": 57
193+
"line": 70
173194
},
174195
"immutable": true,
175196
"options": "standard, enterprise"
@@ -184,7 +205,7 @@
184205
],
185206
"pos": {
186207
"filename": "variables.tf",
187-
"line": 27
208+
"line": 40
188209
}
189210
},
190211
"rabbitmq_version": {
@@ -196,7 +217,7 @@
196217
],
197218
"pos": {
198219
"filename": "variables.tf",
199-
"line": 43
220+
"line": 56
200221
},
201222
"immutable": true,
202223
"computed": true
@@ -246,7 +267,7 @@
246267
],
247268
"pos": {
248269
"filename": "variables.tf",
249-
"line": 121
270+
"line": 134
250271
}
251272
},
252273
"skip_iam_authorization_policy": {
@@ -256,7 +277,7 @@
256277
"default": false,
257278
"pos": {
258279
"filename": "variables.tf",
259-
"line": 185
280+
"line": 198
260281
}
261282
},
262283
"tags": {
@@ -286,7 +307,7 @@
286307
],
287308
"pos": {
288309
"filename": "variables.tf",
289-
"line": 139
310+
"line": 152
290311
}
291312
}
292313
},
@@ -441,7 +462,23 @@
441462
},
442463
"pos": {
443464
"filename": "main.tf",
444-
"line": 163
465+
"line": 170
466+
}
467+
},
468+
"ibm_resource_tag.rabbitmq_tag": {
469+
"mode": "managed",
470+
"type": "ibm_resource_tag",
471+
"name": "rabbitmq_tag",
472+
"attributes": {
473+
"count": "access_tags",
474+
"tags": "access_tags"
475+
},
476+
"provider": {
477+
"name": "ibm"
478+
},
479+
"pos": {
480+
"filename": "main.tf",
481+
"line": 122
445482
}
446483
}
447484
},
@@ -461,7 +498,7 @@
461498
},
462499
"pos": {
463500
"filename": "main.tf",
464-
"line": 192
501+
"line": 199
465502
}
466503
}
467504
},
@@ -539,7 +576,7 @@
539576
},
540577
"pos": {
541578
"filename": "main.tf",
542-
"line": 125
579+
"line": 132
543580
}
544581
}
545582
}

variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ variable "tags" {
2424
default = []
2525
}
2626

27+
variable "access_tags" {
28+
type = list(string)
29+
description = "A list of access tags to apply to the rabbitmq instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
30+
default = []
31+
32+
validation {
33+
condition = alltrue([
34+
for tag in var.access_tags : can(regex("[\\w\\-_\\.]+:[\\w\\-_\\.]+", tag)) && length(tag) <= 128
35+
])
36+
error_message = "Tags must match the regular expression \"[\\w\\-_\\.]+:[\\w\\-_\\.]+\", see https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#limits for more details"
37+
}
38+
}
39+
2740
variable "plan_validation" {
2841
type = bool
2942
description = "Enable or disable validating the database parameters for rabbitmq during the plan phase"

0 commit comments

Comments
 (0)