diff --git a/.catalog-onboard-pipeline.yaml b/.catalog-onboard-pipeline.yaml index 9a791ad9..7cb4fa35 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: 7ee5876d-6e30-49d1-be25-259a442085e8 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/.secrets.baseline b/.secrets.baseline index a933ea3d..88ee2d53 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.sum|^.secrets.baseline$", "lines": null }, - "generated_at": "2025-03-02T09:01:42Z", + "generated_at": "2025-06-24T13:00:25Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -87,7 +87,7 @@ "verified_result": null } ], - "solutions/standard/DA-types.md": [ + "solutions/fully-configurable/DA-types.md": [ { "hashed_secret": "44cdfc3615970ada14420caaaa5c5745fca06002", "is_secret": false, @@ -104,6 +104,16 @@ "type": "Secret Keyword", "verified_result": null } + ], + "tests/pr_test.go": [ + { + "hashed_secret": "8c7c51db5075ebd0369c51e9f14737d9b4c1c21d", + "is_secret": false, + "is_verified": false, + "line_number": 353, + "type": "Base64 High Entropy String", + "verified_result": null + } ] }, "version": "0.13.1+ibm.62.dss", diff --git a/README.md b/README.md index bb2b53cc..7bf50d57 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,9 @@ You need the following permissions to run this module. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.9.0 | -| [ibm](#requirement\_ibm) | >= 1.70.0, <2.0.0 | +| [ibm](#requirement\_ibm) | >= 1.79.2, <2.0.0 | | [null](#requirement\_null) | >= 3.2.1, < 4.0.0 | -| [time](#requirement\_time) | >= 0.9.1 | +| [time](#requirement\_time) | >= 0.9.1, < 1.0.0 | ### Modules @@ -76,16 +76,16 @@ You need the following permissions to run this module. | Name | Type | |------|------| -| [ibm_database.elasticsearch](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/database) | resource | -| [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.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.elasticsearch_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource | +| [ibm_database.elasticsearch](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database) | resource | +| [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.elasticsearch_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource | | [null_resource.put_vectordb_model](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [null_resource.start_vectordb_model](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | 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 | +| [ibm_database_connection.database_connection](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/database_connection) | data source | ### Inputs @@ -97,15 +97,15 @@ You need the following permissions to run this module. | [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 both provisioning is complete and the new deployment that uses that data starts. Specify a backup CRN is in the format `crn:v1:<...>:backup:`. If not specified, 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
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
})) | `[]` | no |
+| [cpu\_count](#input\_cpu\_count) | The dedicated CPU per member that is allocated. For shared CPU, set to 0. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling). | `number` | `0` | no |
+| [disk\_mb](#input\_disk\_mb) | The disk that is allocated per member. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling). | `number` | `5120` | no |
| [elasticsearch\_version](#input\_elasticsearch\_version) | The version of Databases for Elasticsearch to deploy. Possible values: `8.7`, `8.10`, `8.12`, `8.15` which requires an Enterprise Platinum pricing plan. If no value is specified, the current preferred version for IBM Cloud Databases is used. | `string` | `null` | no |
| [elser\_model\_type](#input\_elser\_model\_type) | Trained ELSER model to be used for Elastic's Natural Language Processing. Possible values: `.elser_model_1`, `.elser_model_2` and `.elser_model_2_linux-x86_64`. Applies only if also 'plan' is set to 'platinum'. [Learn more](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-elser.html) | `string` | `".elser_model_2_linux-x86_64"` | no |
| [enable\_elser\_model](#input\_enable\_elser\_model) | Set it to true to install and start the Elastic's Natural Language Processing model. Applies only if also 'plan' is set to 'platinum'. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-elser-embeddings-elasticsearch) | `bool` | `false` | 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 |
-| [member\_cpu\_count](#input\_member\_cpu\_count) | The dedicated CPU per member that is allocated. For shared CPU, set to 0. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling). | `number` | `0` | no |
-| [member\_disk\_mb](#input\_member\_disk\_mb) | The disk that is allocated per member. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling). | `number` | `5120` | no |
| [member\_host\_flavor](#input\_member\_host\_flavor) | The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). | `string` | `null` | no |
-| [member\_memory\_mb](#input\_member\_memory\_mb) | The memory per member that is allocated. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling) | `number` | `4096` | no |
| [members](#input\_members) | The number of members that are allocated. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling). | `number` | `3` | no |
+| [memory\_mb](#input\_memory\_mb) | The memory per member that is allocated. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling) | `number` | `4096` | no |
| [name](#input\_name) | The name of the Databases for Elasticsearch instance. | `string` | n/a | yes |
| [plan](#input\_plan) | The pricing plan for the Databases for Elasticsearch instance. Must be `enterprise` or `platinum` if the `elasticsearch_version` variable is set to `8.10` or later. | `string` | `"enterprise"` | no |
| [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |
diff --git a/common-dev-assets b/common-dev-assets
index d0c2b2a1..b76eee7e 160000
--- a/common-dev-assets
+++ b/common-dev-assets
@@ -1 +1 @@
-Subproject commit d0c2b2a1d3cdf41f6a844bc17816199fe3f8b20f
+Subproject commit b76eee7ec33d5b81b30828e37a02d2df595e0909
diff --git a/cra-config.yaml b/cra-config.yaml
index 8a1d6b57..b87cc8be 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" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
+ - 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:
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:76170fae-4e0c-48c3-8ebe-326059ebb533"
+ TF_VAR_existing_resource_group_name: "geretain-test-elasticsearch"
+ TF_VAR_kms_encryption_enabled: true
TF_VAR_provider_visibility: "public"
- TF_VAR_resource_group_name: "test-es-cra"
- TF_VAR_use_existing_resource_group: false
+ TF_VAR_prefix: "test"
diff --git a/examples/backup-restore/version.tf b/examples/backup-restore/version.tf
index 6f39952e..b211acf0 100644
--- a/examples/backup-restore/version.tf
+++ b/examples/backup-restore/version.tf
@@ -5,7 +5,7 @@ terraform {
# module's version.tf (basic example), and 1 example that will always use the latest provider version (complete example).
ibm = {
source = "IBM-Cloud/ibm"
- version = ">=1.70.0, <2.0.0"
+ version = ">=1.79.2, <2.0.0"
}
}
}
diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf
index 18b25c7e..3f0e4007 100644
--- a/examples/basic/variables.tf
+++ b/examples/basic/variables.tf
@@ -50,6 +50,7 @@ variable "service_endpoints" {
error_message = "Valid values for service_endpoints are 'public', 'public-and-private', and 'private'"
}
}
+
variable "member_host_flavor" {
type = string
description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
diff --git a/examples/basic/version.tf b/examples/basic/version.tf
index 509f9700..5677e7b1 100644
--- a/examples/basic/version.tf
+++ b/examples/basic/version.tf
@@ -4,7 +4,7 @@ terraform {
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
ibm = {
source = "IBM-Cloud/ibm"
- version = "1.70.0"
+ version = "1.79.2"
}
# The elasticsearch provider is not actually required by the module itself, just this example, so OK to use ">=" here instead of locking into a version
elasticsearch = {
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 60b6b53d..22d70de8 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -80,7 +80,7 @@ module "icd_elasticsearch" {
tags = var.resource_tags
auto_scaling = var.auto_scaling
member_host_flavor = "multitenant"
- member_memory_mb = 4096
+ memory_mb = 4096
# Example of how to use different KMS keys for data and backups
use_ibm_owned_encryption_key = false
diff --git a/examples/complete/version.tf b/examples/complete/version.tf
index c07b9389..3f0c1bab 100644
--- a/examples/complete/version.tf
+++ b/examples/complete/version.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
- version = ">=1.70.0, <2.0.0"
+ version = ">=1.79.2, <2.0.0"
}
}
}
diff --git a/examples/fscloud/version.tf b/examples/fscloud/version.tf
index cdc76d38..03d8bdf3 100644
--- a/examples/fscloud/version.tf
+++ b/examples/fscloud/version.tf
@@ -4,7 +4,7 @@ terraform {
# Use latest version of provider in non-basic examples to verify latest version works with module
ibm = {
source = "IBM-Cloud/ibm"
- version = ">= 1.70.0"
+ version = ">= 1.79.2"
}
}
}
diff --git a/ibm_catalog.json b/ibm_catalog.json
index b6bc40dd..d108f771 100644
--- a/ibm_catalog.json
+++ b/ibm_catalog.json
@@ -9,6 +9,7 @@
"target_terraform",
"terraform",
"data_management",
+ "database",
"solution"
],
"keywords": [
@@ -22,61 +23,79 @@
"nosql"
],
"short_description": "Creates and configures an instance of IBM Cloud Databases for Elasticsearch.",
- "long_description": "This architecture supports creating and configuring an instance of Databases for Elasticsearch with KMS encryption.",
+ "long_description": "This architecture supports creating and configuring an instance of [Databases for Elasticsearch](https://www.ibm.com/products/databases-for-elasticsearch), with optional KMS encryption.\n\nℹ️ This Terraform-based automation is part of a broader suite of IBM-maintained Infrastructure as Code (IaC) assets, 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-elasticsearch/blob/main/README.md",
"offering_icon_url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-icd-elasticsearch/main/images/elasticsearch_icon.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-elasticsearch/issues](https://github.com/terraform-ibm-modules/terraform-ibm-icd-elasticsearch/issues). Please note this product is not supported via the IBM Cloud Support Center.",
"features": [
{
- "title": "Creates an instance of Databases for Elasticsearch",
- "description": "Creates and configures an IBM Cloud Databases for Elasticsearch instance."
- },
- {
- "title": "Supports KMS encryption",
- "description": "Provides KMS encryption for the data that you store in the database."
+ "title": "KMS encryption",
+ "description": "Provides [KMS encryption](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-key-protect&interface=ui) for the data that you store in the database, enhancing data security."
},
{
- "title": "Supports autoscaling",
- "description": "Provides the autoscaling to allow the database to increase resources in response to usage."
+ "title": "Autoscaling",
+ "description": "Provides the [autoscaling](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-autoscaling&interface=ui) to allow the database to increase resources in response to usage."
},
{
- "title": "Attaches access tags",
+ "title": "Access tags",
"description": "Attaches access tags to the Elasticsearch 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": [
{
"profile_name": "IBM Cloud Framework for Financial Services",
- "profile_version": "1.6.0"
+ "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-elasticsearch"
+ },
+ {
+ "role_crns": [
+ "crn:v1:bluemix:public:iam::::role:Editor"
+ ],
+ "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 Elasticsearch",
- "description": "This architecture creates an instance of IBM Cloud Databases for Elasticsearch 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": [
@@ -96,6 +115,7 @@
},
{
"key": "provider_visibility",
+ "hidden": true,
"options": [
{
"displayname": "private",
@@ -112,16 +132,19 @@
]
},
{
- "key": "use_existing_resource_group",
- "required": true
- },
- {
- "key": "resource_group_name",
- "required": true
+ "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",
- "required": true
+ "key": "prefix"
},
{
"key": "region",
@@ -177,34 +200,10 @@
}
]
},
- {
- "key": "name"
- },
- {
- "key": "existing_elasticsearch_instance_crn"
- },
- {
- "key": "plan",
- "options": [
- {
- "displayname": "enterprise",
- "value": "enterprise"
- },
- {
- "displayname": "platinum",
- "value": "platinum"
- }
- ]
- },
{
"key": "elasticsearch_version",
- "required": false,
- "default_value": "__NULL__",
+ "required": true,
"options": [
- {
- "displayname": "preferred",
- "value": "__NULL__"
- },
{
"displayname": "8.15",
"value": "8.15"
@@ -220,13 +219,42 @@
]
},
{
- "key": "tags"
+ "key": "name"
},
{
- "key": "access_tags"
+ "key": "plan",
+ "options": [
+ {
+ "displayname": "enterprise",
+ "value": "enterprise"
+ },
+ {
+ "displayname": "platinum",
+ "value": "platinum"
+ }
+ ]
},
{
- "key": "auto_scaling"
+ "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"
@@ -244,19 +272,46 @@
"key": "member_host_flavor"
},
{
- "key": "admin_pass"
+ "key": "auto_scaling"
},
{
- "key": "users"
+ "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": "service_credential_secrets",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
+ },
+ {
+ "key": "admin_pass"
+ },
{
"key": "existing_secrets_manager_instance_crn"
},
{
"key": "existing_secrets_manager_endpoint_type",
+ "hidden": true,
"options": [
{
"displayname": "public",
@@ -269,25 +324,41 @@
]
},
{
- "key": "service_credential_secrets"
+ "key": "skip_elasticsearch_to_secrets_manager_auth_policy"
},
{
- "key": "use_existing_admin_pass_secrets_manager_secret_group"
+ "key": "admin_pass_secrets_manager_secret_group"
},
{
"key": "admin_pass_secrets_manager_secret_name"
},
{
- "key": "admin_pass_secrets_manager_secret_group"
+ "key": "use_existing_admin_pass_secrets_manager_secret_group"
},
{
- "key": "skip_elasticsearch_to_secrets_manager_auth_policy"
+ "key": "users",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
},
{
"key": "ibmcloud_kms_api_key"
},
+ {
+ "key": "kms_encryption_enabled"
+ },
+ {
+ "key": "existing_kms_instance_crn"
+ },
+ {
+ "key": "existing_kms_key_crn"
+ },
{
"key": "kms_endpoint_type",
+ "hidden": true,
"options": [
{
"displayname": "public",
@@ -300,14 +371,13 @@
]
},
{
- "key": "use_ibm_owned_encryption_key"
+ "key": "key_ring_name"
},
{
- "key": "existing_kms_instance_crn",
- "required": true
+ "key": "key_name"
},
{
- "key": "existing_kms_key_crn"
+ "key": "backup_crn"
},
{
"key": "existing_backup_kms_key_crn"
@@ -316,16 +386,10 @@
"key": "use_default_backup_encryption_key"
},
{
- "key": "elasticsearch_key_ring_name"
- },
- {
- "key": "elasticsearch_key_name"
+ "key": "skip_elasticsearch_kms_auth_policy"
},
{
- "key": "skip_es_kms_auth_policy"
- },
- {
- "key": "backup_crn"
+ "key": "existing_elasticsearch_instance_crn"
},
{
"key": "enable_elser_model"
@@ -389,6 +453,328 @@
"key": "cbr_rules"
}
]
+ },
+ {
+ "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-redis"
+ },
+ {
+ "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 Elasticsearch instance on IBM Cloud",
+ "url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-icd-elasticsearch/main/reference-architecture/deployable-architecture-elasticsearch.svg",
+ "type": "image/svg+xml"
+ },
+ "description": "This architecture supports creating and configuring an instance of Databases for Elasticsearch 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": "plan",
+ "options": [
+ {
+ "displayname": "enterprise",
+ "value": "enterprise"
+ },
+ {
+ "displayname": "platinum",
+ "value": "platinum"
+ }
+ ]
+ },
+ {
+ "key": "elasticsearch_version",
+ "required": true,
+ "options": [
+ {
+ "displayname": "8.15",
+ "value": "8.15"
+ },
+ {
+ "displayname": "8.12",
+ "value": "8.12"
+ },
+ {
+ "displayname": "8.10",
+ "value": "8.10"
+ }
+ ]
+ },
+ {
+ "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": "service_credential_names"
+ },
+ {
+ "key": "service_credential_secrets",
+ "type": "array",
+ "custom_config": {
+ "type": "textarea",
+ "grouping": "deployment",
+ "original_grouping": "deployment"
+ }
+ },
+ {
+ "key": "admin_pass"
+ },
+ {
+ "key": "existing_secrets_manager_instance_crn"
+ },
+ {
+ "key": "skip_elasticsearch_to_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_elasticsearch_kms_auth_policy"
+ },
+ {
+ "key": "existing_elasticsearch_instance_crn"
+ },
+ {
+ "key": "enable_elser_model"
+ },
+ {
+ "key": "elser_model_type",
+ "options": [
+ {
+ "displayname": ".elser_model_1",
+ "value": ".elser_model_1"
+ },
+ {
+ "displayname": ".elser_model_2",
+ "value": ".elser_model_2"
+ },
+ {
+ "displayname": ".elser_model_2_linux-x86_64",
+ "value": ".elser_model_2_linux-x86_64"
+ }
+ ]
+ },
+ {
+ "key": "enable_kibana_dashboard"
+ },
+ {
+ "key": "kibana_code_engine_new_project_name"
+ },
+ {
+ "key": "kibana_code_engine_new_app_name"
+ },
+ {
+ "key": "existing_code_engine_project_id"
+ },
+ {
+ "key": "kibana_registry_namespace_image"
+ },
+ {
+ "key": "kibana_image_digest"
+ },
+ {
+ "key": "kibana_image_port"
+ },
+ {
+ "key": "cbr_rules"
+ }
+ ]
}
]
}
diff --git a/main.tf b/main.tf
index 6a870a48..a22ebec4 100644
--- a/main.tf
+++ b/main.tf
@@ -1,15 +1,10 @@
-########################################################################################################################
-# Input variable validation
-# (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
-#
-# TODO: Replace with terraform cross variable validation: https://github.ibm.com/GoldenEye/issues/issues/10836
-########################################################################################################################
-
########################################################################################################################
# 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)
@@ -68,12 +63,13 @@ locals {
create_backup_kms_auth_policy = !var.use_ibm_owned_encryption_key && !var.skip_iam_authorization_policy && !var.use_same_kms_key_for_backups ? 1 : 0
}
-resource "ibm_iam_authorization_policy" "policy" {
+# Create IAM Authorization Policies to allow Elasticsearch to access KMS for the encryption key
+resource "ibm_iam_authorization_policy" "kms_policy" {
count = local.create_kms_auth_policy
source_service_name = "databases-for-elasticsearch"
source_resource_group_id = var.resource_group_id
roles = ["Reader"]
- description = "Allow all Elastic Search instances in the resource group ${var.resource_group_id} to read the ${local.kms_service} key ${local.kms_key_id} from the instance GUID ${local.kms_key_instance_guid}"
+ description = "Allow all Elasticsearch instances in the resource group ${var.resource_group_id} to read the ${local.kms_service} key ${local.kms_key_id} from the instance GUID ${local.kms_key_instance_guid}"
resource_attributes {
name = "serviceName"
operator = "stringEquals"
@@ -108,8 +104,9 @@ resource "ibm_iam_authorization_policy" "policy" {
# workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4478
resource "time_sleep" "wait_for_authorization_policy" {
- count = local.create_kms_auth_policy
- depends_on = [ibm_iam_authorization_policy.policy]
+ count = local.create_kms_auth_policy
+ depends_on = [ibm_iam_authorization_policy.kms_policy]
+
create_duration = "30s"
}
@@ -118,7 +115,7 @@ resource "ibm_iam_authorization_policy" "backup_kms_policy" {
source_service_name = "databases-for-elasticsearch"
source_resource_group_id = var.resource_group_id
roles = ["Reader"]
- description = "Allow all Elastic Search instances in the Resource Group ${var.resource_group_id} to read the ${local.backup_kms_service} key ${local.backup_kms_key_id} from the instance GUID ${local.backup_kms_key_instance_guid}"
+ description = "Allow all Elasticsearch instances in the Resource Group ${var.resource_group_id} to read the ${local.backup_kms_service} key ${local.backup_kms_key_id} from the instance GUID ${local.backup_kms_key_instance_guid}"
resource_attributes {
name = "serviceName"
operator = "stringEquals"
@@ -193,12 +190,12 @@ resource "ibm_database" "elasticsearch" {
dynamic "group" {
for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" && var.backup_crn == null ? [1] : []
content {
- group_id = "member" # Only member type is allowed for elasticsearch
+ group_id = "member" # Only member type is allowed for IBM Cloud Databases
host_flavor {
id = var.member_host_flavor
}
disk {
- allocation_mb = var.member_disk_mb
+ allocation_mb = var.disk_mb
}
members {
allocation_count = var.members
@@ -210,18 +207,18 @@ resource "ibm_database" "elasticsearch" {
dynamic "group" {
for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" && var.backup_crn == null ? [1] : []
content {
- group_id = "member" # Only member type is allowed for elasticsearch
+ group_id = "member" # Only member type is allowed for IBM Cloud Databases
host_flavor {
id = var.member_host_flavor
}
disk {
- allocation_mb = var.member_disk_mb
+ allocation_mb = var.disk_mb
}
memory {
- allocation_mb = var.member_memory_mb
+ allocation_mb = var.memory_mb
}
cpu {
- allocation_count = var.member_cpu_count
+ allocation_count = var.cpu_count
}
members {
allocation_count = var.members
@@ -231,17 +228,17 @@ resource "ibm_database" "elasticsearch" {
## This block is for if host_flavor IS NOT set
dynamic "group" {
- for_each = local.host_flavor_set == false && var.backup_crn == null ? [1] : []
+ for_each = !local.host_flavor_set && var.backup_crn == null ? [1] : []
content {
- group_id = "member" # Only member type is allowed for elasticsearch
+ group_id = "member" # Only member type is allowed for IBM Cloud Databases
memory {
- allocation_mb = var.member_memory_mb
+ allocation_mb = var.memory_mb
}
disk {
- allocation_mb = var.member_disk_mb
+ allocation_mb = var.disk_mb
}
cpu {
- allocation_count = var.member_cpu_count
+ allocation_count = var.cpu_count
}
members {
allocation_count = var.members
@@ -300,7 +297,6 @@ resource "ibm_resource_tag" "elasticsearch_tag" {
tag_type = "access"
}
-
########################################################################################################################
# Context Based Restrictions
########################################################################################################################
diff --git a/modules/fscloud/main.tf b/modules/fscloud/main.tf
index 9a52d8e6..c3d9c9a7 100644
--- a/modules/fscloud/main.tf
+++ b/modules/fscloud/main.tf
@@ -17,11 +17,11 @@ module "elasticsearch" {
tags = var.tags
plan = var.plan
members = var.members
- member_memory_mb = var.member_memory_mb
+ memory_mb = var.member_memory_mb
admin_pass = var.admin_pass
users = var.users
- member_disk_mb = var.member_disk_mb
- member_cpu_count = var.member_cpu_count
+ disk_mb = var.member_disk_mb
+ cpu_count = var.member_cpu_count
member_host_flavor = var.member_host_flavor
auto_scaling = var.auto_scaling
service_credential_names = var.service_credential_names
diff --git a/reference-architecture/deployable-architecture-elasticsearch.svg b/reference-architecture/deployable-architecture-elasticsearch.svg
index 5ca6ee89..367df641 100644
--- a/reference-architecture/deployable-architecture-elasticsearch.svg
+++ b/reference-architecture/deployable-architecture-elasticsearch.svg
@@ -1,4 +1,4 @@
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/solutions/standard/DA-cbr_rules.md b/solutions/fully-configurable/DA-cbr_rules.md
similarity index 100%
rename from solutions/standard/DA-cbr_rules.md
rename to solutions/fully-configurable/DA-cbr_rules.md
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..f099860c
--- /dev/null
+++ b/solutions/fully-configurable/README.md
@@ -0,0 +1,3 @@
+# Cloud automation for Elasticsearch (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..fbb545af
--- /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-permanent",
+ "kms_encryption_enabled": true,
+ "existing_kms_instance_crn": $HPCS_US_SOUTH_CRN
+}
diff --git a/solutions/standard/main.tf b/solutions/fully-configurable/main.tf
similarity index 75%
rename from solutions/standard/main.tf
rename to solutions/fully-configurable/main.tf
index fd4240df..4ce977f6 100644
--- a/solutions/standard/main.tf
+++ b/solutions/fully-configurable/main.tf
@@ -1,37 +1,36 @@
#######################################################################################################################
# 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
}
-#######################################################################################################################
-# KMS related variable validation
-# (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
-#
-# TODO: Replace with terraform cross variable validation: https://github.ibm.com/GoldenEye/issues/issues/10836
-#######################################################################################################################
-
#######################################################################################################################
# KMS encryption key
#######################################################################################################################
locals {
- create_new_kms_key = var.existing_elasticsearch_instance_crn == null && !var.use_ibm_owned_encryption_key && var.existing_kms_key_crn == null ? 1 : 0 # no need to create any KMS resources if using existing Elasticsearch, passing an existing key, or using IBM owned keys
- elasticsearch_key_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.elasticsearch_key_name}" : var.elasticsearch_key_name
- elasticsearch_key_ring_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.elasticsearch_key_ring_name}" : var.elasticsearch_key_ring_name
+ use_ibm_owned_encryption_key = !var.kms_encryption_enabled
+ create_new_kms_key = (
+ var.kms_encryption_enabled &&
+ var.existing_elasticsearch_instance_crn == null &&
+ var.existing_kms_key_crn == null
+ )
+ elasticsearch_key_name = "${local.prefix}${var.key_name}"
+ elasticsearch_key_ring_name = "${local.prefix}${var.key_ring_name}"
}
-
module "kms" {
providers = {
ibm = ibm.kms
}
- count = local.create_new_kms_key
+ count = local.create_new_kms_key ? 1 : 0
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
version = "5.1.7"
create_key_protect_instance = false
@@ -49,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.
}
]
}
@@ -93,24 +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_elasticsearch_instance_crn == null && !var.skip_es_kms_auth_policy && var.ibmcloud_kms_api_key != null && !var.use_ibm_owned_encryption_key
- create_cross_account_backup_kms_auth_policy = var.existing_elasticsearch_instance_crn == null && !var.skip_es_kms_auth_policy && 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.skip_elasticsearch_kms_auth_policy && var.ibmcloud_kms_api_key != null
+ create_cross_account_backup_kms_auth_policy = var.kms_encryption_enabled && !var.skip_elasticsearch_kms_auth_policy && 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_elasticsearch_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_elasticsearch_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_elasticsearch_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_elasticsearch_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.elasticsearch_key_ring_name, local.elasticsearch_key_name)].crn
- kms_key_id = var.existing_elasticsearch_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.elasticsearch_key_ring_name, local.elasticsearch_key_name)].key_id
- kms_region = var.existing_elasticsearch_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
+ kms_account_id = !var.kms_encryption_enabled || var.existing_elasticsearch_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_elasticsearch_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_elasticsearch_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_elasticsearch_instance_crn != null ? null : var.existing_kms_key_crn != null ? var.existing_kms_key_crn : module.kms[0].keys[format("%s.%s", local.elasticsearch_key_ring_name, local.elasticsearch_key_name)].crn
+ kms_key_id = !var.kms_encryption_enabled || var.existing_elasticsearch_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.elasticsearch_key_ring_name, local.elasticsearch_key_name)].key_id
+ kms_region = !var.kms_encryption_enabled || var.existing_elasticsearch_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_elasticsearch_instance_crn != null || var.use_ibm_owned_encryption_key ? null : var.existing_backup_kms_key_crn
+ backup_kms_key_crn = var.existing_elasticsearch_instance_crn != null || !var.kms_encryption_enabled ? 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
}
@@ -123,7 +121,7 @@ resource "ibm_iam_authorization_policy" "kms_policy" {
source_service_name = "databases-for-elasticsearch"
source_resource_group_id = module.resource_group.resource_group_id
roles = ["Reader"]
- description = "Allow all Elastic Search instances in the resource group ${module.resource_group.resource_group_id} in the account ${local.account_id} to read the ${local.kms_service} key ${local.kms_key_id} from the instance GUID ${local.kms_instance_guid}"
+ description = "Allow all Elasticsearch instances in the resource group ${module.resource_group.resource_group_id} in the account ${local.account_id} to read the ${local.kms_service} key ${local.kms_key_id} from the instance GUID ${local.kms_instance_guid}"
resource_attributes {
name = "serviceName"
operator = "stringEquals"
@@ -171,7 +169,7 @@ resource "ibm_iam_authorization_policy" "backup_kms_policy" {
source_service_name = "databases-for-elasticsearch"
source_resource_group_id = module.resource_group.resource_group_id
roles = ["Reader"]
- description = "Allow all Elastic Search instances in the resource group ${module.resource_group.resource_group_id} in the account ${local.account_id} to read the ${local.backup_kms_service} key ${local.backup_kms_key_id} from the instance GUID ${local.backup_kms_instance_guid}"
+ description = "Allow all Elasticsearch instances in the resource group ${module.resource_group.resource_group_id} in the account ${local.account_id} to read the ${local.backup_kms_service} key ${local.backup_kms_key_id} from the instance GUID ${local.backup_kms_instance_guid}"
resource_attributes {
name = "serviceName"
operator = "stringEquals"
@@ -228,7 +226,9 @@ locals {
# if - replace first char with J
# elseif _ replace first char with K
# else use asis
- admin_pass = var.admin_pass == null ? (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) : var.admin_pass
+ 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
}
#######################################################################################################################
@@ -276,31 +276,32 @@ data "ibm_database_connection" "existing_connection" {
# Create new instance
module "elasticsearch" {
count = var.existing_elasticsearch_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}"
region = var.region
plan = var.plan
- skip_iam_authorization_policy = var.skip_es_kms_auth_policy
elasticsearch_version = var.elasticsearch_version
- use_ibm_owned_encryption_key = var.use_ibm_owned_encryption_key
+ skip_iam_authorization_policy = var.kms_encryption_enabled ? var.skip_elasticsearch_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
- backup_crn = var.backup_crn
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
- member_memory_mb = var.member_memory_mb
- member_disk_mb = var.member_disk_mb
- member_cpu_count = var.member_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
enable_elser_model = var.enable_elser_model
elser_model_type = var.elser_model_type
cbr_rules = var.cbr_rules
@@ -322,7 +323,7 @@ locals {
#######################################################################################################################
locals {
- create_sm_auth_policy = var.skip_elasticsearch_to_secrets_manager_auth_policy || var.existing_secrets_manager_instance_crn == null ? 0 : 1
+ create_secrets_manager_auth_policy = var.skip_elasticsearch_to_secrets_manager_auth_policy || var.existing_secrets_manager_instance_crn == null ? 0 : 1
}
# Parse the Secrets Manager CRN
@@ -333,10 +334,9 @@ module "sm_instance_crn_parser" {
crn = var.existing_secrets_manager_instance_crn
}
-# create a service authorization between Secrets Manager and the target service (Elastic Search)
+# create a service authorization between Secrets Manager and the target service (Elasticsearch)
resource "ibm_iam_authorization_policy" "secrets_manager_key_manager" {
- count = local.create_sm_auth_policy
- depends_on = [module.elasticsearch]
+ count = local.create_secrets_manager_auth_policy
source_service_name = "secrets-manager"
source_resource_instance_id = local.existing_secrets_manager_instance_guid
target_service_name = "databases-for-elasticsearch"
@@ -346,14 +346,13 @@ resource "ibm_iam_authorization_policy" "secrets_manager_key_manager" {
}
# workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4478
-resource "time_sleep" "wait_for_es_authorization_policy" {
- count = local.create_sm_auth_policy
+resource "time_sleep" "wait_for_elasticsearch_authorization_policy" {
+ count = local.create_secrets_manager_auth_policy
depends_on = [ibm_iam_authorization_policy.secrets_manager_key_manager]
create_duration = "30s"
}
locals {
- # Build the structure of the service credential type secret
service_credential_secrets = [
for service_credentials in var.service_credential_secrets : {
secret_group_name = service_credentials.secret_group_name
@@ -378,10 +377,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
}
@@ -395,10 +394,9 @@ locals {
existing_secrets_manager_instance_region = var.existing_secrets_manager_instance_crn != null ? module.sm_instance_crn_parser[0].region : null
}
-# Create secret(s)
module "secrets_manager_service_credentials" {
- count = var.existing_secrets_manager_instance_crn == null ? 0 : 1
- depends_on = [time_sleep.wait_for_es_authorization_policy]
+ count = length(local.service_credential_secrets) > 0 ? 1 : 0
+ depends_on = [time_sleep.wait_for_elasticsearch_authorization_policy]
source = "terraform-ibm-modules/secrets-manager/ibm//modules/secrets"
version = "2.3.1"
existing_sm_instance_guid = local.existing_secrets_manager_instance_guid
@@ -413,8 +411,8 @@ module "secrets_manager_service_credentials" {
locals {
code_engine_project_id = var.existing_code_engine_project_id != null ? var.existing_code_engine_project_id : null
- code_engine_project_name = local.code_engine_project_id != null ? null : (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.kibana_code_engine_new_project_name}" : var.kibana_code_engine_new_project_name
- code_engine_app_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.kibana_code_engine_new_app_name}" : var.kibana_code_engine_new_app_name
+ code_engine_project_name = local.code_engine_project_id != null ? null : "${local.prefix}${var.kibana_code_engine_new_project_name}"
+ code_engine_app_name = "${local.prefix}${var.kibana_code_engine_new_app_name}"
kibana_version = var.enable_kibana_dashboard ? jsondecode(data.http.es_metadata[0].response_body).version.number : null
}
diff --git a/solutions/standard/outputs.tf b/solutions/fully-configurable/outputs.tf
similarity index 75%
rename from solutions/standard/outputs.tf
rename to solutions/fully-configurable/outputs.tf
index bc00a5ae..1f52d179 100644
--- a/solutions/standard/outputs.tf
+++ b/solutions/fully-configurable/outputs.tf
@@ -7,16 +7,16 @@ output "id" {
value = local.elasticsearch_id
}
-output "guid" {
- description = "Elasticsearch instance guid"
- value = local.elasticsearch_guid
-}
-
output "version" {
description = "Elasticsearch instance version"
value = local.elasticsearch_version
}
+output "guid" {
+ description = "Elasticsearch instance guid"
+ value = local.elasticsearch_guid
+}
+
output "crn" {
description = "Elasticsearch instance crn"
value = local.elasticsearch_crn
@@ -59,3 +59,19 @@ output "kibana_app_endpoint" {
description = "Code Engine Kibana endpoint URL"
value = var.enable_kibana_dashboard ? module.code_engine_kibana[0].app[local.code_engine_app_name].endpoint : null
}
+
+output "cbr_rule_ids" {
+ description = "CBR rule ids created to restrict Elasticsearch"
+ value = var.existing_elasticsearch_instance_crn != null ? null : module.elasticsearch[0].cbr_rule_ids
+}
+
+output "adminuser" {
+ description = "Database admin user name"
+ value = var.existing_elasticsearch_instance_crn != null ? null : module.elasticsearch[0].adminuser
+}
+
+output "certificate_base64" {
+ description = "Database connection certificate"
+ value = var.existing_elasticsearch_instance_crn != null ? null : module.elasticsearch[0].certificate_base64
+ sensitive = true
+}
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 8657adfe..f8963168 100644
--- a/solutions/standard/variables.tf
+++ b/solutions/fully-configurable/variables.tf
@@ -1,5 +1,5 @@
##############################################################################
-# DA extra
+# Input Variables
##############################################################################
variable "ibmcloud_api_key" {
@@ -8,36 +8,38 @@ variable "ibmcloud_api_key" {
sensitive = true
}
-variable "provider_visibility" {
- description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
+variable "existing_resource_group_name" {
type = string
- default = "private"
-
- validation {
- condition = contains(["public", "private", "public-and-private"], var.provider_visibility)
- error_message = "Invalid visibility option. Allowed values are 'public', 'private', or 'public-and-private'."
- }
+ description = "The name of an existing resource group to provision resource in."
+ default = "Default"
+ nullable = false
}
variable "prefix" {
type = string
- description = "Prefix to add to all resources created by this solution. To not use any prefix value, you can set this value to `null` or an empty string."
- default = "dev"
-}
+ nullable = true
+ description = "The prefix to be added to all resources created by this solution. To skip using a prefix, set this value to null or an empty string. The prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It should not exceed 16 characters, must not end with a hyphen('-'), and can not contain consecutive hyphens ('--'). Example: prod-0205-cos. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
-##############################################################################
-# Input Variables
-##############################################################################
-
-variable "resource_group_name" {
- type = string
- description = "The name of a new or an existing resource group to provision the Databases for Elasicsearch in. If a prefix input variable is specified, the prefix is added to the name in the `