Skip to content

Commit

Permalink
fixed s3 bucket definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Bakhmetev committed Sep 16, 2024
1 parent 9de8a9f commit 573dcfc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tf-aws-s3-bucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ locals {

full_name = var.bucket_name != "" && !var.include_prefix ? var.bucket_name : "${module.name.id}-${var.bucket_name}"
bucket_name = var.include_account_id ? "${local.partition}-${local.full_name}" : local.full_name
bucket_id = join("", aws_s3_bucket.default[*].id)
bucket_id = join("", aws_s3_bucket.this.id)
bucket_arn = "arn:${local.partition}:s3:::${local.bucket_id}"
}

Expand All @@ -24,21 +24,21 @@ module "name" {
tags = var.tags
}

resource "aws_s3_bucket" "default" {
resource "aws_s3_bucket" "this" {
bucket = local.bucket_name

tags = module.this.tags
}

resource "aws_s3_bucket_versioning" "default" {
resource "aws_s3_bucket_versioning" "this" {
bucket = local.bucket_id

versioning_configuration {
status = var.versioning_enabled ? "Enabled" : "Suspended"
}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
bucket = local.bucket_id

rule {
Expand Down Expand Up @@ -141,18 +141,18 @@ data "aws_iam_policy_document" "bucket_policy" {
}
}

resource "aws_s3_bucket_policy" "default" {
resource "aws_s3_bucket_policy" "this" {
count = (
var.allow_ssl_requests_only ||
var.allow_encrypted_uploads_only
) ? 1 : 0

bucket = local.bucket_id
policy = one(data.aws_iam_policy_document.bucket_policy[*].json)
depends_on = [aws_s3_bucket_public_access_block.default]
depends_on = [aws_s3_bucket_public_access_block.this]
}

resource "aws_s3_bucket_public_access_block" "default" {
resource "aws_s3_bucket_public_access_block" "this" {
bucket = local.bucket_id

block_public_acls = var.block_public_acls
Expand Down

0 comments on commit 573dcfc

Please sign in to comment.