diff --git a/.catalog-onboard-pipeline.yaml b/.catalog-onboard-pipeline.yaml index f78ac6e1..6429c8bd 100644 --- a/.catalog-onboard-pipeline.yaml +++ b/.catalog-onboard-pipeline.yaml @@ -6,9 +6,17 @@ offerings: catalog_id: 7df1e4ca-d54c-4fd0-82ce-3d13247308cd offering_id: 39b67380-7bc8-407f-832c-d610afa17d53 variations: - - name: standard + - name: fully-configurable mark_ready: true install_type: fullstack scc: instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37 region: us-south + scope_resource_group_var_name: existing_resource_group_name + - name: security-enforced + mark_ready: true + install_type: fullstack + scc: + instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37 + region: us-south + scope_resource_group_var_name: existing_resource_group_name diff --git a/README.md b/README.md index 8065aca5..a46c5753 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ You need the following permissions to run this module. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.9.0 | -| [ibm](#requirement\_ibm) | >= 1.79.2, < 2.0.0 | +| [ibm](#requirement\_ibm) | >= 1.79.2, <2.0.0 | | [time](#requirement\_time) | >= 0.9.1, < 1.0.0 | ### Modules @@ -75,7 +75,7 @@ You need the following permissions to run this module. | [ibm_iam_authorization_policy.backup_kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource | | [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource | | [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource | -| [ibm_resource_tag.mongodb_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource | +| [ibm_resource_tag.access_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource | | [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [time_sleep.wait_for_backup_kms_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [ibm_database_connection.database_connection](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/database_connection) | data source | @@ -89,7 +89,7 @@ You need the following permissions to run this module. | [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. |
object({
disk = object({
capacity_enabled = optional(bool, false)
free_space_less_than_percent = optional(number, 10)
io_above_percent = optional(number, 90)
io_enabled = optional(bool, false)
io_over_period = optional(string, "15m")
rate_increase_percent = optional(number, 10)
rate_limit_mb_per_member = optional(number, 3670016)
rate_period_seconds = optional(number, 900)
rate_units = optional(string, "mb")
})
memory = object({
io_above_percent = optional(number, 90)
io_enabled = optional(bool, false)
io_over_period = optional(string, "15m")
rate_increase_percent = optional(number, 10)
rate_limit_mb_per_member = optional(number, 114688)
rate_period_seconds = optional(number, 900)
rate_units = optional(string, "mb")
})
}) | `null` | no |
| [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 |
| [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 |
-| [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of context-based restrictions rules to create. | list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
tags = optional(list(object({
name = string
value = string
})))
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
})) | `[]` | no |
+| [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
tags = optional(list(object({
name = string
value = string
})))
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
})) | `[]` | no |
| [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 |
| [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 |
| [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 |
@@ -102,9 +102,9 @@ You need the following permissions to run this module.
| [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |
| [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the MongoDB instance will be created. | `string` | n/a | yes |
| [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 |
-| [service\_endpoints](#input\_service\_endpoints) | The type of endpoint of the database instance. Possible values: `public`, `private`, `public-and-private`. | `string` | `"public"` | no |
+| [service\_endpoints](#input\_service\_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 |
| [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 |
-| [tags](#input\_tags) | Optional list of tags to be added to the MongoDB instance. | `list(any)` | `[]` | no |
+| [tags](#input\_tags) | Optional list of tags to be added to the MongoDB instance. | `list(string)` | `[]` | no |
| [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 |
| [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | IBM Cloud Databases will secure your deployment's data at rest automatically with an encryption key that IBM hold. Alternatively, you may select your own Key Management System instance and encryption key (Key Protect or Hyper Protect Crypto Services) by setting this to false. If setting to false, a value must be passed for the `kms_key_crn` input. | `bool` | `true` | no |
| [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatiely set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. 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). | `bool` | `true` | no |
diff --git a/common-dev-assets b/common-dev-assets
index 1cf0dafd..403ef31b 160000
--- a/common-dev-assets
+++ b/common-dev-assets
@@ -1 +1 @@
-Subproject commit 1cf0dafd08adb8c4450f6110fbb6163efb02f43b
+Subproject commit 403ef31b0757e3b5819313709a12e72c48f4384b
diff --git a/cra-config.yaml b/cra-config.yaml
index fbae9039..94512617 100644
--- a/cra-config.yaml
+++ b/cra-config.yaml
@@ -1,12 +1,12 @@
# More info about this file at https://github.com/terraform-ibm-modules/common-pipeline-assets/blob/main/.github/workflows/terraform-test-pipeline.md#cra-config-yaml
version: "v1"
CRA_TARGETS:
- - CRA_TARGET: "solutions/standard"
- CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json"
- PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
- CRA_ENVIRONMENT_VARIABLES:
+ - CRA_TARGET: "solutions/fully-configurable" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
+ CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json" # CRA Ignore file to use. If not provided, it checks the repo root directory for `cra-tf-validate-ignore-rules.json`
+ PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
+ CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
TF_VAR_existing_kms_instance_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9::"
- TF_VAR_existing_kms_key_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9:key:1368d2eb-3ed0-4a8b-b09c-2155895f01ea"
- TF_VAR_use_existing_resource_group: true
- TF_VAR_resource_group_name: "geretain-test-redis"
+ TF_VAR_existing_resource_group_name: "geretain-test-redis"
+ TF_VAR_kms_encryption_enabled: true
TF_VAR_provider_visibility: "public"
+ TF_VAR_prefix: "test"
diff --git a/ibm_catalog.json b/ibm_catalog.json
index e18769d0..76cfa559 100644
--- a/ibm_catalog.json
+++ b/ibm_catalog.json
@@ -9,6 +9,7 @@
"target_terraform",
"terraform",
"data_management",
+ "database",
"solution"
],
"keywords": [
@@ -22,35 +23,36 @@
"relational"
],
"short_description": "Creates and configures an instance of IBM Cloud Databases for MongoDB.",
- "long_description": "This architecture supports creating and configuring an instance of Databases for MongoDB with KMS encryption.",
+ "long_description": "This architecture supports creating and configuring an instance of [Databases for MongoDB](https://www.ibm.com/products/databases-for-mongodb), with optional KMS encryption. This Terraform-based automation is part of a broader suite of IBM-maintained Infrastructure as Code (IaC) asset collection, each following the naming pattern \"Cloud automation for *servicename*\" and focusing on single IBM Cloud service. These single-service deployable architectures can be used on their own to streamline and automate service deployments through an [IaC approach](https://cloud.ibm.com/docs/secure-enterprise?topic=secure-enterprise-understanding-projects), or assembled together into a broader [automated IaC stack](https://cloud.ibm.com/docs/secure-enterprise?topic=secure-enterprise-config-stack) to automate the deployment of an end-to-end solution architecture.",
"offering_docs_url": "https://github.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/blob/main/README.md",
"offering_icon_url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/main/images/mongodb.svg",
"provider_name": "IBM",
"support_details": "This product is in the community registry, as such support is handled through the originated repo. If you experience issues please open an issue in the repository [https://github.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/issues](https://github.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/issues). Please note this product is not supported via the IBM Cloud Support Center.",
"features": [
{
- "title": "Creates an instance of Databases for MongoDB",
- "description": "Creates and configures an IBM Cloud Databases for MongoDB instance."
+ "title": "KMS encryption",
+ "description": "Provides [KMS encryption](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-key-protect&interface=ui) for the data that you store in the database, enhancing data security."
},
{
- "title": "Supports KMS encryption",
- "description": "Provides KMS encryption for the data that you store in the database."
+ "title": "Autoscaling",
+ "description": "Provides the [autoscaling](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=ui) to allow the database to increase resources in response to usage."
},
{
- "title": "Supports autoscaling",
- "description": "Provides the autoscaling to allow the database to increase resources in response to usage."
+ "title": "Access tags",
+ "description": "Attaches access tags to the MongoDB instance."
},
{
- "title": "Supports backup restoration",
- "description": "Provides database restoration using a backup created by a deployment with the same service ID."
+ "title": "Backup restoration",
+ "description": "Provides [database restoration](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-dashboard-backups&interface=ui) using a backup created by a deployment with the same service ID."
}
],
"flavors": [
{
- "label": "Standard",
- "name": "standard",
+ "label": "Fully configurable",
+ "name": "fully-configurable",
+ "index": 1,
"install_type": "fullstack",
- "working_directory": "solutions/standard",
+ "working_directory": "solutions/fully-configurable",
"compliance": {
"authority": "scc-v3",
"profiles": [
@@ -61,6 +63,13 @@
]
},
"iam_permissions": [
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Viewer"
+ ],
+ "service_name": "Resource group only",
+ "notes": "Viewer access is required in the resource group you want to provision in."
+ },
{
"role_crns": [
"crn:v1:bluemix:public:iam::::role:Editor"
@@ -69,17 +78,24 @@
},
{
"role_crns": [
- "crn:v1:bluemix:public:iam::::serviceRole:Manager",
"crn:v1:bluemix:public:iam::::role:Editor"
],
- "service_name": "kms"
+ "service_name": "kms",
+ "notes": "[Optional] Editor access is required to create keys. It is only required when using Key Protect for encryption."
+ },
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Editor"
+ ],
+ "service_name": "hs-crypto",
+ "notes": "[Optional] Editor access is required to create keys in HPCS. It is only required when using HPCS for encryption."
}
],
"architecture": {
"features": [
{
- "title": " Creates an instance of Databases for MongoDB",
- "description": "This architecture creates an instance of IBM Cloud Databases for MongoDB with KMS encryption. It accepts or creates a resource group, and provides autoscaling rules."
+ "title": " ",
+ "description": "Configured to use IBM secure by default standards, but can be edited to fit your use case."
}
],
"diagrams": [
@@ -99,6 +115,7 @@
},
{
"key": "provider_visibility",
+ "hidden": true,
"options": [
{
"displayname": "private",
@@ -115,21 +132,23 @@
]
},
{
- "key": "use_existing_resource_group"
- },
- {
- "key": "resource_group_name"
+ "key": "existing_resource_group_name",
+ "display_name": "resource_group",
+ "custom_config": {
+ "type": "resource_group",
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "identifier": "rg_name"
+ }
+ }
},
{
"key": "prefix"
},
- {
- "key": "name"
- },
{
"key": "region",
"required": true,
- "default_value": "us-south",
"options": [
{
"displayname": "Chennai (che01)",
@@ -183,13 +202,8 @@
},
{
"key": "mongodb_version",
- "required": false,
- "default_value": "__NULL__",
+ "required": true,
"options": [
- {
- "displayname": "preferred",
- "value": "__NULL__"
- },
{
"displayname": "6.0",
"value": "6.0"
@@ -203,65 +217,144 @@
{
"key": "plan"
},
+ {
+ "key": "name"
+ },
+ {
+ "key": "resource_tags",
+ "type": "array",
+ "custom_config": {
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "key": "access_tags",
+ "type": "array",
+ "custom_config": {
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "type": "string"
+ }
+ }
+ },
{
"key": "members"
},
{
- "key": "memory_mb"
+ "key": "member_memory_mb"
},
{
- "key": "cpu_count"
+ "key": "member_cpu_count"
},
{
- "key": "disk_mb"
+ "key": "member_disk_mb"
},
{
"key": "member_host_flavor"
},
+ {
+ "key": "auto_scaling"
+ },
+ {
+ "key": "service_endpoints",
+ "options": [
+ {
+ "displayname": "private",
+ "value": "private"
+ },
+ {
+ "displayname": "public",
+ "value": "public"
+ },
+ {
+ "displayname": "public-and-private",
+ "value": "public-and-private"
+ }
+ ]
+ },
{
"key": "service_credential_names"
},
{
- "key": "admin_pass"
+ "key": "service_credential_secrets",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
},
{
- "key": "admin_pass_secrets_manager_secret_group"
+ "key": "admin_pass"
},
{
- "key": "admin_pass_secrets_manager_secret_name"
+ "key": "existing_secrets_manager_instance_crn"
},
{
- "key": "existing_mongodb_instance_crn"
+ "key": "existing_secrets_manager_endpoint_type",
+ "hidden": true,
+ "options": [
+ {
+ "displayname": "public",
+ "value": "public"
+ },
+ {
+ "displayname": "private",
+ "value": "private"
+ }
+ ]
},
{
- "key": "use_existing_admin_pass_secrets_manager_secret_group"
+ "key": "skip_mongodb_secrets_manager_auth_policy"
},
{
- "key": "users"
+ "key": "admin_pass_secrets_manager_secret_group"
},
{
- "key": "tags"
+ "key": "admin_pass_secrets_manager_secret_name"
},
{
- "key": "access_tags"
+ "key": "use_existing_admin_pass_secrets_manager_secret_group"
},
{
- "key": "use_ibm_owned_encryption_key"
+ "key": "users",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
},
{
- "key": "existing_kms_instance_crn"
+ "key": "ibmcloud_kms_api_key"
},
{
- "key": "existing_kms_key_crn"
+ "key": "kms_encryption_enabled"
},
{
- "key": "kms_endpoint_type"
+ "key": "existing_kms_instance_crn"
},
{
- "key": "skip_mongodb_kms_auth_policy"
+ "key": "existing_kms_key_crn"
},
{
- "key": "ibmcloud_kms_api_key"
+ "key": "kms_endpoint_type",
+ "hidden": true,
+ "options": [
+ {
+ "displayname": "public",
+ "value": "public"
+ },
+ {
+ "displayname": "private",
+ "value": "private"
+ }
+ ]
},
{
"key": "key_ring_name"
@@ -269,29 +362,284 @@
{
"key": "key_name"
},
+ {
+ "key": "backup_crn"
+ },
{
"key": "existing_backup_kms_key_crn"
},
{
"key": "use_default_backup_encryption_key"
},
+ {
+ "key": "skip_mongodb_kms_auth_policy"
+ },
+ {
+ "key": "existing_mongodb_instance_crn"
+ }
+ ]
+ },
+ {
+ "label": "Security-enforced",
+ "name": "security-enforced",
+ "index": 2,
+ "install_type": "fullstack",
+ "working_directory": "solutions/security-enforced",
+ "compliance": {
+ "authority": "scc-v3",
+ "profiles": [
+ {
+ "profile_name": "IBM Cloud Framework for Financial Services",
+ "profile_version": "1.7.0"
+ }
+ ]
+ },
+ "iam_permissions": [
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Viewer"
+ ],
+ "service_name": "Resource group only",
+ "notes": "Viewer access is required in the resource group you want to provision in."
+ },
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Editor"
+ ],
+ "service_name": "databases-for-mongodb"
+ },
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Editor"
+ ],
+ "service_name": "kms",
+ "notes": "[Optional] Editor access is required to create keys. It is required only if KMS encryption is enabled."
+ },
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Editor"
+ ],
+ "service_name": "hs-crypto",
+ "notes": "[Optional] Editor access is required to create keys in HPCS. It is only required when using HPCS for encryption."
+ }
+ ],
+ "architecture": {
+ "features": [
+ {
+ "title": " ",
+ "description": "Configured to use IBM secure by default standards that can't be changed."
+ }
+ ],
+ "diagrams": [
+ {
+ "diagram": {
+ "caption": "Databases for MongoDB instance on IBM Cloud",
+ "url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-icd-mongodb/main/reference-architecture/deployable-architecture-mongodb.svg",
+ "type": "image/svg+xml"
+ },
+ "description": "This architecture supports creating and configuring an instance of Databases for MongoDB instance with KMS encryption."
+ }
+ ]
+ },
+ "configuration": [
+ {
+ "key": "ibmcloud_api_key"
+ },
+ {
+ "key": "existing_resource_group_name",
+ "display_name": "resource_group",
+ "custom_config": {
+ "type": "resource_group",
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "identifier": "rg_name"
+ }
+ }
+ },
+ {
+ "key": "prefix"
+ },
+ {
+ "key": "region",
+ "required": true,
+ "options": [
+ {
+ "displayname": "Chennai (che01)",
+ "value": "che01"
+ },
+ {
+ "displayname": "Dallas (us-south)",
+ "value": "us-south"
+ },
+ {
+ "displayname": "Frankfurt (eu-de)",
+ "value": "eu-de"
+ },
+ {
+ "displayname": "London (eu-gb)",
+ "value": "eu-gb"
+ },
+ {
+ "displayname": "Madrid (eu-es)",
+ "value": "eu-es"
+ },
+ {
+ "displayname": "Osaka (jp-osa)",
+ "value": "jp-osa"
+ },
+ {
+ "displayname": "Paris (par01)",
+ "value": "par01"
+ },
+ {
+ "displayname": "Sao Paulo (br-sao)",
+ "value": "br-sao"
+ },
+ {
+ "displayname": "Sydney (au-syd)",
+ "value": "au-syd"
+ },
+ {
+ "displayname": "Toronto (ca-tor)",
+ "value": "ca-tor"
+ },
+ {
+ "displayname": "Tokyo (jp-tok)",
+ "value": "jp-tok"
+ },
+ {
+ "displayname": "Washington (us-east)",
+ "value": "us-east"
+ }
+ ]
+ },
+ {
+ "key": "mongodb_version",
+ "required": true,
+ "options": [
+ {
+ "displayname": "6.0",
+ "value": "6.0"
+ },
+ {
+ "displayname": "7.0",
+ "value": "7.0"
+ }
+ ]
+ },
+ {
+ "key": "plan"
+ },
+ {
+ "key": "name"
+ },
+ {
+ "key": "resource_tags",
+ "type": "array",
+ "custom_config": {
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "key": "access_tags",
+ "type": "array",
+ "custom_config": {
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "key": "members"
+ },
+ {
+ "key": "member_memory_mb"
+ },
+ {
+ "key": "member_cpu_count"
+ },
+ {
+ "key": "member_disk_mb"
+ },
+ {
+ "key": "member_host_flavor"
+ },
{
"key": "auto_scaling"
},
{
- "key": "backup_crn"
+ "key": "service_credential_names"
},
{
- "key": "existing_secrets_manager_instance_crn"
+ "key": "service_credential_secrets",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
},
{
- "key": "existing_secrets_manager_endpoint_type"
+ "key": "admin_pass"
},
{
- "key": "service_credential_secrets"
+ "key": "existing_secrets_manager_instance_crn"
},
{
"key": "skip_mongodb_secrets_manager_auth_policy"
+ },
+ {
+ "key": "admin_pass_secrets_manager_secret_group"
+ },
+ {
+ "key": "admin_pass_secrets_manager_secret_name"
+ },
+ {
+ "key": "use_existing_admin_pass_secrets_manager_secret_group"
+ },
+ {
+ "key": "users",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
+ },
+ {
+ "key": "ibmcloud_kms_api_key"
+ },
+ {
+ "key": "existing_kms_instance_crn",
+ "required": true
+ },
+ {
+ "key": "existing_kms_key_crn"
+ },
+ {
+ "key": "key_ring_name"
+ },
+ {
+ "key": "key_name"
+ },
+ {
+ "key": "backup_crn"
+ },
+ {
+ "key": "existing_backup_kms_key_crn"
+ },
+ {
+ "key": "skip_mongodb_kms_auth_policy"
+ },
+ {
+ "key": "existing_mongodb_instance_crn"
}
]
}
diff --git a/main.tf b/main.tf
index 3b370ee9..1e3b6251 100644
--- a/main.tf
+++ b/main.tf
@@ -1,13 +1,10 @@
-##############################################################################
-# ICD MongoDB module
-##############################################################################
-
-
########################################################################################################################
# Locals
########################################################################################################################
locals {
+ # If no value passed for 'backup_encryption_key_crn' use the value of 'kms_key_crn' and perform validation of 'kms_key_crn' to check if region is supported by backup encryption key.
+
# If 'use_ibm_owned_encryption_key' is true or 'use_default_backup_encryption_key' is true, default to null.
# If no value is passed for 'backup_encryption_key_crn', then default to use 'kms_key_crn'.
backup_encryption_key_crn = var.use_ibm_owned_encryption_key || var.use_default_backup_encryption_key ? null : (var.backup_encryption_key_crn != null ? var.backup_encryption_key_crn : var.kms_key_crn)
@@ -163,14 +160,14 @@ resource "time_sleep" "wait_for_backup_kms_authorization_policy" {
resource "ibm_database" "mongodb" {
depends_on = [time_sleep.wait_for_authorization_policy, time_sleep.wait_for_backup_kms_authorization_policy]
name = var.name
- location = var.region
plan = var.plan
+ location = var.region
service = "databases-for-mongodb"
version = var.mongodb_version
resource_group_id = var.resource_group_id
- adminpassword = var.admin_pass
- tags = var.tags
service_endpoints = var.service_endpoints
+ tags = var.tags
+ adminpassword = var.admin_pass
key_protect_key = var.kms_key_crn
backup_encryption_key_crn = local.backup_encryption_key_crn
backup_id = var.backup_crn
@@ -247,7 +244,6 @@ resource "ibm_database" "mongodb" {
}
}
-
## This for_each block is NOT a loop to attach to multiple auto_scaling blocks.
## This block is only used to conditionally add auto_scaling block depending on var.auto_scaling
dynamic "auto_scaling" {
@@ -292,7 +288,7 @@ resource "ibm_database" "mongodb" {
}
}
-resource "ibm_resource_tag" "mongodb_tag" {
+resource "ibm_resource_tag" "access_tag" {
count = length(var.access_tags) == 0 ? 0 : 1
resource_id = ibm_database.mongodb.resource_crn
tags = var.access_tags
diff --git a/outputs.tf b/outputs.tf
index 96371861..12eee8f3 100644
--- a/outputs.tf
+++ b/outputs.tf
@@ -7,26 +7,21 @@ output "id" {
value = ibm_database.mongodb.id
}
-output "guid" {
- description = "MongoDB instance guid"
- value = ibm_database.mongodb.guid
-}
-
output "version" {
description = "MongoDB instance version"
value = ibm_database.mongodb.version
}
+output "guid" {
+ description = "MongoDB instance guid"
+ value = ibm_database.mongodb.guid
+}
+
output "crn" {
description = "MongoDB instance crn"
value = ibm_database.mongodb.resource_crn
}
-output "cbr_rule_ids" {
- description = "CBR rule ids created to restrict MongoDB"
- value = module.cbr_rule[*].rule_id
-}
-
output "service_credentials_json" {
description = "Service credentials json map"
value = local.service_credentials_json
@@ -39,6 +34,11 @@ output "service_credentials_object" {
sensitive = true
}
+output "cbr_rule_ids" {
+ description = "CBR rule ids created to restrict MongoDB"
+ value = module.cbr_rule[*].rule_id
+}
+
output "adminuser" {
description = "Database admin user name"
value = ibm_database.mongodb.adminuser
diff --git a/reference-architecture/deployable-architecture-mongodb.svg b/reference-architecture/deployable-architecture-mongodb.svg
index 9e1a3b0d..399acad1 100644
--- a/reference-architecture/deployable-architecture-mongodb.svg
+++ b/reference-architecture/deployable-architecture-mongodb.svg
@@ -1,4 +1,4 @@
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/solutions/standard/DA-types.md b/solutions/fully-configurable/DA-types.md
similarity index 100%
rename from solutions/standard/DA-types.md
rename to solutions/fully-configurable/DA-types.md
diff --git a/solutions/fully-configurable/README.md b/solutions/fully-configurable/README.md
new file mode 100644
index 00000000..81d156c0
--- /dev/null
+++ b/solutions/fully-configurable/README.md
@@ -0,0 +1,3 @@
+# Cloud automation for MongoDB (Fully configurable)
+
+:exclamation: **Important:** This solution is not intended to be called by other modules because it contains a provider configuration and is not compatible with the `for_each`, `count`, and `depends_on` arguments. For more information, see [Providers Within Modules](https://developer.hashicorp.com/terraform/language/modules/develop/providers).
diff --git a/solutions/fully-configurable/catalogValidationValues.json.template b/solutions/fully-configurable/catalogValidationValues.json.template
new file mode 100644
index 00000000..36858b29
--- /dev/null
+++ b/solutions/fully-configurable/catalogValidationValues.json.template
@@ -0,0 +1,9 @@
+{
+ "ibmcloud_api_key": $VALIDATION_APIKEY,
+ "region": "us-south",
+ "resource_tags": $TAGS,
+ "name": $PREFIX,
+ "existing_resource_group_name": "geretain-test-mongo",
+ "existing_kms_instance_crn": $HPCS_US_SOUTH_CRN,
+ "kms_encryption_enabled": true
+}
diff --git a/solutions/standard/main.tf b/solutions/fully-configurable/main.tf
similarity index 80%
rename from solutions/standard/main.tf
rename to solutions/fully-configurable/main.tf
index da027a1a..a663553a 100644
--- a/solutions/standard/main.tf
+++ b/solutions/fully-configurable/main.tf
@@ -1,12 +1,14 @@
#######################################################################################################################
# Resource Group
#######################################################################################################################
+locals {
+ prefix = var.prefix != null ? trimspace(var.prefix) != "" ? "${var.prefix}-" : "" : ""
+}
module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.2.0"
- resource_group_name = var.use_existing_resource_group == false ? ((var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.resource_group_name}" : var.resource_group_name) : null
- existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null
+ existing_resource_group_name = var.existing_resource_group_name
}
#######################################################################################################################
@@ -14,9 +16,14 @@ module "resource_group" {
#######################################################################################################################
locals {
- create_new_kms_key = var.existing_mongodb_instance_crn == null && !var.use_ibm_owned_encryption_key && var.existing_kms_key_crn == null ? true : false # no need to create any KMS resources if passing an existing key, or using IBM owned keys
- mongodb_key_name = var.prefix != null ? "${var.prefix}-${var.key_name}" : var.key_name
- mongodb_key_ring_name = var.prefix != null ? "${var.prefix}-${var.key_ring_name}" : var.key_ring_name
+ use_ibm_owned_encryption_key = !var.kms_encryption_enabled
+ create_new_kms_key = (
+ var.kms_encryption_enabled &&
+ var.existing_mongodb_instance_crn == null &&
+ var.existing_kms_key_crn == null
+ )
+ mongodb_key_name = "${local.prefix}${var.key_name}"
+ mongodb_key_ring_name = "${local.prefix}${var.key_ring_name}"
}
module "kms" {
@@ -41,7 +48,7 @@ module "kms" {
standard_key = false
rotation_interval_month = 3
dual_auth_delete_enabled = false
- force_delete = true
+ force_delete = true # Force delete must be set to true, or the terraform destroy will fail since the service does not de-register itself from the key until the reclamation period has expired.
}
]
}
@@ -85,23 +92,23 @@ data "ibm_iam_account_settings" "iam_account_settings" {
locals {
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
- create_cross_account_kms_auth_policy = var.existing_mongodb_instance_crn == null && var.ibmcloud_kms_api_key != null && !var.use_ibm_owned_encryption_key
- create_cross_account_backup_kms_auth_policy = var.existing_mongodb_instance_crn == null && var.ibmcloud_kms_api_key != null && !var.use_ibm_owned_encryption_key && var.existing_backup_kms_key_crn != null
+ create_cross_account_kms_auth_policy = var.kms_encryption_enabled && var.existing_mongodb_instance_crn == null && var.ibmcloud_kms_api_key != null
+ create_cross_account_backup_kms_auth_policy = var.kms_encryption_enabled && var.existing_mongodb_instance_crn == null && var.ibmcloud_kms_api_key != null && var.existing_backup_kms_key_crn != null
- # If KMS encryption enabled (and existing ES instance is not being passed), parse details from the existing key if being passed, otherwise get it from the key that the DA creates
- kms_account_id = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].account_id : module.kms_instance_crn_parser[0].account_id
- kms_service = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].service_name : module.kms_instance_crn_parser[0].service_name
- kms_instance_guid = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].service_instance : module.kms_instance_crn_parser[0].service_instance
- kms_key_crn = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_kms_key_crn != null ? var.existing_kms_key_crn : module.kms[0].keys[format("%s.%s", local.mongodb_key_ring_name, local.mongodb_key_name)].crn
- kms_key_id = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].resource : module.kms[0].keys[format("%s.%s", local.mongodb_key_ring_name, local.mongodb_key_name)].key_id
- kms_region = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].region : module.kms_instance_crn_parser[0].region
+ # If KMS encryption enabled (and existing MongoDB instance is not being passed), parse details from the existing key if being passed, otherwise get it from the key that the DA creates
+ kms_account_id = !var.kms_encryption_enabled || var.existing_mongodb_instance_crn != null ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].account_id : module.kms_instance_crn_parser[0].account_id
+ kms_service = !var.kms_encryption_enabled || var.existing_mongodb_instance_crn != null ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].service_name : module.kms_instance_crn_parser[0].service_name
+ kms_instance_guid = !var.kms_encryption_enabled || var.existing_mongodb_instance_crn != null ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].service_instance : module.kms_instance_crn_parser[0].service_instance
+ kms_key_crn = !var.kms_encryption_enabled || var.existing_mongodb_instance_crn != null ? null : var.existing_kms_key_crn != null ? var.existing_kms_key_crn : module.kms[0].keys[format("%s.%s", local.mongodb_key_ring_name, local.mongodb_key_name)].crn
+ kms_key_id = !var.kms_encryption_enabled || var.existing_mongodb_instance_crn != null ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].resource : module.kms[0].keys[format("%s.%s", local.mongodb_key_ring_name, local.mongodb_key_name)].key_id
+ kms_region = !var.kms_encryption_enabled || var.existing_mongodb_instance_crn != null ? null : var.existing_kms_key_crn != null ? module.kms_key_crn_parser[0].region : module.kms_instance_crn_parser[0].region
# If creating KMS cross account policy for backups, parse backup key details from passed in key CRN
backup_kms_account_id = local.create_cross_account_backup_kms_auth_policy ? module.kms_backup_key_crn_parser[0].account_id : local.kms_account_id
backup_kms_service = local.create_cross_account_backup_kms_auth_policy ? module.kms_backup_key_crn_parser[0].service_name : local.kms_service
backup_kms_instance_guid = local.create_cross_account_backup_kms_auth_policy ? module.kms_backup_key_crn_parser[0].service_instance : local.kms_instance_guid
backup_kms_key_id = local.create_cross_account_backup_kms_auth_policy ? module.kms_backup_key_crn_parser[0].resource : local.kms_key_id
- backup_kms_key_crn = var.existing_mongodb_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_backup_kms_key_crn
+ backup_kms_key_crn = var.existing_mongodb_instance_crn != null || local.use_ibm_owned_encryption_key ? null : var.existing_backup_kms_key_crn
# Always use same key for backups unless user explicially passed a value for 'existing_backup_kms_key_crn'
use_same_kms_key_for_backups = var.existing_backup_kms_key_crn == null ? true : false
}
@@ -219,7 +226,7 @@ locals {
# if - replace first char with J
# elseif _ replace first char with K
# else use asis
- generated_admin_password = startswith(random_password.admin_password[0].result, "-") ? "J${substr(random_password.admin_password[0].result, 1, -1)}" : startswith(random_password.admin_password[0].result, "_") ? "K${substr(random_password.admin_password[0].result, 1, -1)}" : random_password.admin_password[0].result
+ generated_admin_password = (length(random_password.admin_password) > 0 ? (startswith(random_password.admin_password[0].result, "-") ? "J${substr(random_password.admin_password[0].result, 1, -1)}" : startswith(random_password.admin_password[0].result, "_") ? "K${substr(random_password.admin_password[0].result, 1, -1)}" : random_password.admin_password[0].result) : null)
# admin password to use
admin_pass = var.admin_pass == null ? local.generated_admin_password : var.admin_pass
}
@@ -269,31 +276,32 @@ data "ibm_database_connection" "existing_connection" {
# Create new instance
module "mongodb" {
count = var.existing_mongodb_instance_crn != null ? 0 : 1
- source = "../../modules/fscloud"
+ source = "../.."
depends_on = [time_sleep.wait_for_authorization_policy, time_sleep.wait_for_backup_kms_authorization_policy]
resource_group_id = module.resource_group.resource_group_id
- name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.name}" : var.name
+ name = "${local.prefix}${var.name}"
plan = var.plan
region = var.region
mongodb_version = var.mongodb_version
- skip_iam_authorization_policy = var.skip_mongodb_kms_auth_policy
- use_ibm_owned_encryption_key = var.use_ibm_owned_encryption_key
+ skip_iam_authorization_policy = var.kms_encryption_enabled ? var.skip_mongodb_kms_auth_policy : true
+ use_ibm_owned_encryption_key = local.use_ibm_owned_encryption_key
kms_key_crn = local.kms_key_crn
backup_encryption_key_crn = local.backup_kms_key_crn
use_same_kms_key_for_backups = local.use_same_kms_key_for_backups
use_default_backup_encryption_key = var.use_default_backup_encryption_key
access_tags = var.access_tags
- tags = var.tags
+ tags = var.resource_tags
admin_pass = local.admin_pass
users = var.users
members = var.members
member_host_flavor = var.member_host_flavor
- memory_mb = var.memory_mb
- disk_mb = var.disk_mb
- cpu_count = var.cpu_count
+ memory_mb = var.member_memory_mb
+ disk_mb = var.member_disk_mb
+ cpu_count = var.member_cpu_count
auto_scaling = var.auto_scaling
service_credential_names = var.service_credential_names
backup_crn = var.backup_crn
+ service_endpoints = var.service_endpoints
}
locals {
@@ -324,7 +332,6 @@ module "secrets_manager_instance_crn_parser" {
# create a service authorization between Secrets Manager and the target service (Databases for MongoDB)
resource "ibm_iam_authorization_policy" "secrets_manager_key_manager" {
count = local.create_secrets_manager_auth_policy
- depends_on = [module.mongodb]
source_service_name = "secrets-manager"
source_resource_instance_id = local.existing_secrets_manager_instance_guid
target_service_name = "databases-for-mongodb"
@@ -365,10 +372,10 @@ locals {
# Build the structure of the arbitrary credential type secret for admin password
admin_pass_secret = [{
- secret_group_name = (var.prefix != null && var.prefix != "") && var.admin_pass_secrets_manager_secret_group != null ? "${var.prefix}-${var.admin_pass_secrets_manager_secret_group}" : var.admin_pass_secrets_manager_secret_group
+ secret_group_name = "${local.prefix}${var.admin_pass_secrets_manager_secret_group}"
existing_secret_group = var.use_existing_admin_pass_secrets_manager_secret_group
secrets = [{
- secret_name = (var.prefix != null && var.prefix != "") && var.admin_pass_secrets_manager_secret_name != null ? "${var.prefix}-${var.admin_pass_secrets_manager_secret_name}" : var.admin_pass_secrets_manager_secret_name
+ secret_name = "${local.prefix}${var.admin_pass_secrets_manager_secret_name}"
secret_type = "arbitrary"
secret_payload_password = local.admin_pass
}
diff --git a/solutions/standard/outputs.tf b/solutions/fully-configurable/outputs.tf
similarity index 100%
rename from solutions/standard/outputs.tf
rename to solutions/fully-configurable/outputs.tf
diff --git a/solutions/fully-configurable/provider.tf b/solutions/fully-configurable/provider.tf
new file mode 100644
index 00000000..e66dac2c
--- /dev/null
+++ b/solutions/fully-configurable/provider.tf
@@ -0,0 +1,14 @@
+provider "ibm" {
+ ibmcloud_api_key = var.ibmcloud_api_key
+ region = var.region
+ visibility = var.provider_visibility
+ private_endpoint_type = (var.provider_visibility == "private" && var.region == "ca-mon") ? "vpe" : null
+}
+
+provider "ibm" {
+ alias = "kms"
+ ibmcloud_api_key = var.ibmcloud_kms_api_key != null ? var.ibmcloud_kms_api_key : var.ibmcloud_api_key
+ region = local.kms_region
+ visibility = var.provider_visibility
+ private_endpoint_type = (var.provider_visibility == "private" && var.region == "ca-mon") ? "vpe" : null
+}
diff --git a/solutions/standard/variables.tf b/solutions/fully-configurable/variables.tf
similarity index 69%
rename from solutions/standard/variables.tf
rename to solutions/fully-configurable/variables.tf
index 585da345..cc668cb0 100644
--- a/solutions/standard/variables.tf
+++ b/solutions/fully-configurable/variables.tf
@@ -7,21 +7,39 @@ variable "ibmcloud_api_key" {
description = "The IBM Cloud API key to deploy resources."
sensitive = true
}
-variable "use_existing_resource_group" {
- type = bool
- description = "Whether to use an existing resource group."
- default = false
-}
-variable "resource_group_name" {
+variable "existing_resource_group_name" {
type = string
- description = "The name of a new or an existing resource group to provision the Databases for MongoDB in. If a prefix input variable is specified, the prefix is added to the name in the `