generate new role for reading from s3 bucket and attach it to the lambda

This commit is contained in:
Daniel Roth 2026-02-09 14:13:06 +00:00
parent 68b12c7344
commit f3e77beefd
2 changed files with 24 additions and 0 deletions

View file

@ -26,3 +26,8 @@ module "lambda" {
)
}
resource "aws_iam_role_policy_attachment" "attach_condition_etl_s3_read" {
role = module.lambda.role.role_name
policy_arn = module.shared.condition_etl_s3_read_arn
}

View file

@ -344,4 +344,23 @@ module "condition_data_bucket" {
source = "../modules/s3"
bucketname = "condition-data-${var.stage}"
allowed_origins = var.allowed_origins
}
resource "aws_iam_policy" "condition_etl_s3_read" {
name = "ConditionETLReadS3"
description = "Allow Lambda to read objects from condition-data-${var.stage}"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = ["s3:GetObject"]
Resource = "arn:aws:s3:::condition-data-${var.stage}/*"
}
]
})
}
output "condition_etl_s3_read_arn" {
value = aws_iam_policy.condition_etl_s3_read.arn
}