Skip to content

Commit 98b1030

Browse files
feat: added access tag support (#166)
1 parent 44e9c07 commit 98b1030

File tree

18 files changed

+124
-13
lines changed

18 files changed

+124
-13
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ You need the following permissions to run this module.
3636
- **Databases for PostgreSQL** service
3737
- `Editor` role access
3838

39+
To attach access management tags to resources in this module, you need the following permissions.
40+
41+
- IAM Services
42+
- **Tagging** service
43+
- `Administrator` platform access
44+
3945
<!-- BEGIN EXAMPLES HOOK -->
4046
## Examples
4147

@@ -66,11 +72,13 @@ You need the following permissions to run this module.
6672
| [ibm_database.postgresql_db](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database) | resource |
6773
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
6874
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
75+
| [ibm_resource_tag.postgresql_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
6976

7077
## Inputs
7178

7279
| Name | Description | Type | Default | Required |
7380
|------|-------------|------|---------|:--------:|
81+
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the PostgreSQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
7482
| <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://ibm.biz/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 |
7583
| <a name="input_backup_crn"></a> [backup\_crn](#input\_backup\_crn) | The CRN of a backup resource to restore from. The backup is created by a database deployment with the same service ID. The backup is loaded after provisioning and the new deployment starts up that uses that data. A backup CRN is in the format crn:v1:<…>:backup:. If omitted, the database is provisioned empty. | `string` | `null` | no |
7684
| <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/backup/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module "postgresql_db" {
1717
pg_version = var.pg_version
1818
region = var.region
1919
resource_tags = var.resource_tags
20+
access_tags = var.access_tags
2021
}
2122

2223
data "ibm_database_backups" "backup_database" {
@@ -32,5 +33,6 @@ module "restored_postgresql_db" {
3233
pg_version = var.pg_version
3334
region = var.region
3435
resource_tags = var.resource_tags
36+
access_tags = var.access_tags
3537
backup_crn = var.postgresql_db_backup_crn == null ? data.ibm_database_backups.backup_database[0].backups[0].backup_id : var.postgresql_db_backup_crn
3638
}

examples/backup/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ variable "resource_tags" {
3434
default = []
3535
}
3636

37+
variable "access_tags" {
38+
type = list(string)
39+
description = "A list of access tags to apply to the PostgreSQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
40+
default = []
41+
}
42+
3743
variable "postgresql_db_backup_crn" {
3844
type = string
3945
description = "The existing CRN of a backup resource to restore from. If null then it will create a new instance first and then create another instance pointing to the backup of the first instance."

examples/basic/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module "postgresql_db" {
2020
pg_version = var.pg_version
2121
region = var.region
2222
resource_tags = var.resource_tags
23+
access_tags = var.access_tags
2324
}
2425

2526
##############################################################################
@@ -33,6 +34,7 @@ module "read_only_replica_postgresql_db" {
3334
name = "${var.prefix}-read-only-replica-${count.index}"
3435
region = var.region
3536
resource_tags = var.resource_tags
37+
access_tags = var.access_tags
3638
pg_version = var.pg_version
3739
remote_leader_crn = module.postgresql_db.crn
3840
member_memory_mb = 2304 # Must be an increment of 384 megabytes. The minimum size of a read-only replica is 2 GB RAM

examples/basic/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ variable "resource_tags" {
3434
default = []
3535
}
3636

37+
variable "access_tags" {
38+
type = list(string)
39+
description = "A list of access tags to apply to the PostgreSQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
40+
default = []
41+
}
42+
3743
variable "read_only_replicas_count" {
3844
type = number
3945
description = "Number of read-only replicas per leader"

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ module "postgresql_db" {
7777
existing_kms_instance_guid = module.key_protect_all_inclusive.key_protect_guid
7878
resource_tags = var.resource_tags
7979
service_credential_names = var.service_credential_names
80+
access_tags = var.access_tags
8081
cbr_rules = [
8182
{
8283
description = "${var.prefix}-postgres access only from vpc"

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 PostgreSQL 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 "pg_version" {
3238
description = "Version of the PostgreSQL instance. If no value is passed, the current preferred version of IBM Cloud Databases is used."
3339
type = string

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module "postgresql_db" {
6161
existing_kms_instance_guid = var.existing_kms_instance_guid
6262
resource_tags = var.resource_tags
6363
service_credential_names = var.service_credential_names
64+
access_tags = var.access_tags
6465
auto_scaling = var.auto_scaling
6566
cbr_rules = [
6667
{

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 PostgreSQL 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 "pg_version" {
3238
description = "Version of the PostgreSQL instance. If no value is passed, the current preferred version of IBM Cloud Databases is used."
3339
type = string

examples/pitr/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module "postgresql_db_pitr" {
2020
name = "${var.prefix}-postgres-pitr"
2121
region = var.region
2222
resource_tags = var.resource_tags
23+
access_tags = var.access_tags
2324
member_memory_mb = 3072
2425
member_disk_mb = 15360
2526
member_cpu_count = 9

0 commit comments

Comments
 (0)