Skip to content

Commit 7baa994

Browse files
committed
feat(src): update iam role
1 parent 0fb6f4a commit 7baa994

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

terraform/fuap-backend/iam.tf

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_role" "ecs_task_execution_role" {
2-
name = "ecsTaskExecutionRoleV2" # Cambia el nombre aquí
2+
name = "ecsTaskExecutionRoleV2"
33
assume_role_policy = jsonencode({
44
Version = "2012-10-17",
55
Statement = [
@@ -23,3 +23,36 @@ resource "aws_iam_role" "ecs_task_execution_role" {
2323
]
2424
}
2525
}
26+
27+
resource "aws_iam_policy" "ecs_task_execution_policy" {
28+
name = "ecsTaskExecutionPolicyV2"
29+
description = "Policy for ECS Task Execution Role to pull images from ECR and send logs to CloudWatch"
30+
policy = jsonencode({
31+
Version = "2012-10-17",
32+
Statement = [
33+
{
34+
Effect = "Allow",
35+
Action = [
36+
"ecr:GetDownloadUrlForLayer",
37+
"ecr:BatchGetImage",
38+
"ecr:BatchCheckLayerAvailability",
39+
"ecr:GetAuthorizationToken"
40+
],
41+
Resource = "*"
42+
},
43+
{
44+
Effect = "Allow",
45+
Action = [
46+
"logs:CreateLogStream",
47+
"logs:PutLogEvents"
48+
],
49+
Resource = "*"
50+
}
51+
]
52+
})
53+
}
54+
55+
resource "aws_iam_role_policy_attachment" "ecs_task_execution_policy_attachment" {
56+
role = aws_iam_role.ecs_task_execution_role.name
57+
policy_arn = aws_iam_policy.ecs_task_execution_policy.arn
58+
}

0 commit comments

Comments
 (0)