Skip to content

Commit

Permalink
feat: exposes the ability to set the provider_visibility in the DAs (#…
Browse files Browse the repository at this point in the history
…216)

[Learn more](/registry.terraform.io/providers/IBM-Cloud/IBM/latest/docs#visibility-1)

---------

Co-authored-by: Shikha Maheshwari <[email protected]>
  • Loading branch information
Aditya-ranjan-16 and maheshwarishikha authored Nov 26, 2024
1 parent 87300e0 commit 991fe28
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions cra-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CRA_TARGETS:
CRA_ENVIRONMENT_VARIABLES:
TF_VAR_resource_group_name: "test"
TF_VAR_existing_kms_instance_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9::"
TF_VAR_provider_visibility: "public"
34 changes: 34 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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": "prefix"
},
Expand Down Expand Up @@ -506,6 +523,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": "prefix"
},
Expand Down
1 change: 1 addition & 0 deletions solutions/agents/provider.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
visibility = var.provider_visibility
}

provider "kubernetes" {
Expand Down
9 changes: 9 additions & 0 deletions solutions/agents/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ variable "prefix" {
description = "The prefix for resources created by this solution."
default = null
}
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'."
}
}
##############################################################################
# Cluster variables
##############################################################################
Expand Down
3 changes: 3 additions & 0 deletions solutions/instances/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
visibility = var.provider_visibility
}

provider "ibm" {
alias = "cos"
ibmcloud_api_key = var.ibmcloud_cos_api_key != null ? var.ibmcloud_cos_api_key : var.ibmcloud_api_key
region = local.default_cos_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.kms_region
visibility = var.provider_visibility
}
9 changes: 9 additions & 0 deletions solutions/instances/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ variable "prefix" {
description = "The prefix to add to all resources that this solution creates."
default = null
}
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'."
}
}
##############################################################################
# IBM Cloud Logs
##############################################################################
Expand Down
3 changes: 3 additions & 0 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestRunUpgradeSolutionInstances(t *testing.T) {
"cos_instance_access_tags": permanentResources["accessTags"],
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
"kms_endpoint_type": "public",
"provider_visibility": "public",
"management_endpoint_type_for_bucket": "public",
"enable_platform_logs": "false",
"enable_platform_metrics": "false",
Expand Down Expand Up @@ -290,6 +291,7 @@ func TestRunExistingResourcesInstances(t *testing.T) {
},
},
"management_endpoint_type_for_bucket": "public",
"provider_visibility": "public",
"enable_platform_metrics": "false",
"enable_platform_logs": "false",
"cloud_logs_policies": []map[string]interface{}{
Expand Down Expand Up @@ -327,6 +329,7 @@ func TestRunExistingResourcesInstances(t *testing.T) {
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
"existing_cos_kms_key_crn": permanentResources["hpcs_south_root_key_crn"],
"kms_endpoint_type": "public",
"provider_visibility": "public",
"existing_cos_instance_crn": terraform.Output(t, existingTerraformOptions, "cos_crn"),
"management_endpoint_type_for_bucket": "public",
"enable_platform_metrics": "false",
Expand Down

0 comments on commit 991fe28

Please sign in to comment.