From b30b3a5fd21d98e0626703b072b1832f3c353664 Mon Sep 17 00:00:00 2001 From: Guillermo Contreras Date: Fri, 13 Sep 2024 11:39:00 -0600 Subject: [PATCH 1/2] Add variable to tag bucket --- CHANGELOG.md | 4 ++++ README.md | 3 +++ s3_bucket.tf | 2 ++ variables_s3.tf | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0d3567..a7683be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Release Version: 1.1.0 +ENHANCEMENTS: +* Add variable to tag bucket + ## Release Version: 1.0.1 ENHANCEMENTS: * Fix deprecated terraform resources diff --git a/README.md b/README.md index c7cf543..57ce5fe 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ User-Info = [ "bucket_key: my-s3-bucket/Louie" ] ``` + ## Requirements | Name | Version | @@ -250,6 +251,7 @@ No modules. | [s3\_lifecycle\_prevent\_destroy](#input\_s3\_lifecycle\_prevent\_destroy) | Prevent/allow terraform to destroy the bucket | `bool` | `false` | no | | [s3\_versioning\_enabled](#input\_s3\_versioning\_enabled) | To enable file versioning | `bool` | `false` | no | | [suffix](#input\_suffix) | A suffix which is added to each resource name. | `string` | `""` | no | +| [tags](#input\_tags) | Tags to be added to the bucket | `map(string)` | `{}` | no | ## Outputs @@ -261,3 +263,4 @@ No modules. | [s3\_get\_delete\_user\_info](#output\_s3\_get\_delete\_user\_info) | n/a | | [s3\_list\_delete\_user\_info](#output\_s3\_list\_delete\_user\_info) | n/a | | [standard\_user\_info](#output\_standard\_user\_info) | n/a | + \ No newline at end of file diff --git a/s3_bucket.tf b/s3_bucket.tf index 0707ed0..3a64442 100644 --- a/s3_bucket.tf +++ b/s3_bucket.tf @@ -1,6 +1,8 @@ # The S3 bucket resource "aws_s3_bucket" "s3_bucket" { bucket = var.s3_bucket_name + + tags = merge({ Name = var.s3_bucket_name, role = "storage" }, var.tags) } resource "aws_s3_bucket_acl" "name" { diff --git a/variables_s3.tf b/variables_s3.tf index 5c53017..59f90b8 100644 --- a/variables_s3.tf +++ b/variables_s3.tf @@ -47,4 +47,10 @@ variable "lifecycle_config_rule_id" { description = "ID of the lifecycle configuration rule" default = "" type = string +} + +variable "tags" { + description = "Tags to be added to the bucket" + type = map(string) + default = {} } \ No newline at end of file From 0dfa245ca0a7ae42a119ce6b4e28b8020bcc0b20 Mon Sep 17 00:00:00 2001 From: Guillermo Contreras Date: Wed, 18 Sep 2024 10:48:26 -0600 Subject: [PATCH 2/2] Remove extra tag key --- s3_bucket.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3_bucket.tf b/s3_bucket.tf index 3a64442..6f9d8d3 100644 --- a/s3_bucket.tf +++ b/s3_bucket.tf @@ -2,7 +2,7 @@ resource "aws_s3_bucket" "s3_bucket" { bucket = var.s3_bucket_name - tags = merge({ Name = var.s3_bucket_name, role = "storage" }, var.tags) + tags = merge({ Name = var.s3_bucket_name }, var.tags) } resource "aws_s3_bucket_acl" "name" {