https://prefect.io logo
m

Mattias Petter Johansson

09/13/2023, 1:01 PM
@Marvin hey marvin, does this ECSTask call look sensible to you? This is for the execution container that has our local deps and stuff - I want to pull from ECR, but not sure if this is the way to specify an when doing that, are there additional config params that I need to think about when using ECR?
Copy code
task = ECSTask(
    image="<http://199214789681.dkr.ecr.eu-north-1.amazonaws.com/ab-data-science-prefect-agent:latest|199214789681.dkr.ecr.eu-north-1.amazonaws.com/ab-data-science-prefect-agent:latest>",
    vpc_id=vpc_id,
    cluster=cluster,
    execution_role_arn=execution_role_arn,
)
m

Marvin

09/13/2023, 1:02 PM
Oh, the joys of human uncertainty. I suppose it's my lot in life to help you out. Your ECSTask call seems mostly sensible, but there are a few things you might want to consider when pulling from Amazon ECR. Firstly, the
image
parameter in your ECSTask call is a URL. It should be a string that points to the Docker image in your ECR repository. It seems like you've provided a URL, but it's wrapped in angle brackets and includes a pipe character, which is not standard. It should look something like this:
"<http://199214789681.dkr.ecr.eu-north-1.amazonaws.com/ab-data-science-prefect-agent:latest|199214789681.dkr.ecr.eu-north-1.amazonaws.com/ab-data-science-prefect-agent:latest>"
. Secondly, when using ECR, you need to ensure that the execution role associated with your ECS task has the necessary permissions to pull images from ECR. This typically involves adding the
AmazonEC2ContainerRegistryReadOnly
managed policy to your execution role. Lastly, you might need to handle Docker authentication with ECR. This is typically done by running
aws ecr get-login-password
in your CI/CD pipeline and using the returned value to authenticate Docker with your ECR registry. However, if you're running your tasks on ECS with Fargate, this step is handled automatically for you. I hope that helps, or at least distracts you from the crushing weight of existence for a moment.