Skip to content

Commit 51856ff

Browse files
authored
fix: add fix to support passing null for the prefix input variable (#605)
1 parent 25cfdca commit 51856ff

File tree

9 files changed

+12
-14
lines changed

9 files changed

+12
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ To attach access management tags to resources in this module, you need the follo
144144
| <a name="input_name"></a> [name](#input\_name) | Name for VPC | `string` | n/a | yes |
145145
| <a name="input_network_acls"></a> [network\_acls](#input\_network\_acls) | The list of ACLs to create. Provide at least one rule for each ACL. | <pre>list(<br> object({<br> name = string<br> add_ibm_cloud_internal_rules = optional(bool)<br> add_vpc_connectivity_rules = optional(bool)<br> prepend_ibm_rules = optional(bool)<br> rules = list(<br> object({<br> name = string<br> action = string<br> destination = string<br> direction = string<br> source = string<br> tcp = optional(<br> object({<br> port_max = optional(number)<br> port_min = optional(number)<br> source_port_max = optional(number)<br> source_port_min = optional(number)<br> })<br> )<br> udp = optional(<br> object({<br> port_max = optional(number)<br> port_min = optional(number)<br> source_port_max = optional(number)<br> source_port_min = optional(number)<br> })<br> )<br> icmp = optional(<br> object({<br> type = optional(number)<br> code = optional(number)<br> })<br> )<br> })<br> )<br> })<br> )</pre> | <pre>[<br> {<br> "add_ibm_cloud_internal_rules": true,<br> "add_vpc_connectivity_rules": true,<br> "name": "vpc-acl",<br> "prepend_ibm_rules": true,<br> "rules": []<br> }<br>]</pre> | no |
146146
| <a name="input_network_cidrs"></a> [network\_cidrs](#input\_network\_cidrs) | List of Network CIDRs for the VPC. This is used to manage network ACL rules for cluster provisioning. | `list(string)` | <pre>[<br> "10.0.0.0/8"<br>]</pre> | no |
147-
| <a name="input_prefix"></a> [prefix](#input\_prefix) | The prefix that you would like to append to your resources | `string` | n/a | yes |
147+
| <a name="input_prefix"></a> [prefix](#input\_prefix) | The prefix that you would like to append to your resources. Explicitly set to null if you do not wish to use a prefix. | `string` | n/a | yes |
148148
| <a name="input_region"></a> [region](#input\_region) | The region to which to deploy the VPC | `string` | n/a | yes |
149149
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the VPC to be created | `string` | n/a | yes |
150150
| <a name="input_routes"></a> [routes](#input\_routes) | OPTIONAL - Allows you to specify the next hop for packets based on their destination address | <pre>list(<br> object({<br> name = string<br> route_direct_link_ingress = optional(bool)<br> route_transit_gateway_ingress = optional(bool)<br> route_vpc_zone_ingress = optional(bool)<br> routes = optional(<br> list(<br> object({<br> action = optional(string)<br> zone = number<br> destination = string<br> next_hop = string<br> })<br> ))<br> })<br> )</pre> | `[]` | no |

common-dev-assets

dynamic_values.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module "dynamic_values" {
66
source = "./dynamic_values"
7-
prefix = "${var.prefix}-${var.name}"
7+
prefix = var.prefix != null ? "${var.prefix}-${var.name}" : var.name
88
region = var.region
99
address_prefixes = var.address_prefixes
1010
routes = var.routes

dynamic_values/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717
for address in var.address_prefixes[zone] :
1818
# Return object containing name, zone, and CIDR
1919
{
20-
name = "${var.prefix}-${zone}-${index(var.address_prefixes[zone], address) + 1}"
20+
name = var.prefix != null ? "${var.prefix}-${zone}-${index(var.address_prefixes[zone], address) + 1}" : "{${zone}-${index(var.address_prefixes[zone], address) + 1}"
2121
cidr = address
2222
zone = "${var.region}-${index(keys(var.address_prefixes), zone) + 1}"
2323
}

examples/default/main.tf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ data "ibm_resource_group" "existing_resource_group" {
1919
#############################################################################
2020

2121
resource "ibm_resource_instance" "cos_instance" {
22-
count = var.enable_vpc_flow_logs ? 1 : 0
23-
22+
count = var.enable_vpc_flow_logs ? 1 : 0
2423
name = "${var.prefix}-vpc-logs-cos"
2524
resource_group_id = var.resource_group != null ? data.ibm_resource_group.existing_resource_group[0].id : ibm_resource_group.resource_group[0].id
2625
service = "cloud-object-storage"
@@ -29,8 +28,7 @@ resource "ibm_resource_instance" "cos_instance" {
2928
}
3029

3130
resource "ibm_cos_bucket" "cos_bucket" {
32-
count = var.enable_vpc_flow_logs ? 1 : 0
33-
31+
count = var.enable_vpc_flow_logs ? 1 : 0
3432
bucket_name = "${var.prefix}-vpc-logs-cos-bucket"
3533
resource_instance_id = ibm_resource_instance.cos_instance[0].id
3634
region_location = var.region

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource "time_sleep" "wait_for_authorization_policy" {
5656

5757
resource "ibm_is_vpc_routing_table" "route_table" {
5858
for_each = module.dynamic_values.routing_table_map
59-
name = "${var.prefix}-${var.name}-route-${each.value.name}"
59+
name = var.prefix != null ? "${var.prefix}-${var.name}-route-${each.value.name}" : "${var.name}-route-${each.value.name}"
6060
vpc = ibm_is_vpc.vpc.id
6161
route_direct_link_ingress = each.value.route_direct_link_ingress
6262
route_transit_gateway_ingress = each.value.route_transit_gateway_ingress
@@ -91,7 +91,7 @@ locals {
9191

9292
resource "ibm_is_public_gateway" "gateway" {
9393
for_each = local.gateway_object
94-
name = "${var.prefix}-${var.name}-public-gateway-${each.key}"
94+
name = var.prefix != null ? "${var.prefix}-${var.name}-public-gateway-${each.key}" : "${var.name}-public-gateway-${each.key}"
9595
vpc = ibm_is_vpc.vpc.id
9696
resource_group = var.resource_group_id
9797
zone = each.value
@@ -125,7 +125,7 @@ resource "ibm_iam_authorization_policy" "policy" {
125125
resource "ibm_is_flow_log" "flow_logs" {
126126
count = (var.enable_vpc_flow_logs) ? 1 : 0
127127

128-
name = "${var.prefix}-${var.name}-logs"
128+
name = var.prefix != null ? "${var.prefix}-${var.name}-logs" : "${var.name}-logs"
129129
target = ibm_is_vpc.vpc.id
130130
active = var.is_flow_log_collector_active
131131
storage_bucket = var.existing_storage_bucket_name

module-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
"prefix": {
266266
"name": "prefix",
267267
"type": "string",
268-
"description": "The prefix that you would like to append to your resources",
268+
"description": "The prefix that you would like to append to your resources. Explicitly set to null if you do not wish to use a prefix.",
269269
"required": true,
270270
"source": [
271271
"ibm_is_flow_log.flow_logs.name",

network_acls.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ locals {
161161

162162
resource "ibm_is_network_acl" "network_acl" {
163163
for_each = local.acl_object
164-
name = "${var.prefix}-${each.key}" #already has name of vpc in each.key
164+
name = var.prefix != null ? "${var.prefix}-${each.key}" : each.key #already has name of vpc in each.key
165165
vpc = ibm_is_vpc.vpc.id
166166
resource_group = var.resource_group_id
167167
access_tags = var.access_tags

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ variable "region" {
1818
}
1919

2020
variable "prefix" {
21-
description = "The prefix that you would like to append to your resources"
21+
description = "The prefix that you would like to append to your resources. Explicitly set to null if you do not wish to use a prefix."
2222
type = string
2323
}
2424

0 commit comments

Comments
 (0)