From 53580ae62a46595ee6f63e85fbc6cf7217af14df Mon Sep 17 00:00:00 2001 From: Aditya Ranjan <48973656+Aditya-ranjan-16@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:39:24 +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) (#586) --- cra-config.yaml | 1 + ibm_catalog.json | 17 +++++++++++++++++ solutions/standard/provider.tf | 1 + solutions/standard/variables.tf | 10 ++++++++++ tests/pr_test.go | 1 + 5 files changed, 30 insertions(+) diff --git a/cra-config.yaml b/cra-config.yaml index b4180d4..d3589fe 100644 --- a/cra-config.yaml +++ b/cra-config.yaml @@ -6,3 +6,4 @@ CRA_TARGETS: PROFILE_ID: "48279384-3d29-4089-8259-8ed354774b4a" # SCC profile ID (currently set to 'CIS IBM Cloud Foundations Benchmark v1.1.0' '1.1.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_resource_group_name: "test" + TF_VAR_provider_visibility: "public" diff --git a/ibm_catalog.json b/ibm_catalog.json index 68622c4..b169e54 100644 --- a/ibm_catalog.json +++ b/ibm_catalog.json @@ -65,6 +65,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 df45ef5..f69fb6d 100644 --- a/solutions/standard/provider.tf +++ b/solutions/standard/provider.tf @@ -1,4 +1,5 @@ provider "ibm" { ibmcloud_api_key = var.ibmcloud_api_key region = var.region + visibility = var.provider_visibility } diff --git a/solutions/standard/variables.tf b/solutions/standard/variables.tf index 5088c17..d4689f4 100644 --- a/solutions/standard/variables.tf +++ b/solutions/standard/variables.tf @@ -8,6 +8,16 @@ 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)." + 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'." + } +} variable "use_existing_resource_group" { type = bool description = "Whether to use an existing resource group." diff --git a/tests/pr_test.go b/tests/pr_test.go index 71ae439..11a4f4b 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -78,6 +78,7 @@ func TestRunUpgradeDASolution(t *testing.T) { terraformVars := map[string]interface{}{ "resource_group_name": options.Prefix, "kms_endpoint_type": "public", + "provider_visibility": "public", "existing_kms_instance_crn": permanentResources["hpcs_south_crn"], "keys": []map[string]interface{}{{"key_ring_name": "my-key-ring", "keys": []map[string]interface{}{{"key_name": "some-key-name-1"}, {"key_name": "some-key-name-2"}}}}, "resource_tags": []string{"kms-da-upg"},