Skip to content

Commit

Permalink
Added missing bucket rights for backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Loic-Vanden-Bossche committed Apr 26, 2024
1 parent 46cf460 commit 77f07ec
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/infrastructure/project/backend/role-task.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,29 @@ resource "aws_iam_role_policy" "ecs_backend_task_execution_ssm_role_policy" {
},
]
})
}

resource "aws_iam_role_policy" "ecs_backend_task_execution_ssm_role_policy" {
name = "${var.namespace}_ECS_S3_TaskIAMRole_${var.environment}"
role = aws_iam_role.ecs_task_execution_role.id

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
"Effect" : "Allow",
"Action" : [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket",
"s3:GetBucketLocation",
],
"Resource" : [
var.storage_bucket_arn,
"${var.storage_bucket_arn}/*"
]
},
]
})
}
5 changes: 5 additions & 0 deletions packages/infrastructure/project/backend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ variable "alb_header_value" {
variable "storage_s3_bucket_name" {
type = string
description = "The name of the S3 bucket"
}

variable "storage_bucket_arn" {
type = string
description = "The ARN of the S3 bucket used for application storage"
}
1 change: 1 addition & 0 deletions packages/infrastructure/project/modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "backend" {
rds_db_url = module.storage.rds_db_url
alb_header_value = module.frontend.alb_header_value
storage_s3_bucket_name = module.storage.application_storage_bucket_name
storage_bucket_arn = module.storage.application_storage_bucket_arn
}

module "domain" {
Expand Down
5 changes: 5 additions & 0 deletions packages/infrastructure/project/storage/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ output "application_storage_bucket_id" {
description = "The ID of the S3 bucket used for application storage"
}

output "application_storage_bucket_arn" {
value = aws_s3_bucket.application_storage.arn
description = "The ARN of the S3 bucket used for application storage"
}

output "application_storage_bucket_domain_name" {
value = aws_s3_bucket.application_storage.bucket_regional_domain_name
description = "The domain name of the S3 bucket used for application storage"
Expand Down

0 comments on commit 77f07ec

Please sign in to comment.