Skip to content

Commit a6b1c9e

Browse files
authored
feat: updated DA variable allowed_network to default to 'private-only'<br> added new DA input variable existing_secrets_endpoint_type (#123)
1 parent 41aa38b commit a6b1c9e

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

solutions/standard/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ locals {
6767
secrets_manager_guid = var.existing_secrets_manager_crn != null ? (length(local.parsed_existing_secrets_manager_crn) > 0 ? local.parsed_existing_secrets_manager_crn[7] : null) : module.secrets_manager[0].secrets_manager_guid
6868
secrets_manager_crn = var.existing_secrets_manager_crn != null ? var.existing_secrets_manager_crn : module.secrets_manager[0].secrets_manager_crn
6969
secrets_manager_region = var.existing_secrets_manager_crn != null ? (length(local.parsed_existing_secrets_manager_crn) > 0 ? local.parsed_existing_secrets_manager_crn[5] : null) : module.secrets_manager[0].secrets_manager_region
70+
sm_endpoint_type = var.existing_secrets_manager_crn != null ? var.existing_secrets_endpoint_type : var.allowed_network == "private-only" ? "private" : "public"
7071
}
7172

7273
module "secrets_manager" {
@@ -87,7 +88,7 @@ module "secrets_manager" {
8788
enable_event_notification = var.existing_event_notification_instance_crn != null ? true : false
8889
existing_en_instance_crn = var.existing_event_notification_instance_crn
8990
skip_en_iam_authorization_policy = var.skip_event_notification_iam_authorization_policy
90-
endpoint_type = var.allowed_network == "private-only" ? "private" : "public"
91+
endpoint_type = local.sm_endpoint_type
9192
}
9293

9394
# Configure an IBM Secrets Manager IAM credentials engine for an existing IBM Secrets Manager instance.
@@ -98,7 +99,7 @@ module "iam_secrets_engine" {
9899
region = local.secrets_manager_region
99100
iam_engine_name = var.prefix != null ? "${var.prefix}-${var.iam_engine_name}" : var.iam_engine_name
100101
secrets_manager_guid = local.secrets_manager_guid
101-
endpoint_type = var.allowed_network == "private-only" ? "private" : "public"
102+
endpoint_type = local.sm_endpoint_type
102103
}
103104

104105
locals {
@@ -124,7 +125,7 @@ module "secrets_manager_public_cert_engine" {
124125
dns_config_name = var.dns_provider_name
125126
ca_config_name = var.ca_name
126127
acme_letsencrypt_private_key = var.acme_letsencrypt_private_key
127-
service_endpoints = var.allowed_network == "private-only" ? "private" : "public"
128+
service_endpoints = local.sm_endpoint_type
128129
}
129130

130131

@@ -140,7 +141,7 @@ module "private_secret_engine" {
140141
root_ca_max_ttl = var.root_ca_max_ttl
141142
intermediate_ca_name = var.intermediate_ca_name
142143
certificate_template_name = var.certificate_template_name
143-
endpoint_type = var.allowed_network == "private-only" ? "private" : "public"
144+
endpoint_type = local.sm_endpoint_type
144145
}
145146

146147
data "ibm_resource_instance" "existing_sm" {

solutions/standard/variables.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ variable "existing_secrets_manager_crn" {
4848
default = null
4949
}
5050

51+
variable "existing_secrets_endpoint_type" {
52+
type = string
53+
description = "The endpoint type to use if passing a value for `existing_secrets_manager_crn`."
54+
default = "private"
55+
validation {
56+
condition = contains(["public", "private"], var.existing_secrets_endpoint_type)
57+
error_message = "Allowed values for 'existing_secrets_endpoint_type' are \"public\" and \"private\"."
58+
}
59+
}
60+
5161
variable "service_plan" {
5262
type = string
5363
description = "The service/pricing plan to use when provisioning a new Secrets Manager instance. Allowed values: 'standard' and 'trial'. Only used if `provision_sm_instance` is set to true."
@@ -61,7 +71,7 @@ variable "service_plan" {
6171
variable "allowed_network" {
6272
type = string
6373
description = "The types of service endpoints to set on the Secrets Manager instance. Possible values are `private-only` or `public-and-private`."
64-
default = "public-and-private"
74+
default = "private-only"
6575
validation {
6676
condition = contains(["private-only", "public-and-private"], var.allowed_network)
6777
error_message = "The specified allowed_network is not a valid selection!"

tests/pr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ func TestRunDASolutionSchematics(t *testing.T) {
108108
{Name: "region", Value: validRegions[rand.Intn(len(validRegions))], DataType: "string"},
109109
{Name: "resource_group_name", Value: options.Prefix, DataType: "string"},
110110
{Name: "service_plan", Value: "trial", DataType: "string"},
111-
{Name: "allowed_network", Value: "private-only", DataType: "string"},
112111
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
113112
{Name: "iam_engine_enabled", Value: true, DataType: "bool"},
114113
{Name: "public_engine_enabled", Value: true, DataType: "bool"},
@@ -198,6 +197,7 @@ func TestRunExistingResourcesInstances(t *testing.T) {
198197
"existing_secrets_manager_crn": terraform.Output(t, existingTerraformOptions, "secrets_manager_instance_crn"),
199198
"iam_engine_enabled": true,
200199
"private_engine_enabled": true,
200+
"existing_secrets_endpoint_type": "public",
201201
},
202202
})
203203

0 commit comments

Comments
 (0)