From 043ff7506fba61f0e1a9e975f393161c04c1d9c7 Mon Sep 17 00:00:00 2001 From: robervexcel Date: Fri, 15 Mar 2024 14:58:24 +0100 Subject: [PATCH] add-s3-extra-tags --- main.tf | 3 +++ modules/backup/main.tf | 4 +--- modules/backup/variables.tf | 12 ++++++++++++ modules/cluster/storage.tf | 12 +++--------- modules/cluster/variables.tf | 13 +++++++++++++ modules/vault/main.tf | 4 +--- modules/vault/variables.tf | 12 ++++++++++++ variables.tf | 6 ++++++ 8 files changed, 51 insertions(+), 15 deletions(-) diff --git a/main.tf b/main.tf index 7311f1a..f6b2914 100644 --- a/main.tf +++ b/main.tf @@ -67,6 +67,7 @@ module "cluster" { iops = var.iops use_kms_s3 = var.use_kms_s3 s3_kms_arn = var.s3_kms_arn + s3_extra_tags = var.s3_extra_tags is_jx2 = var.is_jx2 content = local.content cluster_endpoint_public_access = var.cluster_endpoint_public_access @@ -123,6 +124,7 @@ module "vault" { use_vault = var.use_vault region = var.region enable_acl = var.enable_acl + s3_extra_tags = var.s3_extra_tags } // ---------------------------------------------------------------------------- @@ -137,6 +139,7 @@ module "backup" { velero_username = var.velero_username create_velero_role = var.create_velero_role enable_acl = var.enable_acl + s3_extra_tags = var.s3_extra_tags } // ---------------------------------------------------------------------------- diff --git a/modules/backup/main.tf b/modules/backup/main.tf index 94fb121..940894d 100644 --- a/modules/backup/main.tf +++ b/modules/backup/main.tf @@ -12,9 +12,7 @@ locals { resource "aws_s3_bucket" "backup_bucket" { count = var.enable_backup ? 1 : 0 bucket_prefix = "backup-${lower(var.cluster_name)}-" - tags = { - Owner = "Jenkins-x" - } + tags = merge(var.s3_default_tags, var.s3_extra_tags) force_destroy = var.force_destroy } diff --git a/modules/backup/variables.tf b/modules/backup/variables.tf index 5fb08e9..5a1c02a 100644 --- a/modules/backup/variables.tf +++ b/modules/backup/variables.tf @@ -39,6 +39,18 @@ variable "s3_kms_arn" { default = "" } +variable "s3_default_tags" { + description = "Default tags for s3 buckets" + type = map + default = { Owner = "Jenkins-x" } +} + +variable "s3_extra_tags" { + description = "Add new tags for s3 buckets" + type = map + default = {} +} + variable "is_jx2" { default = true type = bool diff --git a/modules/cluster/storage.tf b/modules/cluster/storage.tf index fb23046..1194021 100644 --- a/modules/cluster/storage.tf +++ b/modules/cluster/storage.tf @@ -13,9 +13,7 @@ locals { resource "aws_s3_bucket" "logs_jenkins_x" { count = var.enable_logs_storage ? 1 : 0 bucket_prefix = "logs-${lower(var.cluster_name)}-" - tags = { - Owner = "Jenkins-x" - } + tags = merge(var.s3_default_tags, var.s3_extra_tags) force_destroy = var.force_destroy } @@ -52,9 +50,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "logs_jenkins_x" { resource "aws_s3_bucket" "reports_jenkins_x" { count = var.enable_reports_storage ? 1 : 0 bucket_prefix = "reports-${lower(var.cluster_name)}-" - tags = { - Owner = "Jenkins-x" - } + tags = merge(var.s3_default_tags, var.s3_extra_tags) force_destroy = var.force_destroy } @@ -92,9 +88,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "reports_jenkins_x resource "aws_s3_bucket" "repository_jenkins_x" { count = var.enable_repository_storage ? 1 : 0 bucket_prefix = "repository-${lower(var.cluster_name)}-" - tags = { - Owner = "Jenkins-x" - } + tags = merge(var.s3_default_tags, var.s3_extra_tags) force_destroy = var.force_destroy } diff --git a/modules/cluster/variables.tf b/modules/cluster/variables.tf index 3f2a729..dde045b 100644 --- a/modules/cluster/variables.tf +++ b/modules/cluster/variables.tf @@ -167,6 +167,19 @@ variable "use_kms_s3" { default = false } +variable "s3_default_tags" { + description = "Default tags for s3 buckets" + type = map + default = { Owner = "Jenkins-x" } +} + +variable "s3_extra_tags" { + description = "Add new tags for s3 buckets" + type = map + default = {} +} + + variable "map_accounts" { description = "Additional AWS account numbers to add to the aws-auth configmap." type = list(string) diff --git a/modules/vault/main.tf b/modules/vault/main.tf index ba0f91c..1d24e06 100644 --- a/modules/vault/main.tf +++ b/modules/vault/main.tf @@ -37,9 +37,7 @@ resource "aws_s3_bucket" "vault-unseal-bucket" { count = local.create_vault_resources ? 1 : 0 bucket_prefix = "vault-unseal-${lower(var.cluster_name)}-" - tags = { - Name = "Vault unseal bucket" - } + tags = merge(var.s3_default_tags, var.s3_extra_tags) force_destroy = var.force_destroy } diff --git a/modules/vault/variables.tf b/modules/vault/variables.tf index 86a7686..e54ce69 100644 --- a/modules/vault/variables.tf +++ b/modules/vault/variables.tf @@ -69,6 +69,18 @@ variable "s3_kms_arn" { default = "" } +variable "s3_default_tags" { + description = "Default tags for s3 buckets" + type = map + default = { Name = "Vault unseal bucket" } +} + +variable "s3_extra_tags" { + description = "Add new tags for s3 buckets" + type = map + default = {} +} + variable "is_jx2" { default = true type = bool diff --git a/variables.tf b/variables.tf index 7b5661c..e8050b4 100644 --- a/variables.tf +++ b/variables.tf @@ -334,6 +334,12 @@ variable "s3_kms_arn" { default = "" } +variable "s3_extra_tags" { + description = "Add new tags for s3 buckets" + type = map + default = {} +} + variable "is_jx2" { default = true type = bool