Skip to content

Commit 1f9ff19

Browse files
shemauSteve Peggs
and
Steve Peggs
authored
feat: feat: The service_endpoints variable has been renamed to allowed_network and now only accepts the following values: private-only or public-and-private (#69)
Co-authored-by: Steve Peggs <peggs@uk.ibm.com>
1 parent 8fd889a commit 1f9ff19

File tree

8 files changed

+15
-21
lines changed

8 files changed

+15
-21
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module "secrets_manager" {
4444
region = "us-south"
4545
secrets_manager_name = "my-secrets-manager"
4646
sm_service_plan = "trial"
47-
service_endpoints = "public-and-private"
4847
}
4948
```
5049

@@ -91,6 +90,7 @@ You need the following permissions to run this module.
9190

9291
| Name | Description | Type | Default | Required |
9392
|------|-------------|------|---------|:--------:|
93+
| <a name="input_allowed_network"></a> [allowed\_network](#input\_allowed\_network) | The types of service endpoints to set on the Secrets Manager instance. Possible values are `private-only` or `public-and-private`. | `string` | `"public-and-private"` | no |
9494
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> }))</pre> | `[]` | no |
9595
| <a name="input_enable_event_notification"></a> [enable\_event\_notification](#input\_enable\_event\_notification) | Set this to true to enable lifecycle notifications for your Secrets Manager instance by connecting an Event Notifications service. When setting this to true, a value must be passed for `existing_en_instance_crn` variable. | `bool` | `false` | no |
9696
| <a name="input_endpoint_type"></a> [endpoint\_type](#input\_endpoint\_type) | The type of endpoint (public or private) to connect to the Secrets Manager API. The Terraform provider uses this endpoint type to interact with the Secrets Manager API and configure Event Notifications. | `string` | `"public"` | no |
@@ -101,7 +101,6 @@ You need the following permissions to run this module.
101101
| <a name="input_region"></a> [region](#input\_region) | The region to provision the Secrets Manager instance to. | `string` | n/a | yes |
102102
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The ID of the resource group to provision the Secrets Manager instance to. | `string` | n/a | yes |
103103
| <a name="input_secrets_manager_name"></a> [secrets\_manager\_name](#input\_secrets\_manager\_name) | The name to give the Secrets Manager instance. | `string` | n/a | yes |
104-
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The types of service endpoints to set on the Secrets Manager instance. Possible values are `public`, `private` or `public-and-private`. | `string` | `"public-and-private"` | no |
105104
| <a name="input_skip_en_iam_authorization_policy"></a> [skip\_en\_iam\_authorization\_policy](#input\_skip\_en\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all Secrets Manager instances (scoped to the resource group) an 'Event Source Manager' role to the given Event Notifications instance passed in the `existing_en_instance_crn` input variable. In addition, no policy is created if `enable_event_notification` is set to false. | `bool` | `false` | no |
106105
| <a name="input_skip_kms_iam_authorization_policy"></a> [skip\_kms\_iam\_authorization\_policy](#input\_skip\_kms\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all Secrets Manager instances in the resource group to read the encryption key from the KMS instance. If set to false, pass in a value for the KMS instance in the `existing_kms_instance_guid` variable. In addition, no policy is created if `kms_encryption_enabled` is set to false. | `bool` | `false` | no |
107106
| <a name="input_sm_service_plan"></a> [sm\_service\_plan](#input\_sm\_service\_plan) | The Secrets Manager plan to provision. | `string` | `"standard"` | no |

examples/complete/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module "secrets_manager" {
4242
secrets_manager_name = "${var.prefix}-secrets-manager" #tfsec:ignore:general-secrets-no-plaintext-exposure
4343
sm_service_plan = var.sm_service_plan
4444
sm_tags = var.resource_tags
45-
service_endpoints = "public-and-private"
4645
kms_encryption_enabled = true
4746
existing_kms_instance_guid = module.key_protect.kms_guid
4847
kms_key_crn = module.key_protect.keys["${var.prefix}-sm.${var.prefix}-sm-key"].crn

main.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
# Validation
66
locals {
7-
allowed_network = var.service_endpoints == "private" ? "private-only" : "public-and-private"
8-
97
# Validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
108
# tflint-ignore: terraform_unused_declarations
119
validate_kms_values = (!var.kms_encryption_enabled && var.kms_key_crn != null) ? tobool("When passing values for var.kms_key_crn, you must set var.kms_encryption_enabled to true. Otherwise unset them to use default encryption") : (!var.kms_encryption_enabled && var.existing_kms_instance_guid != null) ? tobool("When passing values for var.existing_kms_instance_guid, you must set var.kms_encryption_enabled to true. Otherwise unset them to use default encryption") : true
@@ -16,21 +14,20 @@ locals {
1614
# tflint-ignore: terraform_unused_declarations
1715
validate_event_notification = var.enable_event_notification && var.existing_en_instance_crn == null ? tobool("When setting var.enable_event_notification to true, a value must be passed for var.existing_en_instance_crn") : true
1816
# tflint-ignore: terraform_unused_declarations
19-
validate_endpoint = var.enable_event_notification && (var.endpoint_type == "public" && var.service_endpoints == "private") || (var.endpoint_type == "private" && var.service_endpoints == "public") ? tobool("It is not allowed to have conflicting var.endpoint_type and var.service_endpoints values.") : true
17+
validate_endpoint = var.enable_event_notification && var.endpoint_type == "public" && var.allowed_network == "private-only" ? tobool("It is not allowed to have conflicting var.endpoint_type and var.allowed_network values.") : true
2018
}
2119

2220
# Create Secrets Manager Instance
2321
resource "ibm_resource_instance" "secrets_manager_instance" {
2422
depends_on = [ibm_iam_authorization_policy.kms_policy]
2523
name = var.secrets_manager_name
2624
service = "secrets-manager"
27-
service_endpoints = var.service_endpoints
2825
plan = var.sm_service_plan
2926
location = var.region
3027
resource_group_id = var.resource_group_id
3128
tags = var.sm_tags
3229
parameters = {
33-
"allowed_network" = local.allowed_network
30+
"allowed_network" = var.allowed_network
3431
"kms_instance" = var.existing_kms_instance_guid
3532
"kms_key" = var.kms_key_crn
3633
}

modules/fscloud/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "secrets_manager" {
55
secrets_manager_name = var.secrets_manager_name #tfsec:ignore:general-secrets-no-plaintext-exposure
66
sm_service_plan = var.service_plan
77
sm_tags = var.sm_tags
8-
service_endpoints = "private"
8+
allowed_network = "private-only"
99
endpoint_type = "private"
1010
kms_encryption_enabled = true
1111
existing_kms_instance_guid = var.existing_kms_instance_guid

solutions/standard/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module "secrets_manager" {
5656
region = var.region
5757
secrets_manager_name = var.secrets_manager_instance_name
5858
sm_service_plan = var.service_plan
59-
service_endpoints = var.service_endpoints
59+
allowed_network = var.allowed_network
6060
sm_tags = var.secret_manager_tags
6161
# kms dependency
6262
kms_encryption_enabled = true
@@ -67,5 +67,5 @@ module "secrets_manager" {
6767
enable_event_notification = var.existing_en_instance_crn != null ? true : false
6868
existing_en_instance_crn = var.existing_en_instance_crn
6969
skip_en_iam_authorization_policy = var.skip_en_iam_authorization_policy
70-
endpoint_type = var.service_endpoints == "private" ? var.service_endpoints : "public"
70+
endpoint_type = var.allowed_network == "private-only" ? "private" : "public"
7171
}

solutions/standard/variables.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ variable "service_plan" {
4545
}
4646
}
4747

48-
variable "service_endpoints" {
49-
# public-and-private until IBM Console connects to SM via private endpoints
48+
variable "allowed_network" {
5049
type = string
51-
description = "The service endpoints to enable for all services deployed by this solution. Allowed values are `private` or `public-and-private`. If selecting `public-and-private`, communication to the instances will all be done over the public endpoints. Ensure to enable virtual routing and forwarding (VRF) in your account if using `private`, and that the terraform runtime has access to the the IBM Cloud private network."
50+
description = "The types of service endpoints to set on the Secrets Manager instance. Possible values are `private-only` or `public-and-private`."
5251
default = "public-and-private"
5352
validation {
54-
condition = contains(["private", "public-and-private"], var.service_endpoints)
55-
error_message = "The specified service_endpoints is not a valid selection. Allowed values are `private` or `public-and-private`."
53+
condition = contains(["private-only", "public-and-private"], var.allowed_network)
54+
error_message = "The specified allowed_network is not a valid selection!"
5655
}
5756
}
5857

tests/pr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func TestRunDASolutionSchematics(t *testing.T) {
131131
{Name: "region", Value: options.Region, DataType: "string"},
132132
{Name: "resource_group_name", Value: options.Prefix, DataType: "string"},
133133
{Name: "service_plan", Value: "trial", DataType: "string"},
134-
{Name: "service_endpoints", Value: "private", DataType: "string"},
134+
{Name: "allowed_network", Value: "private-only", DataType: "string"},
135135
{Name: "existing_kms_guid", Value: permanentResources["hpcs_south"], DataType: "string"},
136136
{Name: "kms_region", Value: "us-south", DataType: "string"}, // KMS instance is in us-south
137137
}

variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ variable "sm_tags" {
3333
default = []
3434
}
3535

36-
variable "service_endpoints" {
36+
variable "allowed_network" {
3737
type = string
38-
description = "The types of service endpoints to set on the Secrets Manager instance. Possible values are `public`, `private` or `public-and-private`."
38+
description = "The types of service endpoints to set on the Secrets Manager instance. Possible values are `private-only` or `public-and-private`."
3939
default = "public-and-private"
4040
validation {
41-
condition = contains(["public", "private", "public-and-private"], var.service_endpoints)
42-
error_message = "The specified service_endpoints is not a valid selection!"
41+
condition = contains(["private-only", "public-and-private"], var.allowed_network)
42+
error_message = "The specified allowed_network is not a valid selection!"
4343
}
4444
}
4545

0 commit comments

Comments
 (0)