Skip to content

Commit

Permalink
feat(src): update iam role
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Pino committed Jun 16, 2024
1 parent 0fb6f4a commit 7baa994
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion terraform/fuap-backend/iam.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_iam_role" "ecs_task_execution_role" {
name = "ecsTaskExecutionRoleV2" # Cambia el nombre aquí
name = "ecsTaskExecutionRoleV2"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
Expand All @@ -23,3 +23,36 @@ resource "aws_iam_role" "ecs_task_execution_role" {
]
}
}

resource "aws_iam_policy" "ecs_task_execution_policy" {
name = "ecsTaskExecutionPolicyV2"
description = "Policy for ECS Task Execution Role to pull images from ECR and send logs to CloudWatch"
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:GetAuthorizationToken"
],
Resource = "*"
},
{
Effect = "Allow",
Action = [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
Resource = "*"
}
]
})
}

resource "aws_iam_role_policy_attachment" "ecs_task_execution_policy_attachment" {
role = aws_iam_role.ecs_task_execution_role.name
policy_arn = aws_iam_policy.ecs_task_execution_policy.arn
}

0 comments on commit 7baa994

Please sign in to comment.