Jon Young
07/02/2025, 5:01 PMMarvin
07/02/2025, 5:02 PMMarvin
07/02/2025, 5:02 PMjson
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
2. Task Role (permissions depend on what your flows need to access):
- This role should include permissions for any AWS services your flows interact with
- Common permissions might include:
- s3:*
for S3 access
- rds:*
for RDS access
- secretsmanager:GetSecretValue
for accessing Secrets Manager
- Any other service-specific permissions your flows require
The easiest way to get started is to:
1. Use the AWS-managed policy AmazonECSTaskExecutionRolePolicy
for the task execution role
2. Create a custom task role with the specific permissions your flows need
You can find more details in the Prefect ECS Guide.
Remember: Always follow the principle of least privilege and only grant the permissions that are absolutely necessary for your flows to function.
Would you like me to provide more specific permissions for any particular AWS services your flows need to interact with?Jon Young
07/02/2025, 5:03 PMMarvin
07/02/2025, 5:03 PMMarvin
07/02/2025, 5:04 PMec2:DescribeVpcs
error occurs because the ECS worker needs permissions to inspect your VPC configuration to properly set up task networking. You'll need to add the following permissions to your task role:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups"
],
"Resource": "*"
}
]
}
These permissions are necessary because:
1. `DescribeVpcs`: ECS needs to validate the VPC where tasks will run
2. `DescribeSubnets`: Required to identify available subnets for task placement
3. `DescribeSecurityGroups`: Needed to verify security group configurations
Add these permissions to your existing task role. If you're using a managed policy, you might want to create an additional inline policy with these permissions.
Would you like me to provide the complete set of networking-related permissions that might be needed for ECS task execution?Jon Young
07/02/2025, 5:04 PMMarvin
07/02/2025, 5:04 PMMarvin
07/02/2025, 5:05 PMjson
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeSubnets",
"ec2:DescribeVpcs",
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetAuthorizationToken",
"ecr:GetDownloadUrlForLayer",
"ecs:DeregisterTaskDefinition",
"ecs:DescribeTaskDefinition",
"ecs:DescribeTasks",
"ecs:RegisterTaskDefinition",
"ecs:RunTask",
"ecs:StopTask",
"iam:PassRole",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:GetLogEvents",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
This is much more comprehensive than what I initially suggested. The permissions cover:
- EC2/VPC inspection (ec2:Describe*
)
- ECR image pulling
- ECS task management
- CloudWatch logging
- IAM role passing
You can find these permissions in:
1. The prefect-recipes repository
2. Referenced in Prefect Issue #16385
The official Prefect ECS Guide doesn't currently list all these permissions explicitly, which is why I had to reference the GitHub repositories for the complete list.