Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
886657f
add: cross object referencing
Aditya-ranjan-16 Feb 13, 2025
a9e8b5e
Merge branch 'main' into cross-object
Aditya-ranjan-16 Feb 17, 2025
7ec338c
Merge branch 'main' into cross-object
Aditya-ranjan-16 Feb 19, 2025
3a5d0cc
add: validation in main module
Aditya-ranjan-16 Feb 19, 2025
0d69181
fix
Aditya-ranjan-16 Feb 19, 2025
b142233
fix
Aditya-ranjan-16 Feb 19, 2025
49e3ab9
fix
Aditya-ranjan-16 Feb 19, 2025
558037a
fix: corrected logic
Aditya-ranjan-16 Feb 20, 2025
a45022d
fix: added existing_kms_instance_crn in cra config
Aditya-ranjan-16 Feb 20, 2025
62229c4
fix
Aditya-ranjan-16 Feb 20, 2025
e9ef24f
Merge branch 'main' into cross-object
Ak-sky Feb 24, 2025
4449954
Merge branch 'main' into cross-object
aatreyee2506 Mar 11, 2025
54acec6
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 1, 2025
3fcf77a
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 8, 2025
d95a7dc
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 14, 2025
f0ca1f2
fix: making validation consistent with other ICDS
lethal007 Apr 14, 2025
3344895
fix
Aditya-ranjan-16 Apr 14, 2025
c1d342d
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 14, 2025
f6ecd3d
test
Aditya-ranjan-16 Apr 14, 2025
ff0d005
fix
Aditya-ranjan-16 Apr 14, 2025
dcdbbf2
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 17, 2025
358c1dd
fix
Aditya-ranjan-16 Apr 17, 2025
cb24905
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 22, 2025
ddf3662
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 27, 2025
b152758
fix: Making Consistent with Redis
Aditya-ranjan-16 Apr 27, 2025
221d80d
Merge branch 'main' into cross-object
Aditya-ranjan-16 Apr 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ To attach access management tags to resources in this module, you need the follo

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.70.0, < 2.0.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1 |

Expand Down
1 change: 1 addition & 0 deletions cra-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CRA_TARGETS:
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_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_kms_instance_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9:key:76170fae-4e0c-48c3-8ebe-326059ebb532"
TF_VAR_use_existing_resource_group: true
TF_VAR_resource_group_name: "geretain-test-mysql"
TF_VAR_provider_visibility: "public"
2 changes: 1 addition & 1 deletion examples/backup/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
required_providers {
# Use latest version of provider in non-basic examples to verify latest version works with module
ibm = {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
required_providers {
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
ibm = {
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
required_providers {
# Use latest version of provider in non-basic examples to verify latest version works with module
ibm = {
Expand Down
2 changes: 1 addition & 1 deletion examples/fscloud/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
required_providers {
# Use latest version of provider in non-basic examples to verify latest version works with module
ibm = {
Expand Down
10 changes: 0 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
##############################################################################

locals {
# Validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
# tflint-ignore: terraform_unused_declarations
validate_kms_values = var.use_ibm_owned_encryption_key && (var.kms_key_crn != null || var.backup_encryption_key_crn != null) ? tobool("When passing values for 'kms_key_crn' or 'backup_encryption_key_crn', you must set 'use_ibm_owned_encryption_key' to false. Otherwise unset them to use default encryption.") : true
# tflint-ignore: terraform_unused_declarations
validate_kms_vars = !var.use_ibm_owned_encryption_key && var.kms_key_crn == null ? tobool("When setting 'use_ibm_owned_encryption_key' to false, a value must be passed for 'kms_key_crn'.") : true
# tflint-ignore: terraform_unused_declarations
validate_backup_key = !var.use_ibm_owned_encryption_key && var.backup_encryption_key_crn != null && (var.use_default_backup_encryption_key || var.use_same_kms_key_for_backups) ? tobool("When passing a value for 'backup_encryption_key_crn' you cannot set 'use_default_backup_encryption_key' to true or 'use_ibm_owned_encryption_key' to false.") : true
# tflint-ignore: terraform_unused_declarations
validate_backup_key_2 = !var.use_ibm_owned_encryption_key && var.backup_encryption_key_crn == null && !var.use_same_kms_key_for_backups ? tobool("When 'use_same_kms_key_for_backups' is set to false, a value needs to be passed for 'backup_encryption_key_crn'.") : true

# 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.
Expand Down
2 changes: 1 addition & 1 deletion modules/fscloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The IBM Cloud Framework for Financial Services mandates the application of an in

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.70.0 |

### Modules
Expand Down
2 changes: 1 addition & 1 deletion modules/fscloud/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
required_providers {
# The below tflint-ignore is required because although the below provider is not directly required by this submodule,
# it is required by consuming modules, and if not set here, the top level module calling this module will not be
Expand Down
14 changes: 0 additions & 14 deletions solutions/standard/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ module "resource_group" {
existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null
}

#######################################################################################################################
# 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
#######################################################################################################################

locals {
# tflint-ignore: terraform_unused_declarations
validate_kms_1 = var.use_ibm_owned_encryption_key && (var.existing_kms_instance_crn != null || var.existing_kms_key_crn != null || var.existing_backup_kms_key_crn != null) ? tobool("When setting values for 'existing_kms_instance_crn', 'existing_kms_key_crn' or 'existing_backup_kms_key_crn', the 'use_ibm_owned_encryption_key' input must be set to false.") : true
# tflint-ignore: terraform_unused_declarations
validate_kms_2 = !var.use_ibm_owned_encryption_key && (var.existing_kms_instance_crn == null && var.existing_kms_key_crn == null) ? tobool("When 'use_ibm_owned_encryption_key' is false, a value is required for either 'existing_kms_instance_crn' (to create a new key), or 'existing_kms_key_crn' to use an existing key.") : true
}

#######################################################################################################################
# KMS encryption key
#######################################################################################################################
Expand Down
12 changes: 12 additions & 0 deletions solutions/standard/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,20 @@ variable "existing_kms_instance_crn" {
type = string
description = "The CRN of a Key Protect or Hyper Protect Crypto Services instance. Required to create a new encryption key and key ring which will be used to encrypt both deployment data and backups. Applies only if `use_ibm_owned_encryption_key` is false. To use an existing key, pass values for `existing_kms_key_crn` and/or `existing_backup_kms_key_crn`. 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)."
default = null
validation {
condition = (var.existing_kms_instance_crn == null) == var.use_ibm_owned_encryption_key
error_message = "If 'existing_kms_instance_crn' is provided, 'use_ibm_owned_encryption_key' must be set to false."
}
}

variable "existing_kms_key_crn" {
type = string
description = "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 optional `existing_backup_kms_key_crn` input. If no value is passed a new key will be created in the instance specified in the `existing_kms_instance_crn` input. 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)."
default = null
validation {
condition = (var.existing_kms_key_crn == null && var.existing_kms_instance_crn == null) == var.use_ibm_owned_encryption_key
error_message = "'use_ibm_owned_encryption_key' input must be set to false."
}
}

variable "kms_endpoint_type" {
Expand Down Expand Up @@ -220,6 +228,10 @@ variable "existing_backup_kms_key_crn" {
type = string
description = "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. If no value is passed, the value of `existing_kms_key_crn` is used. If no value is passed for `existing_kms_key_crn`, a new key will be created in the instance specified in the `existing_kms_instance_crn` input. 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)."
default = null
validation {
condition = var.existing_backup_kms_key_crn == null || var.use_ibm_owned_encryption_key == false
error_message = "'use_ibm_owned_encryption_key' input must be set to false."
}
}

variable "use_default_backup_encryption_key" {
Expand Down
2 changes: 1 addition & 1 deletion solutions/standard/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
# Lock DA into an exact provider version - renovate automation will keep it updated
required_providers {
ibm = {
Expand Down
16 changes: 16 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ variable "use_default_backup_encryption_key" {
type = bool
description = "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."
default = false
validation {
condition = !var.use_default_backup_encryption_key || (var.use_ibm_owned_encryption_key && var.backup_encryption_key_crn == null)
error_message = "If 'use_default_backup_encryption_key' is true , 'use_ibm_owned_encryption_key' must be not be set to false. and 'backup_encryption_key_crn' must be null"
}
}

variable "kms_key_crn" {
Expand All @@ -297,12 +301,20 @@ variable "kms_key_crn" {
])
error_message = "Value must be the KMS key CRN from a Key Protect or Hyper Protect Crypto Services instance."
}
validation {
condition = (var.kms_key_crn == null) == var.use_ibm_owned_encryption_key
error_message = "If 'kms_key_crn' is provided, 'use_ibm_owned_encryption_key' must be set to false."
}
}

variable "use_same_kms_key_for_backups" {
type = bool
description = "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)."
default = true
validation {
condition = var.use_same_kms_key_for_backups || var.backup_encryption_key_crn != null
error_message = "If 'use_same_kms_key_for_backups' is false, 'backup_encryption_key_crn' must be set"
}
}

variable "backup_encryption_key_crn" {
Expand All @@ -318,6 +330,10 @@ variable "backup_encryption_key_crn" {
])
error_message = "Value must be the KMS key CRN from a Key Protect or Hyper Protect Crypto Services instance in one of the supported backup regions."
}
validation {
condition = var.backup_encryption_key_crn == null || var.use_ibm_owned_encryption_key == false
error_message = "If 'backup_encryption_key_crn' is provided, 'use_ibm_owned_encryption_key' must be set to false."
}
}

variable "skip_iam_authorization_policy" {
Expand Down
2 changes: 1 addition & 1 deletion version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.9.0"
required_providers {
# Use "greater than or equal to" range in modules
ibm = {
Expand Down