From a6ed8cd331c6d70f91b52dfcae024d35ead899bb Mon Sep 17 00:00:00 2001 From: Aditya Ranjan <48973656+Aditya-ranjan-16@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:27:22 +0530 Subject: [PATCH] feat: exposed the ability to set the `provider_visibility` in the DA [Learn more](https://registry.terraform.io/providers/IBM-Cloud/IBM/latest/docs#visibility-1) (#463) --- cra-config.yaml | 1 + ibm_catalog.json | 17 +++++++++++++++++ solutions/standard/provider.tf | 2 ++ solutions/standard/variables.tf | 10 ++++++++++ tests/pr_test.go | 1 + 5 files changed, 31 insertions(+) diff --git a/cra-config.yaml b/cra-config.yaml index 67094752..89953755 100644 --- a/cra-config.yaml +++ b/cra-config.yaml @@ -9,3 +9,4 @@ CRA_TARGETS: TF_VAR_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_provider_visibility: "public" diff --git a/ibm_catalog.json b/ibm_catalog.json index 94f23b2f..6209ee38 100644 --- a/ibm_catalog.json +++ b/ibm_catalog.json @@ -214,6 +214,23 @@ { "key": "ibmcloud_api_key" }, + { + "key": "provider_visibility", + "options": [ + { + "displayname": "private", + "value": "private" + }, + { + "displayname": "public", + "value": "public" + }, + { + "displayname": "public-and-private", + "value": "public-and-private" + } + ] + }, { "key": "use_existing_resource_group" }, diff --git a/solutions/standard/provider.tf b/solutions/standard/provider.tf index 32fb3295..d77fe085 100644 --- a/solutions/standard/provider.tf +++ b/solutions/standard/provider.tf @@ -1,9 +1,11 @@ provider "ibm" { ibmcloud_api_key = var.ibmcloud_api_key region = var.region + visibility = var.provider_visibility } provider "ibm" { alias = "kms" ibmcloud_api_key = var.ibmcloud_kms_api_key != null ? var.ibmcloud_kms_api_key : var.ibmcloud_api_key region = local.existing_kms_instance_region + visibility = var.provider_visibility } diff --git a/solutions/standard/variables.tf b/solutions/standard/variables.tf index ad98230e..b897a1ab 100644 --- a/solutions/standard/variables.tf +++ b/solutions/standard/variables.tf @@ -227,3 +227,13 @@ variable "backup_crn" { error_message = "backup_crn must be null OR starts with 'crn:' and contains ':backup:'" } } +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)." + 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'." + } +} diff --git a/tests/pr_test.go b/tests/pr_test.go index 8fc791b5..8cdc7d06 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -171,6 +171,7 @@ func TestRunStandardUpgradeSolution(t *testing.T) { "access_tags": permanentResources["accessTags"], "existing_kms_instance_crn": permanentResources["hpcs_south_crn"], "kms_endpoint_type": "public", + "provider_visibility": "public", "resource_group_name": options.Prefix, }