Skip to content

Commit 897ec54

Browse files
make label prefix optional (#7)
Signed-off-by: Karthic Ravindran <[email protected]>
1 parent 8993150 commit 897ec54

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

compute.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ resource "oci_core_instance" "operator" {
88

99
create_vnic_details {
1010
assign_public_ip = false
11-
display_name = "${var.label_prefix}-operator-vnic"
12-
hostname_label = "${var.label_prefix}-operator"
11+
display_name = var.label_prefix == "none" ? "operator-vnic" : "${var.label_prefix}-operator-vnic"
12+
hostname_label = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
1313
nsg_ids = var.nsg_ids
1414
subnet_id = oci_core_subnet.operator[0].id
1515
}
1616

17-
display_name = "${var.label_prefix}-operator"
17+
display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
1818

1919
# prevent the operator from destroying and recreating itself if the image ocid changes
2020
lifecycle {

instance_principal.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resource "oci_identity_dynamic_group" "operator_instance_principal" {
1717
compartment_id = var.tenancy_id
1818
description = "dynamic group to allow instances to call services for 1 operator"
1919
matching_rule = "ALL {instance.id = '${join(",", data.oci_core_instance.operator.*.id)}'}"
20-
name = "${var.label_prefix}-operator-instance-principal"
20+
name = var.label_prefix == "none" ? "operator-instance-principal" : "${var.label_prefix}-operator-instance-principal"
2121

2222
count = var.operator_enabled == true && var.operator_instance_principal == true ? 1 : 0
2323
}
@@ -27,7 +27,7 @@ resource "oci_identity_policy" "operator_instance_principal" {
2727

2828
compartment_id = var.compartment_id
2929
description = "policy to allow operator host to call services"
30-
name = "${var.label_prefix}-operator-instance-principal"
30+
name = var.label_prefix == "none" ? "operator-instance-principal" : "${var.label_prefix}-operator-instance-principal"
3131
statements = ["Allow dynamic-group ${oci_identity_dynamic_group.operator_instance_principal[0].name} to manage all-resources in compartment id ${var.compartment_id}"]
3232

3333
count = var.operator_enabled == true && var.operator_instance_principal == 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" "operator" {
55
compartment_id = var.compartment_id
6-
display_name = "${var.label_prefix}-operator"
6+
display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
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" "operator" {
55
cidr_block = cidrsubnet(local.vcn_cidr, var.newbits, var.netnum)
66
compartment_id = var.compartment_id
7-
display_name = "${var.label_prefix}-operator"
7+
display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
88
dns_label = "operator"
99
freeform_tags = var.tags
1010
prohibit_public_ip_on_vnic = true

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)