Skip to content

Commit e88acd9

Browse files
Make label prefix optional (#4)
Signed-off-by: Karthic Ravindran <[email protected]>
1 parent 17c4431 commit e88acd9

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

compute.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ resource "oci_core_instance" "bastion" {
88

99
create_vnic_details {
1010
assign_public_ip = true
11-
display_name = "${var.label_prefix}-bastion-vnic"
11+
display_name = var.label_prefix == "none" ? "bastion-vnic" : "${var.label_prefix}-bastion-vnic"
1212
hostname_label = "bastion"
1313
subnet_id = oci_core_subnet.bastion[0].id
1414
}
1515

16-
display_name = "${var.label_prefix}-bastion"
16+
display_name = var.label_prefix == "none" ? "bastion" : "${var.label_prefix}-bastion"
1717

1818
# prevent the bastion from destroying and recreating itself if the image ocid changes
1919
lifecycle {

examples/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ variable "compartment_id" {
4040
variable "label_prefix" {
4141
description = "a string that will be prepended to all resources"
4242
type = string
43+
default = "none"
4344
}
4445

4546
# bastion module parameters

ons.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ provider "oci" {
1212

1313
resource "oci_ons_notification_topic" "bastion_notification" {
1414
compartment_id = var.compartment_id
15-
name = "${var.label_prefix}-${var.notification_topic}"
15+
name = var.label_prefix == "none" ? var.notification_topic : "${var.label_prefix}-${var.notification_topic}"
1616

1717
count = (var.bastion_enabled == true && var.notification_enabled == true) ? 1 : 0
1818
}
@@ -33,7 +33,7 @@ resource "oci_identity_dynamic_group" "bastion_notification" {
3333
depends_on = [oci_core_instance.bastion]
3434
description = "dynamic group to allow bastion to send notifications to ONS"
3535
matching_rule = "ALL {instance.id = '${join(",", data.oci_core_instance.bastion.*.id)}'}"
36-
name = "${var.label_prefix}-bastion-notification"
36+
name = var.label_prefix == "none" ? "bastion-notification" : "${var.label_prefix}-bastion-notification"
3737

3838
count = (var.bastion_enabled == true && var.notification_enabled == true) ? 1 : 0
3939
}
@@ -44,7 +44,7 @@ resource "oci_identity_policy" "bastion_notification" {
4444
compartment_id = var.compartment_id
4545
depends_on = [oci_core_instance.bastion]
4646
description = "policy to allow bastion host to publish messages to ONS"
47-
name = "${var.label_prefix}-bastion-notification"
47+
name = var.label_prefix == "none" ? "bastion-notification" : "${var.label_prefix}-bastion-notification"
4848
statements = ["Allow dynamic-group ${oci_identity_dynamic_group.bastion_notification[0].name} to use ons-topic in compartment id ${var.compartment_id} where request.permission='ONS_TOPIC_PUBLISH'"]
4949

5050
count = (var.bastion_enabled == true && var.notification_enabled == true) ? 1 : 0

security.tf

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

44
resource "oci_core_security_list" "bastion" {
55
compartment_id = var.compartment_id
6-
display_name = "${var.label_prefix}-bastion"
6+
display_name = var.label_prefix == "none" ? "bastion" : "${var.label_prefix}-bastion"
77
freeform_tags = var.tags
88

99
egress_security_rules {

subnets.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
resource "oci_core_subnet" "bastion" {
55
cidr_block = cidrsubnet(local.vcn_cidr, var.newbits, var.netnum)
66
compartment_id = var.compartment_id
7-
display_name = "${var.label_prefix}-bastion"
7+
display_name = var.label_prefix == "none" ? "bastion" : "${var.label_prefix}-bastion"
88
dns_label = "bastion"
99
freeform_tags = var.tags
1010
prohibit_public_ip_on_vnic = false

variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ variable "compartment_id" {
4242
variable "label_prefix" {
4343
description = "a string that will be prepended to all resources"
4444
type = string
45+
default = "none"
4546
}
4647

4748
# network parameters

0 commit comments

Comments
 (0)