Skip to content

Commit 4098bd6

Browse files
authored
fix: updated multiservice example (#423) <br> * This release fixes the multi-service-profile example with location update. <br> * location variable of cbr-service-profile submodule is now required (no default)
* fix: updated multiservice example with the correct location and updated variable validaiton logic * udpated the location variable as null
1 parent c6032c9 commit 4098bd6

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

examples/multi-service-profile/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variable "ibmcloud_api_key" {
77
variable "prefix" {
88
type = string
99
description = "Prefix to append to all resources created by this example"
10-
default = "test-terraform-multizone"
10+
default = "test-terraform-multiservice"
1111
}
1212

1313
variable "region" {
@@ -19,7 +19,7 @@ variable "region" {
1919
variable "location" {
2020
description = "The region in which the network zone is scoped"
2121
type = string
22-
default = "us-south"
22+
default = "dal" # dal metro is the equivalent location for the us-south region
2323
}
2424

2525
variable "resource_group" {
@@ -36,7 +36,7 @@ variable "resource_tags" {
3636

3737
variable "zone_service_ref_list" {
3838
type = list(string)
39-
default = ["cloud-object-storage", "containers-kubernetes", "server-protect"]
39+
default = ["cloud-object-storage", "server-protect"]
4040
description = "(List) Service reference for the zone creation"
4141
}
4242

modules/cbr-service-profile/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module "cbr_rule_multi_service_profile" {
4949
| Name | Description | Type | Default | Required |
5050
|------|-------------|------|---------|:--------:|
5151
| <a name="input_endpoints"></a> [endpoints](#input\_endpoints) | List specific endpoint types for target services, valid values for endpoints are 'public', 'private' or 'direct' | `list(string)` | <pre>[<br> "private"<br>]</pre> | no |
52-
| <a name="input_location"></a> [location](#input\_location) | The region in which the network zone is scoped | `string` | `"us-south"` | no |
52+
| <a name="input_location"></a> [location](#input\_location) | The region in which the network zone is scoped | `string` | n/a | yes |
5353
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Prefix to append to all vpc\_zone\_list, service\_ref\_zone\_list and cbr\_rule\_description created by this submodule | `string` | `"serviceprofile"` | no |
5454
| <a name="input_target_service_details"></a> [target\_service\_details](#input\_target\_service\_details) | (String) Details of the target service for which the rule has to be created | <pre>list(object({<br> target_service_name = string<br> target_rg = optional(string)<br> enforcement_mode = string<br> tags = optional(list(string))<br> }))</pre> | n/a | yes |
5555
| <a name="input_zone_service_ref_list"></a> [zone\_service\_ref\_list](#input\_zone\_service\_ref\_list) | (List) Service reference for the zone creation | `list(string)` | `[]` | no |

modules/cbr-service-profile/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ locals {
1212
# tflint-ignore: terraform_unused_declarations
1313
validate_zone_inputs = ((length(var.zone_vpc_crn_list) == 0) && (length(var.zone_service_ref_list) == 0)) ? tobool("Error: Provide a valid zone vpc and/or service references") : true
1414
# tflint-ignore: terraform_unused_declarations
15-
validate_location_and_service_name = ((contains(["compliance", "directlink", "iam-groups", "containers-kubernetes", "user-management"], var.zone_service_ref_list)) && var.location != null) ? tobool("Error: The services 'compliance','directlink','iam-groups','containers-kubernetes','user-management' does not support location") : true
15+
validate_location_and_service_name = (length(setintersection(["compliance", "directlink", "iam-groups", "containers-kubernetes", "user-management"], var.zone_service_ref_list)) > 0 && var.location != null) ? tobool("Error: The services 'compliance','directlink','iam-groups','containers-kubernetes','user-management' does not support location") : true
16+
17+
1618

1719
# Restrict and allow the api types as per the target service
1820
icd_api_types = ["crn:v1:bluemix:public:context-based-restrictions::::api-type:data-plane"]
@@ -58,7 +60,6 @@ locals {
5860

5961
zone_list = concat(tolist(local.vpc_zone_list), tolist(local.service_ref_zone_list))
6062
}
61-
6263
module "cbr_zone" {
6364
count = length(local.zone_list)
6465
source = "../cbr-zone-module"

modules/cbr-service-profile/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ variable "zone_service_ref_list" {
3838
variable "location" {
3939
type = string
4040
description = "The region in which the network zone is scoped"
41-
default = "us-south"
4241
}
4342

4443
variable "target_service_details" {

tests/pr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func TestMultiServiceProfileExample(t *testing.T) {
211211
t.Run("verify service reference exist", func(t *testing.T) {
212212
var serviceRefExists bool
213213
var actual_references []string
214-
expected_references := []string{"cloud-object-storage", "containers-kubernetes", "server-protect"}
214+
expected_references := []string{"cloud-object-storage", "server-protect"}
215215

216216
zoneIds := zones[0].([]interface{})
217217
for index := range zoneIds {

0 commit comments

Comments
 (0)