Skip to content

Commit 5cee1a8

Browse files
jpvelezcursoragent
andcommitted
Make additional S3 buckets configurable via variable
Replace hardcoded smart-meter-data-sb bucket with additional_s3_buckets variable for better consistency and flexibility Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 240956f commit 5cee1a8

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

infra/main.tf

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ resource "aws_iam_role_policy" "s3_access" {
144144
"s3:DeleteObject",
145145
"s3:ListBucket"
146146
]
147-
Resource = [
148-
"arn:aws:s3:::${var.s3_bucket_name}",
149-
"arn:aws:s3:::${var.s3_bucket_name}/*",
150-
"arn:aws:s3:::smart-meter-data-sb",
151-
"arn:aws:s3:::smart-meter-data-sb/*"
152-
]
147+
Resource = concat(
148+
[
149+
"arn:aws:s3:::${var.s3_bucket_name}",
150+
"arn:aws:s3:::${var.s3_bucket_name}/*"
151+
],
152+
flatten([
153+
for bucket in var.additional_s3_buckets : [
154+
"arn:aws:s3:::${bucket}",
155+
"arn:aws:s3:::${bucket}/*"
156+
]
157+
])
158+
)
153159
}
154160
]
155161
})

infra/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ variable "s3_mount_path" {
5252
default = "/data.sb"
5353
}
5454

55+
variable "additional_s3_buckets" {
56+
description = "Additional S3 buckets that the instance needs access to (beyond the mounted bucket)"
57+
type = list(string)
58+
default = ["smart-meter-data-sb"]
59+
}
60+
5561
variable "project_name" {
5662
description = "Name prefix for resources"
5763
type = string

0 commit comments

Comments
 (0)