https://prefect.io logo
m

Mateo Merlo

01/01/2023, 8:27 PM
Hi everyone!! I'm having an error running the infrastructure block following the tutorial https://towardsdatascience.com/prefect-aws-ecs-fargate-github-actions-make-serverless-dataflows-as-easy-as-py-f6025335effc. When I run
python blocks/ecs_task.py
I got the error on the image.
āœ… 1
prefect 2.7.4 prefect-aws 0.2.0 s3fs 2022.8.2 ecs_task.py
Copy code
from prefect_aws import AwsCredentials
from prefect_aws.ecs import ECSTask

aws_credentials_block = AwsCredentials(
    aws_access_key_id="****",
    aws_secret_access_key="****",
)
aws_credentials_block.save("prod", overwrite=True)

ecs = ECSTask(
    aws_credentials=aws_credentials_block,
    image="<http://631792532656.dkr.ecr.us-east-1.amazonaws.com/prefect2-image:latest|631792532656.dkr.ecr.us-east-1.amazonaws.com/prefect2-image:latest>",  # image pushed to ECR
    cpu="256",
    memory="512",
    stream_output=True,
    configure_cloudwatch_logs=True,
    cluster="prefect2EcsCluster",
    execution_role_arn="arn:aws:iam::631792532656:role/prefectECSAgentTaskExecutionRole",
    task_role_arn="arn:aws:iam::631792532656:role/prefectTaskRole",
)
ecs.save("prod", overwrite=True)
Anyone with this error?
r

Ryan Peden

01/01/2023, 8:32 PM
Does updating to
prefect-aws
0.2.1 make a difference? There were some changes in it that might help.
m

Mateo Merlo

01/01/2023, 8:34 PM
I've tried but still same error. In case this helps, I'm using: boto3 1.24.59 botocore 1.27.59
r

Ryan Peden

01/01/2023, 8:35 PM
It actually looks like the changes I was thinking of aren't released yet, but ensuring you are on the newest released version makes debugging easier, so thank you for trying it anyway. šŸ™‚ I'm going to check a couple of things quickly and get back to you ASAP.
m

Mateo Merlo

01/01/2023, 8:38 PM
Thank you so much Ryan!
r

Ryan Peden

01/01/2023, 9:00 PM
No problem, Mateo! I see what is happening here, and I don't think it will prevent your script from working. When I check on both Prefect Cloud and a local Prefect Orion server, the blocks get created as expected despite the error message. What's happening here is that when the
prefect
package initializes, it tries to load collections like
prefect-aws
automatically. However, in this case it is raising an error if
prefect-aws
is loaded first. We will fix this if needed, but in the meantime you can do one of the following: • Use the script as-is and ignore the error message. • Add
import prefect
to the top of your file before the
prefect_aws
imports. If you use PyLint or another linter, you might need to add a comment to get it to ignore the unused import.
gratitude thank you 1
m

Mateo Merlo

01/01/2023, 9:37 PM
Thanks for the explanation Ryan!I added the
import prefect
at the top and it works without the error. šŸ™ŒšŸ¼
šŸ™Œ 1