Skip to content

Commit 352443d

Browse files
Khuzaima05Khuzaima-Shakeel
andauthored
feat: added support for access tags (#59)
Co-authored-by: Khuzaima-Shakeel <[email protected]>
1 parent 2acf433 commit 352443d

File tree

8 files changed

+31
-0
lines changed

8 files changed

+31
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ You need the following permissions to run this module.
7373
| [ibm_database.elasticsearch](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/database) | resource |
7474
| [ibm_iam_authorization_policy.policy](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
7575
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_key) | resource |
76+
| [ibm_resource_tag.elasticsearch_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
7677
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
7778
| [ibm_database_connection.database_connection](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/database_connection) | data source |
7879

7980
### Inputs
8081

8182
| Name | Description | Type | Default | Required |
8283
|------|-------------|------|---------|:--------:|
84+
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the Elasticsearch instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
8385
| <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 and cannot start with a special character. | `string` | `null` | no |
8486
| <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-elasticsearch?topic=databases-for-elasticsearch-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 |
8587
| <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 is passed here, the value passed for the 'kms\_key\_crn' variable is used, unless 'use\_default\_backup\_encryption\_key' is set to 'true'. 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_elasticsearch" {
2020
region = var.region
2121
elasticsearch_version = var.elasticsearch_version
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
@@ -28,6 +28,12 @@ variable "elasticsearch_version" {
2828
default = null
2929
}
3030

31+
variable "access_tags" {
32+
type = list(string)
33+
description = "A list of access tags to apply to the Elasticsearch 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 "resource_tags" {
3238
type = list(string)
3339
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
@@ -41,6 +41,7 @@ module "icd_elasticsearch" {
4141
region = var.region
4242
plan = var.plan
4343
kms_encryption_enabled = true
44+
access_tags = var.access_tags
4445
admin_pass = var.admin_pass
4546
users = var.users
4647
existing_kms_instance_guid = module.key_protect_all_inclusive.key_protect_guid

examples/complete/variables.tf

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

31+
variable "access_tags" {
32+
type = list(string)
33+
description = "A list of access tags to apply to the Elasticsearch 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 "resource_tags" {
3238
type = list(string)
3339
description = "Optional list of tags to be added to created resources"

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ resource "ibm_database" "elasticsearch" {
128128
}
129129
}
130130

131+
resource "ibm_resource_tag" "elasticsearch_tag" {
132+
count = length(var.access_tags) == 0 ? 0 : 1
133+
resource_id = ibm_database.elasticsearch.resource_crn
134+
tags = var.access_tags
135+
tag_type = "access"
136+
}
137+
138+
131139
##############################################################################
132140
# Context Based Restrictions
133141
##############################################################################

tests/pr_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func TestRunCompleteExample(t *testing.T) {
5555
BestRegionYAMLPath: regionSelectionPath,
5656
TerraformVars: map[string]interface{}{
5757
"elasticsearch_version": "8.10",
58+
"access_tags": permanentResources["accessTags"],
5859
"existing_sm_instance_guid": permanentResources["secretsManagerGuid"],
5960
"existing_sm_instance_region": permanentResources["secretsManagerRegion"],
6061
"users": []map[string]interface{}{

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ variable "name" {
1818
description = "The name to give the Elasticsearch instance."
1919
}
2020

21+
variable "access_tags" {
22+
type = list(string)
23+
description = "A list of access tags to apply to the Elasticsearch instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
24+
default = []
25+
}
26+
2127
variable "tags" {
2228
type = list(string)
2329
description = "Tags associated with the instance (Optional, array of strings)."

0 commit comments

Comments
 (0)