From 4df52f9c481ce19f8f18696046eca314a5fca986 Mon Sep 17 00:00:00 2001 From: yesh-naik-12 Date: Thu, 17 Feb 2022 01:30:23 +0530 Subject: [PATCH] version update Version update and restructured resources --- s3-bucket.tf | 37 ++++++++++++++++++++++++------------- versions.tf | 1 + 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/s3-bucket.tf b/s3-bucket.tf index 7a377fe..63d392f 100755 --- a/s3-bucket.tf +++ b/s3-bucket.tf @@ -1,30 +1,41 @@ resource "aws_s3_bucket" "config" { - acl = "log-delivery-write" bucket = local.config_name lifecycle { prevent_destroy = true } + + tags = var.tags +} - lifecycle_rule { - id = "log" - enabled = true +resource "aws_s3_bucket_logging" "config" { + bucket = aws_s3_bucket.config.id - transition { - days = var.transition_to_glacier - storage_class = "GLACIER" - } + target_bucket = var.log_bucket + target_prefix = "s3/${local.config_name}/" +} + +resource "aws_s3_bucket_acl" "config" { + bucket = aws_s3_bucket.config.id + acl = "log-delivery-write" +} + +resource "aws_s3_bucket_lifecycle_configuration" "config" { + bucket = aws_s3_bucket.config.bucket + rule { + id = "log" expiration { days = var.expiration } - } - logging { - target_bucket = var.log_bucket - target_prefix = "s3/${local.config_name}/" + status = "Enabled" + + transition { + days = var.transition_to_glacier + storage_class = "GLACIER" + } } - tags = var.tags } data "aws_iam_policy_document" "config" { diff --git a/versions.tf b/versions.tf index 241ac05..6bcb5e0 100644 --- a/versions.tf +++ b/versions.tf @@ -4,6 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" + version = ">= 4.0.0" } } }