Skip to content

Commit d342e4d

Browse files
authored
feat: adding access tag support (#189)
1 parent b03df8b commit d342e4d

File tree

14 files changed

+111
-22
lines changed

14 files changed

+111
-22
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ You need the following permissions to run this module.
6464
| [ibm_database.mongodb](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database) | resource |
6565
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
6666
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
67+
| [ibm_resource_tag.mongodb_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
6768
| [ibm_database_connection.database_connection](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/database_connection) | data source |
6869

6970
## Inputs
7071

7172
| Name | Description | Type | Default | Required |
7273
|------|-------------|------|---------|:--------:|
74+
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the MongoDB instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
7375
| <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 |
7476
| <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/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=cli#autoscaling-considerations 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 |
7577
| <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 the disk that holds deployment backups. Only used if var.kms\_encryption\_enabled is set to true. BYOK for backups is available only in US regions us-south and us-east, and in 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, use a key from us-south or eu-de. Hyper Protect Crypto Services for IBM Cloud Databases backups is not currently supported. If no value is passed here, the value passed for the 'kms\_key\_crn' variable is used. And if a HPCS value is passed for var.kms\_key\_crn, the database backup encryption uses 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
@@ -18,5 +18,6 @@ module "mongodb" {
1818
resource_group_id = module.resource_group.resource_group_id
1919
instance_name = "${var.prefix}-mongodb"
2020
region = var.region
21+
access_tags = var.access_tags
2122
tags = var.resource_tags
2223
}

examples/basic/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ variable "resource_group" {
2222
default = null
2323
}
2424

25+
variable "access_tags" {
26+
type = list(string)
27+
description = "A list of access tags to apply to the MongoDB instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
28+
default = []
29+
}
30+
2531
variable "resource_tags" {
2632
type = list(string)
2733
description = "Optional list of tags to be added to created resources"

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ module "mongodb" {
7777
existing_kms_instance_guid = module.key_protect_all_inclusive.key_protect_guid
7878
region = var.region
7979
kms_key_crn = module.key_protect_all_inclusive.keys["icd.${var.prefix}-mongodb"].crn
80+
access_tags = var.access_tags
8081
tags = var.resource_tags
8182
service_credential_names = var.service_credential_names
8283
cbr_rules = [

examples/complete/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ variable "resource_tags" {
2828
default = []
2929
}
3030

31+
variable "access_tags" {
32+
type = list(string)
33+
description = "A list of access tags to apply to the MongoDB instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
34+
default = []
35+
}
36+
3137
variable "mongodb_version" {
3238
type = string
3339
description = "Version of the MongoDB instance. If no value is passed, the current preferred version of IBM Cloud Databases is used."

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module "mongodb" {
5757
instance_name = "${var.prefix}-mongodb"
5858
region = var.region
5959
tags = var.resource_tags
60+
access_tags = var.access_tags
6061
kms_key_crn = var.kms_key_crn
6162
existing_kms_instance_guid = var.existing_kms_instance_guid
6263
mongodb_version = var.mongodb_version

examples/fscloud/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ variable "resource_tags" {
2828
default = []
2929
}
3030

31+
variable "access_tags" {
32+
type = list(string)
33+
description = "A list of access tags to apply to the MongoDB instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
34+
default = []
35+
}
36+
3137
variable "existing_kms_instance_guid" {
3238
description = "The GUID of the Hyper Protect Crypto service in which the key specified in var.kms_key_crn is coming from"
3339
type = string

main.tf

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

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

module-metadata.json

Lines changed: 59 additions & 22 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 MongoDB 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.mongodb_tag.count",
11+
"ibm_resource_tag.mongodb_tag.tags"
12+
],
13+
"pos": {
14+
"filename": "variables.tf",
15+
"line": 35
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": 122
35+
"line": 135
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/databases-for-mongodb?topic=databases-for-mongodb-autoscaling\u0026interface=cli#autoscaling-considerations in the IBM Cloud Docs.",
2142
"pos": {
2243
"filename": "variables.tf",
23-
"line": 141
44+
"line": 154
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 the disk that holds deployment backups. Only used if var.kms_encryption_enabled is set to true. BYOK for backups is available only in US regions us-south and us-east, and in 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, use a key from us-south or eu-de. Hyper Protect Crypto Services for IBM Cloud Databases backups is not currently supported. If no value is passed here, the value passed for the 'kms_key_crn' variable is used. And if a HPCS value is passed for var.kms_key_crn, the database backup encryption uses the default encryption keys.",
3051
"pos": {
3152
"filename": "variables.tf",
32-
"line": 192
53+
"line": 205
3354
}
3455
},
3556
"cbr_rules": {
@@ -46,7 +67,7 @@
4667
],
4768
"pos": {
4869
"filename": "variables.tf",
49-
"line": 218
70+
"line": 231
5071
}
5172
},
5273
"configuration": {
@@ -58,7 +79,7 @@
5879
],
5980
"pos": {
6081
"filename": "variables.tf",
61-
"line": 35
82+
"line": 48
6283
}
6384
},
6485
"cpu_count": {
@@ -68,7 +89,7 @@
6889
"default": 0,
6990
"pos": {
7091
"filename": "variables.tf",
71-
"line": 97
92+
"line": 110
7293
}
7394
},
7495
"disk_mb": {
@@ -78,7 +99,7 @@
7899
"default": 10240,
79100
"pos": {
80101
"filename": "variables.tf",
81-
"line": 90
102+
"line": 103
82103
}
83104
},
84105
"endpoints": {
@@ -93,7 +114,7 @@
93114
],
94115
"pos": {
95116
"filename": "variables.tf",
96-
"line": 72
117+
"line": 85
97118
},
98119
"options": "public, private, public-and-private"
99120
},
@@ -106,7 +127,7 @@
106127
],
107128
"pos": {
108129
"filename": "variables.tf",
109-
"line": 208
130+
"line": 221
110131
},
111132
"immutable": true,
112133
"computed": true
@@ -134,7 +155,7 @@
134155
],
135156
"pos": {
136157
"filename": "variables.tf",
137-
"line": 172
158+
"line": 185
138159
}
139160
},
140161
"kms_key_crn": {
@@ -146,7 +167,7 @@
146167
],
147168
"pos": {
148169
"filename": "variables.tf",
149-
"line": 178
170+
"line": 191
150171
},
151172
"immutable": true
152173
},
@@ -157,7 +178,7 @@
157178
"default": 3,
158179
"pos": {
159180
"filename": "variables.tf",
160-
"line": 104
181+
"line": 117
161182
}
162183
},
163184
"memory_mb": {
@@ -167,7 +188,7 @@
167188
"default": 1024,
168189
"pos": {
169190
"filename": "variables.tf",
170-
"line": 83
191+
"line": 96
171192
}
172193
},
173194
"mongodb_version": {
@@ -179,7 +200,7 @@
179200
],
180201
"pos": {
181202
"filename": "variables.tf",
182-
"line": 47
203+
"line": 60
183204
},
184205
"immutable": true,
185206
"computed": true
@@ -239,7 +260,7 @@
239260
],
240261
"pos": {
241262
"filename": "variables.tf",
242-
"line": 61
263+
"line": 74
243264
},
244265
"cloud_data_type": "resource_group",
245266
"immutable": true,
@@ -258,7 +279,7 @@
258279
],
259280
"pos": {
260281
"filename": "variables.tf",
261-
"line": 111
282+
"line": 124
262283
}
263284
},
264285
"skip_iam_authorization_policy": {
@@ -268,7 +289,7 @@
268289
"default": false,
269290
"pos": {
270291
"filename": "variables.tf",
271-
"line": 202
292+
"line": 215
272293
}
273294
},
274295
"tags": {
@@ -282,7 +303,7 @@
282303
],
283304
"pos": {
284305
"filename": "variables.tf",
285-
"line": 66
306+
"line": 79
286307
}
287308
},
288309
"users": {
@@ -298,7 +319,7 @@
298319
],
299320
"pos": {
300321
"filename": "variables.tf",
301-
"line": 129
322+
"line": 142
302323
}
303324
}
304325
},
@@ -454,7 +475,23 @@
454475
},
455476
"pos": {
456477
"filename": "main.tf",
457-
"line": 166
478+
"line": 173
479+
}
480+
},
481+
"ibm_resource_tag.mongodb_tag": {
482+
"mode": "managed",
483+
"type": "ibm_resource_tag",
484+
"name": "mongodb_tag",
485+
"attributes": {
486+
"count": "access_tags",
487+
"tags": "access_tags"
488+
},
489+
"provider": {
490+
"name": "ibm"
491+
},
492+
"pos": {
493+
"filename": "main.tf",
494+
"line": 123
458495
}
459496
}
460497
},
@@ -474,7 +511,7 @@
474511
},
475512
"pos": {
476513
"filename": "main.tf",
477-
"line": 195
514+
"line": 202
478515
}
479516
}
480517
},
@@ -552,7 +589,7 @@
552589
},
553590
"pos": {
554591
"filename": "main.tf",
555-
"line": 127
592+
"line": 134
556593
}
557594
}
558595
}

profiles/fscloud/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ No resources.
3232

3333
| Name | Description | Type | Default | Required |
3434
|------|-------------|------|---------|:--------:|
35+
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the MongoDB instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
3536
| <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 |
3637
| <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/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=cli#autoscaling-considerations 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 |
3738
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> }))</pre> | `[]` | no |

0 commit comments

Comments
 (0)