Skip to content

Commit f384a29

Browse files
feat: initial release (#1)
1 parent 2854dff commit f384a29

32 files changed

+960
-257
lines changed

README.md

Lines changed: 45 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,93 @@
11
<!-- BEGIN MODULE HOOK -->
22

33
<!-- Update the title to match the module name and add a description -->
4-
# Terraform Modules Template Project
4+
# IBM Cloud Databases for ICD MongoDB module
55
<!-- UPDATE BADGE: Update the link for the following badge-->
6-
[![Incubating (Not yet consumable)](https://img.shields.io/badge/status-Incubating%20(Not%20yet%20consumable)-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
7-
[![Build status](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/actions/workflows/ci.yml/badge.svg)](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/actions/workflows/ci.yml)
6+
[![Stable (With quality checks)](https://img.shields.io/badge/Status-Stable%20(With%20quality%20checks)-green)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
7+
[![Build status](https://github.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/actions/workflows/ci.yml/badge.svg)](https://github.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/actions/workflows/ci.yml)
88
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
9-
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-module-template?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/releases/latest)
9+
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-icd-mongodb?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/releases/latest)
1010
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
1111
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
1212

1313
<!-- Remove the content in this H2 heading after completing the steps -->
1414

15-
## Submit a new module
16-
17-
:+1::tada: Thank you for taking the time to contribute! :tada::+1:
18-
19-
This template repository exists to help you create Terraform modules for IBM Cloud.
20-
21-
The default structure includes the following files:
22-
23-
- `README.md`: A description of the module
24-
- `main.tf`: The logic for the module
25-
- `version.tf`: The required terraform and provider versions
26-
- `variables.tf`: The input variables for the module
27-
- `outputs.tf`: The values that are output from the module
28-
For more information, see [Module structure](https://terraform-ibm-modules.github.io/documentation/#/module-structure) in the project documentation.
29-
30-
You can add other content to support what your module does and how it works. For example, you might add a `scripts/` directory that contains shell scripts that are run by a `local-exec` `null_resource` in the Terraform module.
31-
32-
Follow this process to create and submit a Terraform module.
33-
34-
### Create a repo from this repo template
35-
36-
1. Create a repository from this repository template by clicking `Use this template` in the upper right of the GitHub UI.
37-
&emsp;&emsp;&emsp;&emsp;<br>For more information about creating a repository from a template, see the [GitHub docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
38-
1. Select `terraform-ibm-modules` as the owner.
39-
1. Enter a name for the module in format `terraform-ibm-<NAME>`, where `<NAME>` reflects the type of infrastructure that the module manages.
40-
&emsp;&emsp;&emsp;&emsp;<br>Use hyphens as delimiters for names with multiple words (for example, terraform-ibm-`activity-tracker`).
41-
1. Provide a short description of the module.
42-
&emsp;&emsp;&emsp;&emsp;<br>The description is displayed under the repository name on the [organization page](https://github.com/terraform-ibm-modules) and in the **About** section of the repository. Use the description to help users understand the purpose of your module. For more information, see [module names and descriptions](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions) in the docs.
43-
44-
### Clone the repo and set up your development environment
45-
46-
Locally clone the new repository and set up your development environment by completing the tasks in [Local development setup](https://terraform-ibm-modules.github.io/documentation/#/local-dev-setup) in the project documentation.
47-
48-
### Update the repo name and description in source control
49-
50-
To help make sure that the repo name and description are not changed except through pull requests, they are defined in the `settings.yml` file.
51-
52-
Check to make sure that values are uncommented and correct:
53-
54-
1. Open the [settings.yml](.github/settings.yml) file.
55-
1. If not already updated, uncomment the `name` and `description` properties and set the values to what you specified when you requested the repo.
56-
57-
### Update the Terraform files
58-
59-
Implement the logic for your module by updating the `main.tf`, `version.tf`, `variables.tf`, and `outputs.tf` Terraform files. For more information, see [Creating Terraform on IBM Cloud templates](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-create-tf-config).
60-
61-
### Create examples and tests
62-
63-
Add one or more examples in the `examples` directory that consume your new module, and configure tests for them in the `tests` directory. For more information about tests, see [Tests](https://terraform-ibm-modules.github.io/documentation/#/tests).
64-
65-
### Update the content in the readme file
66-
67-
After you implement the logic for your module and create examples and tests, update this readme file in your repository by following these steps:
68-
69-
1. Update the title heading and add a description about your module.
70-
1. Update the badge links.
71-
1. Remove all the content in this H2 heading section.
72-
1. Complete the [Usage](#usage) and [Required IAM access policies](#required-iam-access-policies) sections. The [Examples](#examples) and [Requirements](#requirements) section are populated by a pre-commit hook.
73-
74-
### Commit your code and submit your module for review
75-
76-
1. Before you commit any code, review [Contributing to the IBM Cloud Terraform modules project](https://terraform-ibm-modules.github.io/documentation/#/contribute-module) in the project documentation.
77-
1. Create a pull request for review.
78-
79-
### Post-merge steps
80-
81-
After the first PR for your module is merged, follow these post-merge steps:
82-
83-
1. Create a PR to enable the upgrade test by removing the `t.Skip` line in `tests/pr_test.go`.
84-
85-
<!-- Remove the content in this previous H2 heading -->
86-
8715
## Usage
8816

89-
<!--
90-
Add an example of the use of the module in the following code block.
17+
:exclamation: **Important:** This module does not support major version upgrades or updates to encryption and backup encryption keys. To upgrade the version, create a new MongoDB instance with the updated version, and follow the steps in [Upgrading to a new major version](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-upgrading) in the IBM Cloud docs.
9118

92-
Use real values instead of "var.<var_name>" or other placeholder values
93-
unless real values don't help users know what to change.
94-
-->
95-
96-
```hcl
19+
```terraform
20+
module "mongodb" {
21+
# replace "master" with a GIT release version to lock into a specific release
22+
source = "git::https://github.ibm.com/GoldenEye/icd-mongodb-module?ref=master"
23+
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX"
24+
region = "us-south"
25+
instance_name = "my-mongodb-instance"
26+
}
9727
9828
```
9929

10030
## Required IAM access policies
10131

102-
<!-- PERMISSIONS REQUIRED TO RUN MODULE
103-
If this module requires permissions, uncomment the following block and update
104-
the sample permissions, following the format.
105-
Replace the sample Account and IBM Cloud service names and roles with the
106-
information in the console at
107-
Manage > Access (IAM) > Access groups > Access policies.
108-
-->
109-
110-
<!--
11132
You need the following permissions to run this module.
11233

11334
- Account Management
114-
- **Sample Account Service** service
115-
- `Editor` platform access
116-
- `Manager` service access
117-
- IAM Services
118-
- **Sample Cloud Service** service
119-
- `Administrator` platform access
120-
-->
121-
122-
<!-- NO PERMISSIONS FOR MODULE
123-
If no permissions are required for the module, uncomment the following
124-
statement instead the previous block.
125-
-->
126-
127-
<!-- No permissions are needed to run this module.-->
35+
- **Databases for MongoDB** service
36+
- `Editor` role access
37+
12838
<!-- END MODULE HOOK -->
12939
<!-- BEGIN EXAMPLES HOOK -->
13040
## Examples
13141

42+
- [ Autoscale example](examples/autoscale)
43+
- [ Encryption example](examples/complete)
13244
- [ Default example](examples/default)
133-
- [ Example that uses existing resources](examples/existing-resources)
134-
- [ Non default example](examples/non-default)
13545
<!-- END EXAMPLES HOOK -->
13646
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
13747
## Requirements
13848

13949
| Name | Version |
14050
|------|---------|
141-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
51+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
52+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.49.0 |
14253

14354
## Modules
14455

14556
No modules.
14657

14758
## Resources
14859

149-
No resources.
60+
| Name | Type |
61+
|------|------|
62+
| [ibm_database.mongodb](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database) | resource |
15063

15164
## Inputs
15265

153-
No inputs.
66+
| Name | Description | Type | Default | Required |
67+
|------|-------------|------|---------|:--------:|
68+
| <a name="input_allowlist"></a> [allowlist](#input\_allowlist) | (Optional, List of Objects) A list of allowed IP addresses for the database. | <pre>list(object({<br> address = string<br> description = string<br> }))</pre> | `[]` | no |
69+
| <a name="input_auto_scaling"></a> [auto\_scaling](#input\_auto\_scaling) | Configure rules to allow your database to automatically increase its resources. Single block of autoscaling is allowed at once. | <pre>object({<br> cpu = object({<br> rate_increase_percent = optional(number)<br> rate_limit_count_per_member = optional(number)<br> rate_period_seconds = optional(number)<br> rate_units = optional(string)<br> })<br> disk = object({<br> capacity_enabled = optional(bool)<br> free_space_less_than_percent = optional(number)<br> io_above_percent = optional(number)<br> io_over_period = optional(string)<br> io_enabled = optional(bool)<br> rate_increase_percent = optional(number)<br> rate_limit_mb_per_member = optional(number)<br> rate_period_seconds = optional(number)<br> rate_units = optional(string)<br> })<br> memory = object({<br> io_above_percent = optional(number)<br> io_enabled = optional(bool)<br> io_over_period = optional(string)<br> rate_increase_percent = optional(number)<br> rate_limit_mb_per_member = optional(number)<br> rate_period_seconds = optional(number)<br> rate_units = optional(string)<br> })<br> })</pre> | <pre>{<br> "cpu": {},<br> "disk": {},<br> "memory": {}<br>}</pre> | no |
70+
| <a name="input_backup_encryption_key_crn"></a> [backup\_encryption\_key\_crn](#input\_backup\_encryption\_key\_crn) | (Optional) The CRN of a key protect key, that you want to use for encrypting disk that holds deployment backups. If null, will use 'key\_protect\_key\_crn' as encryption key. If 'key\_protect\_key\_crn' is also null database is encrypted by using randomly generated keys. | `string` | `null` | no |
71+
| <a name="input_configuration"></a> [configuration](#input\_configuration) | Database Configuration in JSON format. | <pre>object({<br> maxmemory = optional(number)<br> maxmemory-policy = optional(string)<br> appendonly = optional(string)<br> maxmemory-samples = optional(number)<br> stop-writes-on-bgsave-error = optional(string)<br> })</pre> | `null` | no |
72+
| <a name="input_cpu_count"></a> [cpu\_count](#input\_cpu\_count) | Number of CPU cores available to the mongodb instance | `number` | `7` | no |
73+
| <a name="input_disk_mb"></a> [disk\_mb](#input\_disk\_mb) | Disk available to the mongodb instance | `number` | `20480` | no |
74+
| <a name="input_endpoints"></a> [endpoints](#input\_endpoints) | Endpoints available to the mongodb instance (public, private, public-and-private) | `string` | `"private"` | no |
75+
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | Name of the MongoDB instance | `string` | n/a | yes |
76+
| <a name="input_key_protect_key_crn"></a> [key\_protect\_key\_crn](#input\_key\_protect\_key\_crn) | (Optional) The root key CRN of a Key Management Service like Key Protect or Hyper Protect Crypto Service (HPCS) that you want to use for disk encryption. If `null`, database is encrypted by using randomly generated keys. See https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok for current list of supported regions for BYOK | `string` | `null` | no |
77+
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members | `number` | `3` | no |
78+
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Memory available to the mongodb instance | `number` | `1024` | no |
79+
| <a name="input_mongodb_version"></a> [mongodb\_version](#input\_mongodb\_version) | The version of the mongodb to be provisioned | `string` | `null` | no |
80+
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the service plan that you choose for your mongodb instance | `string` | `"standard"` | no |
81+
| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where instance will be created | `string` | `"us-south"` | no |
82+
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The ID of the IMB Cloud resource group where you want to create the instance | `string` | n/a | yes |
83+
| <a name="input_tags"></a> [tags](#input\_tags) | A list of tags that you want to add to your instance | `list(any)` | `[]` | no |
15484

15585
## Outputs
15686

157-
No outputs.
87+
| Name | Description |
88+
|------|-------------|
89+
| <a name="output_id"></a> [id](#output\_id) | mongodb instance id |
90+
| <a name="output_version"></a> [version](#output\_version) | mongodb instance version |
15891
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
15992
<!-- BEGIN CONTRIBUTING HOOK -->
16093

examples/autoscale/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Autoscale example
2+
3+
An end-to-end example that uses the module's default variable values.
4+
5+
This example uses the IBM Cloud Terraform provider to create the following infrastructure:
6+
7+
- A resource group, if one is not passed in.
8+
- An ICD MongoDB database instance with autoscaling enabled (automatically increase resources).

examples/autoscale/main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
##############################################################################
2+
# Resource Group
3+
##############################################################################
4+
5+
module "resource_group" {
6+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.0.5"
7+
# if an existing resource group is not set (null) create a new one using prefix
8+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
9+
existing_resource_group_name = var.resource_group
10+
}
11+
12+
##############################################################################
13+
# ICD mongodb database with auto scale
14+
##############################################################################
15+
module "mongodb" {
16+
source = "../.."
17+
resource_group_id = module.resource_group.resource_group_id
18+
instance_name = "${var.prefix}-mongodb"
19+
region = var.region
20+
tags = var.resource_tags
21+
auto_scaling = var.auto_scaling
22+
}

examples/autoscale/outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# Outputs
3+
##############################################################################
4+
5+
6+
output "id" {
7+
description = "Mongodb instance id"
8+
value = module.mongodb.id
9+
}
10+
11+
output "version" {
12+
description = "Mongodb instance version"
13+
value = module.mongodb.version
14+
}

examples/autoscale/variables.tf

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
variable "ibmcloud_api_key" {
2+
type = string
3+
description = "The IBM Cloud API Key"
4+
sensitive = true
5+
}
6+
7+
variable "region" {
8+
type = string
9+
description = "Region to provision all resources created by this example"
10+
default = "us-south"
11+
}
12+
13+
variable "prefix" {
14+
type = string
15+
description = "Prefix to append to all resources created by this example"
16+
default = "mongodb"
17+
}
18+
19+
variable "resource_group" {
20+
type = string
21+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
22+
default = null
23+
}
24+
25+
variable "resource_tags" {
26+
type = list(string)
27+
description = "Optional list of tags to be added to created resources"
28+
default = []
29+
}
30+
31+
variable "auto_scaling" {
32+
type = object({
33+
cpu = object({
34+
rate_increase_percent = optional(number)
35+
rate_limit_count_per_member = optional(number)
36+
rate_period_seconds = optional(number)
37+
rate_units = optional(string)
38+
})
39+
disk = object({
40+
capacity_enabled = optional(bool)
41+
free_space_less_than_percent = optional(number)
42+
io_above_percent = optional(number)
43+
io_over_period = optional(string)
44+
io_enabled = optional(bool)
45+
rate_increase_percent = optional(number)
46+
rate_limit_mb_per_member = optional(number)
47+
rate_period_seconds = optional(number)
48+
rate_units = optional(string)
49+
})
50+
memory = object({
51+
io_above_percent = optional(number)
52+
io_enabled = optional(bool)
53+
io_over_period = optional(string)
54+
rate_increase_percent = optional(number)
55+
rate_limit_mb_per_member = optional(number)
56+
rate_period_seconds = optional(number)
57+
rate_units = optional(string)
58+
})
59+
})
60+
description = "Configure rules to allow your database to automatically increase its resources. Single block of autoscaling is allowed at once."
61+
default = {
62+
cpu = {
63+
rate_increase_percent = 20
64+
rate_limit_count_per_member = 20
65+
rate_period_seconds = 900
66+
rate_units = "count"
67+
}
68+
disk = {
69+
capacity_enabled = true
70+
free_space_less_than_percent = 15
71+
io_above_percent = 85
72+
io_enabled = true
73+
io_over_period = "15m"
74+
rate_increase_percent = 15
75+
rate_limit_mb_per_member = 3670016
76+
rate_period_seconds = 900
77+
rate_units = "mb"
78+
}
79+
memory = {
80+
io_above_percent = 90
81+
io_enabled = true
82+
io_over_period = "15m"
83+
rate_increase_percent = 10
84+
rate_limit_mb_per_member = 114688
85+
rate_period_seconds = 900
86+
rate_units = "mb"
87+
}
88+
}
89+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.0.0"
2+
required_version = ">= 1.3.0"
33
required_providers {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {

examples/complete/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Encryption example
2+
3+
An example that adds encryption to the [default example](../default/README.md).
4+
5+
This example uses the IBM Cloud Terraform provider to create the following infrastructure:
6+
7+
- A resource group, if one is not passed in.
8+
- An encrypted ICD MongoDB instance with credentials stored in IBM Cloud Secrets Manager.

0 commit comments

Comments
 (0)