Skip to content

Commit 7b705e7

Browse files
committed
support for defined tags for all resources
Signed-off-by: junior <junior@users.noreply.github.com>
1 parent fb104ed commit 7b705e7

File tree

17 files changed

+88
-128
lines changed

17 files changed

+88
-128
lines changed

module-cluster-tools.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module "cluster-tools" {
1010
# compartment_ocid = var.compartment_ocid
1111
region = var.region
1212

13-
# Deployment Tags + Freeform Tags
14-
freeform_deployment_tags = local.freeform_deployment_tags
13+
# Deployment Tags + Freeform Tags + Defined Tags
14+
oci_tag_values = local.oci_tag_values
1515

1616
# Cluster Tools
1717
## Namespace

module-oke.tf

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ module "vault" {
1313
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
1414
tenancy_ocid = var.tenancy_ocid
1515

16-
# Deployment Tags + Freeform Tags
17-
freeform_deployment_tags = local.freeform_deployment_tags
16+
# Deployment Tags + Freeform Tags + Defined Tags
17+
# freeform_deployment_tags = local.freeform_deployment_tags
18+
oci_tag_values = local.oci_tag_values
1819

1920
# Encryption (OCI Vault/Key Management/KMS)
2021
use_encryption_from_oci_vault = var.use_encryption_from_oci_vault
@@ -44,9 +45,9 @@ module "oke" {
4445
region = var.region
4546

4647
# Deployment Tags + Freeform Tags
47-
cluster_freeform_deployment_tags = local.freeform_deployment_tags
48-
load_balancers_freeform_deployment_tags = local.freeform_deployment_tags
49-
block_volumes_freeform_deployment_tags = local.freeform_deployment_tags
48+
cluster_tags = local.oci_tag_values
49+
load_balancers_tags = local.oci_tag_values
50+
block_volumes_tags = local.oci_tag_values
5051

5152
# OKE Cluster
5253
## create_new_oke_cluster
@@ -76,8 +77,8 @@ module "oke_node_pool" {
7677
source = "./modules/oke-node-pool"
7778

7879
# Deployment Tags + Freeform Tags
79-
node_pools_freeform_deployment_tags = local.freeform_deployment_tags
80-
worker_nodes_freeform_deployment_tags = local.freeform_deployment_tags
80+
node_pools_tags = local.oci_tag_values
81+
worker_nodes_tags = local.oci_tag_values
8182

8283
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
8384
tenancy_ocid = var.tenancy_ocid
@@ -312,11 +313,15 @@ locals {
312313
"DeploymentID" = local.deploy_id,
313314
"AppName" = var.app_name,
314315
"Quickstart" = "oke_base" }
315-
freeform_deployment_tags = merge(var.tag_values.freeformTags, local.deploy_tags)
316-
workers_public_ssh_key = var.generate_public_ssh_key ? tls_private_key.oke_worker_node_ssh_key.public_key_openssh : var.public_ssh_key
317-
app_name = var.app_name
318-
app_name_normalized = substr(replace(lower(var.app_name), " ", "-"), 0, 6)
319-
app_name_for_dns = substr(lower(replace(var.app_name, "/\\W|_|\\s/", "")), 0, 6)
316+
# freeform_deployment_tags = merge(var.tag_values.freeformTags, local.deploy_tags)
317+
oci_tag_values = {
318+
"freeformTags" = merge(var.tag_values.freeformTags, local.deploy_tags),
319+
"definedTags" = var.tag_values.definedTags
320+
}
321+
workers_public_ssh_key = var.generate_public_ssh_key ? tls_private_key.oke_worker_node_ssh_key.public_key_openssh : var.public_ssh_key
322+
app_name = var.app_name
323+
app_name_normalized = substr(replace(lower(var.app_name), " ", "-"), 0, 6)
324+
app_name_for_dns = substr(lower(replace(var.app_name, "/\\W|_|\\s/", "")), 0, 6)
320325
}
321326

322327
# OKE Outputs

modules/cluster-tools/cluster-tools.tf

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

2828
# OCI Provider
2929
variable "tenancy_ocid" {}
30-
variable "compartment_ocid" {}
30+
# variable "compartment_ocid" {}
3131
variable "region" {}
3232

3333
# Namespace

modules/cluster-tools/grafana.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ resource "kubernetes_ingress_v1" "grafana" {
199199

200200
tls {
201201
secret_name = "grafana-${var.ingress_cluster_issuer}-tls"
202-
hosts = local.ingress_hosts
202+
hosts = local.ingress_hosts
203203
}
204204
}
205205
depends_on = [helm_release.ingress_nginx, helm_release.grafana]

modules/cluster-tools/ingress-nginx.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ variable "ingress_email_issuer" {
4646
default = "no-reply@example.cloud"
4747
description = "You must replace this email address with your own. The certificate provider will use this to contact you about expiring certificates, and issues related to your account."
4848
}
49-
# Deployment Details + Freeform Tags
50-
variable "freeform_deployment_tags" {
49+
# Deployment Details + Freeform Tags + Defined Tags
50+
variable "oci_tag_values" {
5151
description = "Tags to be added to the resources"
5252
}
5353

@@ -119,7 +119,7 @@ locals {
119119
(var.ingress_tls && var.cert_manager_enabled) ? local.ingress_nginx_annotations_cert_manager : {}
120120
)
121121
ingress_hosts = compact(concat(split(",", var.ingress_hosts), [local.app_nip_io_domain]))
122-
app_name = var.freeform_deployment_tags.AppName
122+
app_name = var.oci_tag_values.freeformTags.AppName
123123
app_name_for_dns = substr(lower(replace(local.app_name, "/\\W|_|\\s/", "")), 0, 6)
124124
app_nip_io_domain = (var.ingress_nginx_enabled && var.ingress_hosts_include_nip_io) ? format("${local.app_name_for_dns}.%s.${var.nip_io_domain}", local.ingress_controller_load_balancer_ip_hex) : ""
125125
}

modules/new-subnet-from-oke-vcn/security-lists.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ resource "oci_core_security_list" "extra_subnet_security_list" {
66
compartment_id = var.oke_vcn_compartment_ocid
77
display_name = "${local.subnet_name_normalized}-seclist-${local.deploy_id}"
88
vcn_id = var.oke_vcn_ocid
9-
freeform_tags = var.freeform_deployment_tags
9+
freeform_tags = var.oci_tag_values.freeformTags
10+
defined_tags = var.oci_tag_values.definedTags
1011

1112
# Ingresses
1213

modules/new-subnet-from-oke-vcn/subnet.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ resource "oci_core_subnet" "extra_subnet" {
1212
route_table_id = oci_core_route_table.extra_subnet_route_table[0].id
1313
dhcp_options_id = var.oke_vcn_default_dhcp_ocid
1414
security_list_ids = [oci_core_security_list.extra_subnet_security_list[0].id]
15-
freeform_tags = var.freeform_deployment_tags
15+
freeform_tags = var.oci_tag_values.freeformTags
16+
defined_tags = var.oci_tag_values.definedTags
1617

1718
count = var.create_new_subnet ? 1 : 0
1819
}
@@ -21,7 +22,8 @@ resource "oci_core_route_table" "extra_subnet_route_table" {
2122
compartment_id = var.oke_vcn_compartment_ocid
2223
vcn_id = var.oke_vcn_ocid
2324
display_name = "${local.subnet_name_normalized}-route-table-${local.deploy_id}"
24-
freeform_tags = var.freeform_deployment_tags
25+
freeform_tags = var.oci_tag_values.freeformTags
26+
defined_tags = var.oci_tag_values.definedTags
2527

2628
route_rules {
2729
description = "Traffic to/from internet"

modules/new-subnet-from-oke-vcn/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ variable "subnet_name" {
4040
description = "Subnet Name"
4141
}
4242

43-
# Deployment Details + Freeform Tags
44-
variable "freeform_deployment_tags" {
43+
# Deployment Details + Freeform Tags + Defined Tags
44+
variable "oci_tag_values" {
4545
description = "Tags to be added to the resources"
4646
}
4747

4848
# Subnet Name Locals
4949
locals {
5050
subnet_name_for_dns = substr(lower(replace(var.subnet_name, "/\\W|_|\\s/", "")), 0, 6)
5151
subnet_name_normalized = substr(replace(lower(var.subnet_name), " ", "-"), 0, 6)
52-
deploy_id = var.freeform_deployment_tags.DeploymentID
52+
deploy_id = var.oci_tag_values.freeformTags.DeploymentID
5353
}

modules/oci-vault-kms/policies.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,3 @@ locals {
7373
"Allow group ${var.user_admin_group_for_vault_policy} to use key-delegate in compartment id ${var.oke_cluster_compartment_ocid}"
7474
]
7575
}
76-
77-
# Conditional locals
78-
locals {
79-
app_dynamic_group = (var.use_encryption_from_oci_vault && var.create_dynamic_group_for_nodes_in_compartment) ? oci_identity_dynamic_group.app_dynamic_group.0.name : "void"
80-
app_name_normalized = substr(replace(lower(var.freeform_deployment_tags.AppName), " ", "-"), 0, 6)
81-
app_name = var.freeform_deployment_tags.AppName
82-
deploy_id = var.freeform_deployment_tags.DeploymentID
83-
}

modules/oci-vault-kms/variables.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "existent_encryption_key_id" {
1717
}
1818

1919
# Deployment Details + Freeform Tags
20-
variable "freeform_deployment_tags" {
20+
variable "oci_tag_values" {
2121
description = "Tags to be added to the resources"
2222
}
2323

@@ -48,3 +48,11 @@ variable "create_compartment_policies" {
4848

4949
# OCI Provider
5050
variable "tenancy_ocid" {}
51+
52+
# Conditional locals
53+
locals {
54+
app_dynamic_group = (var.use_encryption_from_oci_vault && var.create_dynamic_group_for_nodes_in_compartment) ? oci_identity_dynamic_group.app_dynamic_group.0.name : "void"
55+
app_name_normalized = substr(replace(lower(var.oci_tag_values.freeformTags.AppName), " ", "-"), 0, 6)
56+
app_name = var.oci_tag_values.freeformTags.AppName
57+
deploy_id = var.oci_tag_values.freeformTags.DeploymentID
58+
}

0 commit comments

Comments
 (0)