Skip to content

Commit

Permalink
update bucket naming
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Apr 1, 2025
1 parent 2db0632 commit 771c42f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions prefixes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ locals {
"log-stream" = "lgs-"
# EKS
"eks" = "eks-"
"eks-s3" = "v-s3-eks-"
"eks-user" = "s-eks-"
"eks-role" = "r-eks-"
"eks-policy" = "p-eks-"
Expand Down
14 changes: 11 additions & 3 deletions s3.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
data "aws_caller_identity" "current" {}

## create bucket
locals {
account_id = data.aws_caller_identity.current.account_id
account_id = data.aws_caller_identity.current.account_id
bucket_name = format("%v%v-loki-%v-%v", local.prefixes["eks-s3"], var.cluster_name, local.account_id, local.region_short)
region_short = join("", [for c in split("-", var.region) : substr(c, 0, 1)])
}

data "aws_s3_bucket" "s3_server_access_logs" {
Expand All @@ -12,8 +13,15 @@ data "aws_s3_bucket" "s3_server_access_logs" {
module "loki_s3" {
source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard?ref=tf-upgrade"

bucket_name = format("%v-loki", var.cluster_name)
bucket_name = local.bucket_name
access_log_bucket = data.aws_s3_bucket.s3_server_access_logs.id

tags = var.tags

lifecycle {
precondition {
condition = length(local.bucket_name) >= 3 && length(local.bucket_name) <= 63
error_message = "S3 bucket name must be between 3 and 63 characters. Current name '${local.bucket_name}' is ${length(local.bucket_name)} characters."
}
}
}

0 comments on commit 771c42f

Please sign in to comment.