Add predefined tags

This commit is contained in:
Serge Logvinov
2022-01-04 00:12:06 +02:00
parent 353ce8ec59
commit b74ab73aba
16 changed files with 201 additions and 3 deletions

View File

@@ -13,3 +13,8 @@ output "key_file" {
description = "key_file"
value = "~/.oci/oci_${var.project}_terraform.pem"
}
output "tags" {
description = "tags"
value = [for tag, value in var.tags : "${oci_identity_tag_namespace.kubernetes.name}.${tag}"]
}

View File

@@ -5,6 +5,7 @@ resource "oci_identity_policy" "terraform" {
compartment_id = oci_identity_compartment.project.id
statements = [
"Allow group ${oci_identity_group.terraform.name} to use tag-namespaces in compartment ${oci_identity_compartment.project.name}",
"Allow group ${oci_identity_group.terraform.name} to manage virtual-network-family in compartment ${oci_identity_compartment.project.name}",
"Allow group ${oci_identity_group.terraform.name} to manage load-balancers in compartment ${oci_identity_compartment.project.name}",
"Allow group ${oci_identity_group.terraform.name} to manage dns in compartment ${oci_identity_compartment.project.name}",

13
oracle/init/tags.tf Normal file
View File

@@ -0,0 +1,13 @@
resource "oci_identity_tag_namespace" "kubernetes" {
compartment_id = oci_identity_compartment.project.id
name = "Kubernetes"
description = "Default kubernetes infrastructure tags"
}
resource "oci_identity_tag" "tags" {
for_each = var.tags
name = each.key
description = each.value
tag_namespace_id = oci_identity_tag_namespace.kubernetes.id
}

View File

@@ -12,3 +12,13 @@ variable "project" {
type = string
default = "main"
}
variable "tags" {
description = "Defined Tags of resources"
type = map(string)
default = {
"Environment" = "Resource environment"
"Role" = "Kubernetes node role"
"Type" = "Type of resource"
}
}

View File

@@ -3,7 +3,7 @@ terraform {
required_providers {
oci = {
source = "hashicorp/oci"
version = "4.56.0"
version = "4.57.0"
}
}
}