Skip to content

Commit e9d2580

Browse files
authored
feat: Module updates (#496)
1 parent bae4ed2 commit e9d2580

28 files changed

+648
-405
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,20 @@ You need the following permissions to run this module.
8989
| <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 |
9090
| <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 |
9191
| <a name="input_backup_encryption_key_crn"></a> [backup\_encryption\_key\_crn](#input\_backup\_encryption\_key\_crn) | The CRN of a Key Protect or Hyper Protect Crypto Services encryption key that you want to use for encrypting the disk that holds deployment backups. Applies only if `use_ibm_owned_encryption_key` is false and `use_same_kms_key_for_backups` is false. If no value is passed, and `use_same_kms_key_for_backups` is true, the value of `kms_key_crn` is used. Alternatively set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `string` | `null` | no |
92-
| <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 |
92+
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of context-based restrictions 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/> tags = optional(list(object({<br/> name = string<br/> value = string<br/> })))<br/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
9393
| <a name="input_cpu_count"></a> [cpu\_count](#input\_cpu\_count) | Allocated dedicated CPU per member. For shared CPU, set to 0. [Learn more](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-pricing#mongodb-scale-member) | `number` | `0` | no |
94-
| <a name="input_disk_mb"></a> [disk\_mb](#input\_disk\_mb) | Allocated disk per member. [Learn more](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-pricing#mongodb-scale-member) | `number` | `10240` | no |
95-
| <a name="input_endpoints"></a> [endpoints](#input\_endpoints) | Specify whether you want to enable the public, private, or both service endpoints. Supported values are 'public', 'private', or 'public-and-private'. | `string` | `"private"` | no |
96-
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name to give the MongoDB instance. | `string` | n/a | yes |
94+
| <a name="input_disk_mb"></a> [disk\_mb](#input\_disk\_mb) | The disk that is allocated per member. [Learn more](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-pricing#mongodb-scale-member) | `number` | `10240` | no |
9795
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The CRN of a Key Protect or Hyper Protect Crypto Services encryption key to encrypt your data. Applies only if `use_ibm_owned_encryption_key` is false. By default this key is used for both deployment data and backups, but this behaviour can be altered using the `use_same_kms_key_for_backups` and `backup_encryption_key_crn` inputs. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `string` | `null` | no |
9896
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). | `string` | `null` | no |
99-
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members | `number` | `3` | no |
97+
| <a name="input_members"></a> [members](#input\_members) | The number of members that are allocated. [Learn more](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-resources-scaling) | `number` | `3` | no |
10098
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-pricing#mongodb-scale-member) | `number` | `4096` | no |
10199
| <a name="input_mongodb_version"></a> [mongodb\_version](#input\_mongodb\_version) | The version of the MongoDB to provision. If no value passed, the current ICD preferred version is used. For our version policy, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-versioning-policy for more details | `string` | `null` | no |
100+
| <a name="input_name"></a> [name](#input\_name) | The name to give the MongoDB instance. | `string` | n/a | yes |
102101
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the service plan that you choose for your MongoDB instance | `string` | `"standard"` | no |
103102
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |
104103
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the MongoDB instance will be created. | `string` | n/a | yes |
105104
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | Map of name, role for service credentials that you want to create for the database | `map(string)` | `{}` | no |
105+
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The type of endpoint of the database instance. Possible values: `public`, `private`, `public-and-private`. | `string` | `"public"` | no |
106106
| <a name="input_skip_iam_authorization_policy"></a> [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of IAM authorization policies that permits all Databases for MongoDB instances in the given resource group 'Reader' access to the Key Protect or Hyper Protect Crypto Services key that was provided in the `kms_key_crn` and `backup_encryption_key_crn` inputs. This policy is required in order to enable KMS encryption, so only skip creation if there is one already present in your account. No policy is created if `use_ibm_owned_encryption_key` is true. | `bool` | `false` | no |
107107
| <a name="input_tags"></a> [tags](#input\_tags) | Optional list of tags to be added to the MongoDB instance. | `list(any)` | `[]` | no |
108108
| <a name="input_use_default_backup_encryption_key"></a> [use\_default\_backup\_encryption\_key](#input\_use\_default\_backup\_encryption\_key) | When `use_ibm_owned_encryption_key` is set to false, backups will be encrypted with either the key specified in `kms_key_crn`, or in `backup_encryption_key_crn` if a value is passed. If you do not want to use your own key for backups encryption, you can set this to `true` to use the IBM Cloud Databases default encryption for backups. Alternatively set `use_ibm_owned_encryption_key` to true to use the default encryption for both backups and deployment data. | `bool` | `false` | no |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ibmcloud_api_key": $VALIDATION_APIKEY,
3+
"region": "us-south",
4+
"tags": $TAGS,
5+
"prefix": $PREFIX
6+
}

examples/backup-restore/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ module "resource_group" {
1111
}
1212

1313
data "ibm_database_backups" "backup_database" {
14-
deployment_id = var.mongo_db_crn
14+
deployment_id = var.existing_database_crn
1515
}
1616

1717
# New mongo db instance pointing to the backup instance
18-
module "restored_mongo_db" {
18+
module "restored_icd_mongodb" {
1919
source = "../.."
2020
resource_group_id = module.resource_group.resource_group_id
21-
instance_name = "${var.prefix}-mongodb-restored"
21+
name = "${var.prefix}-mongodb-restored"
2222
region = var.region
2323
mongodb_version = var.mongodb_version
2424
access_tags = var.access_tags
25-
tags = var.resource_tags
25+
tags = var.tags
2626
member_host_flavor = "multitenant"
2727
backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id
2828
}

examples/backup-restore/outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# Outputs
33
##############################################################################
44

5-
output "restored_mongo_db_id" {
5+
output "restored_icd_mongodb_id" {
66
description = "Restored MongoDB instance id"
7-
value = module.restored_mongo_db.id
7+
value = module.restored_icd_mongodb.id
88
}
99

10-
output "restored_mongo_db_version" {
10+
output "restored_icd_mongodb_version" {
1111
description = "Restored MongoDB instance version"
12-
value = module.restored_mongo_db.version
12+
value = module.restored_icd_mongodb.version
1313
}

examples/backup-restore/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ variable "mongodb_version" {
3434
default = null
3535
}
3636

37-
variable "resource_tags" {
37+
variable "tags" {
3838
type = list(string)
3939
description = "Optional list of tags to be added to created resources"
4040
default = []
4141
}
4242

43-
variable "mongo_db_crn" {
43+
variable "existing_database_crn" {
4444
type = string
4545
description = "The existing CRN of a mongoDB instance to fetch the latest backup crn."
46+
default = null
4647
}

examples/basic/main.tf

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ module "resource_group" {
1111
}
1212

1313
##############################################################################
14-
# ICD mongodb database
14+
# MongoDB Instance
1515
##############################################################################
1616

17-
module "mongodb" {
18-
source = "../.."
19-
resource_group_id = module.resource_group.resource_group_id
20-
instance_name = "${var.prefix}-mongodb"
21-
region = var.region
22-
mongodb_version = var.mongodb_version
23-
access_tags = var.access_tags
24-
tags = var.resource_tags
17+
module "database" {
18+
source = "../.."
19+
resource_group_id = module.resource_group.resource_group_id
20+
name = "${var.prefix}-data-store"
21+
region = var.region
22+
mongodb_version = var.mongodb_version
23+
access_tags = var.access_tags
24+
tags = var.tags
25+
service_endpoints = var.service_endpoints
26+
member_host_flavor = var.member_host_flavor
27+
service_credential_names = {
28+
"mongodb_admin" : "Administrator",
29+
"mongodb_operator" : "Operator",
30+
"mongodb_viewer" : "Viewer",
31+
"mongodb_editor" : "Editor",
32+
}
2533
}

examples/basic/outputs.tf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,37 @@
22
# Outputs
33
##############################################################################
44
output "id" {
5-
description = "Mongodb instance id"
6-
value = module.mongodb.id
5+
description = "Database instance id"
6+
value = module.database.id
7+
}
8+
9+
output "mongodb_crn" {
10+
description = "Mongodb CRN"
11+
value = module.database.crn
712
}
813

914
output "version" {
1015
description = "Mongodb instance version"
11-
value = module.mongodb.version
16+
value = module.database.version
1217
}
1318

1419
output "adminuser" {
1520
description = "Database admin user name"
16-
value = module.mongodb.adminuser
21+
value = module.database.adminuser
1722
}
1823

1924
output "hostname" {
2025
description = "Database connection hostname"
21-
value = module.mongodb.hostname
26+
value = module.database.hostname
2227
}
2328

2429
output "port" {
2530
description = "Database connection port"
26-
value = module.mongodb.port
31+
value = module.database.port
2732
}
2833

2934
output "certificate_base64" {
3035
description = "Database connection certificate"
31-
value = module.mongodb.certificate_base64
36+
value = module.database.certificate_base64
3237
sensitive = true
3338
}

examples/basic/variables.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,25 @@ variable "mongodb_version" {
3434
default = null
3535
}
3636

37-
variable "resource_tags" {
37+
variable "tags" {
3838
type = list(string)
3939
description = "Optional list of tags to be added to created resources"
4040
default = []
4141
}
42+
43+
variable "service_endpoints" {
44+
type = string
45+
description = "The type of endpoint of the database instance. Possible values: `public`, `private`, `public-and-private`."
46+
default = "public"
47+
48+
validation {
49+
condition = can(regex("public|public-and-private|private", var.service_endpoints))
50+
error_message = "Valid values for service_endpoints are 'public', 'public-and-private', and 'private'"
51+
}
52+
}
53+
variable "member_host_flavor" {
54+
type = string
55+
description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
56+
default = "multitenant"
57+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
58+
}

examples/basic/version.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ terraform {
66
source = "IBM-Cloud/ibm"
77
version = "1.70.0"
88
}
9+
910
}
1011
}

0 commit comments

Comments
 (0)