diff --git a/openchallenges/service_stack.py b/openchallenges/service_stack.py index 4dd351b..e1be848 100644 --- a/openchallenges/service_stack.py +++ b/openchallenges/service_stack.py @@ -60,6 +60,28 @@ def __init__( ) ) + # default ECS execution policy plus Guardduty access + execution_role = iam.Role( + self, + "ExecutionRole", + assumed_by=iam.ServicePrincipal("ecs-tasks.amazonaws.com"), + managed_policies=[ + iam.ManagedPolicy.from_aws_managed_policy_name( + "service-role/AmazonECSTaskExecutionRolePolicy" + ), + ], + ) + execution_role.add_to_policy( + iam.PolicyStatement( + actions=[ + "logs:CreateLogStream", + "logs:PutLogEvents", + ], + resources=["*"], + effect=iam.Effect.ALLOW, + ) + ) + # ECS task with fargate self.task_definition = ecs.FargateTaskDefinition( self, @@ -67,6 +89,7 @@ def __init__( cpu=1024, memory_limit_mib=4096, task_role=task_role, + execution_role=execution_role, ) image = ecs.ContainerImage.from_registry(props.container_location)