Darragh
06/03/2020, 3:51 PMflow.environment = FargateTaskEnvironment(
launch_type="FARGATE",
region="eu-west-1",
cpu="256",
memory="512",
networkConfiguration={
"awsvpcConfiguration": {
"assignPublicIp": "ENABLED",
"subnets": ["subnet-X"],
"securityGroups": ["sg-Y"],
}
},
family="my_flow",
taskRoleArn="arn:aws:iam::X:role/Role",
executionRoleArn="arn:aws:iam::X:role/Role",
containerDefinitions={
"name": "my-flow",
"image": "my-flow",
"command": [],
"environment": [],
"essential": True,
}
)
Fargate Agent:
echo "export REGION_NAME=${CDK_DEPLOY_REGION}" > .env
echo "export AWS_DEFAULT_REGION=${CDK_DEPLOY_REGION}" >> .env
echo "export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> .env
echo "export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> .env
source .env
nohup prefect agent start fargate > prefect_fargate.log 2>&1 & disown
Everything seems fine until I try to run it. There’s no update in the agent logs to show it’s been picked up, and the UI just says:
Failed to load and execute Flow's environment: AttributeError("'str' object has no attribute 'get'")
Anything immediate/obvious/stupid stand out?
As an aside I’m guessing I’m missing a bunch of config for the agent, but the docs are a little unclear on that one, the top level of the docs [https://docs.prefect.io/orchestration/agents/fargate.html#installation] seem to suggest you only need the handful of vars I added
UPDATE: Some progress, it’s now giving a meaningful error, Parameter validation failed: Missing required parameter in containerDefinitions[0].logConfiguration: "logDriver
Fixing itjosh
06/03/2020, 4:15 PMDarragh
06/03/2020, 4:18 PMAttributeError: 'tuple' object has no attribute 'start'
from prefect.agent.fargate import FargateAgent
agent = FargateAgent(
launch_type="FARGATE",
aws_access_key_id="KEY",
aws_secret_access_key="KEY",
region_name="eu-west-1",
networkConfiguration={
"awsvpcConfiguration": {
"assignPublicIp": "ENABLED",
"subnets": ["subnet-X"],
"securityGroups": ["sg-X"],
}
},
cpu="256",
memory="512",
platformVersion="1.4.0",
containerDefinitions=[{
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/my/log/group",
"awslogs-region": "eu-west-1",
"awslogs-stream-prefix": "prefect-flow-runs",
"awslogs-create-group": "true",
},
},
}],
),
agent.start()
josh
06/03/2020, 4:24 PMDarragh
06/03/2020, 4:25 PMjosh
06/03/2020, 4:25 PMagent = FargateAgent(
launch_type="FARGATE",
aws_access_key_id="KEY",
aws_secret_access_key="KEY",
region_name="eu-west-1",
networkConfiguration={
"awsvpcConfiguration": {
"assignPublicIp": "ENABLED",
"subnets": ["subnet-X"],
"securityGroups": ["sg-X"],
}
},
cpu="256",
memory="512",
platformVersion="1.4.0",
containerDefinitions=[
{
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/my/log/group",
"awslogs-region": "eu-west-1",
"awslogs-stream-prefix": "prefect-flow-runs",
"awslogs-create-group": "true",
},
},
}
],
)
Darragh
06/03/2020, 4:26 PMjosh
06/03/2020, 4:26 PMDarragh
06/03/2020, 4:52 PMFargate requires task definition to have execution role ARN to support log driver awslogs
{
“RoleName”: “ROLE”,
“PolicyName”: “ROLE_POLICY,
“PolicyDocument”: {
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “VisualEditor0",
“Effect”: “Allow”,
“Action”: [
“cloudwatch:*“,
“logs:*“,
“ecs:*“,
“ecr:*”
],
“Resource”: “*”
}
]
}
}josh
06/03/2020, 5:43 PMregister_task_definition
and run_task
)Jeff Brainerd
06/03/2020, 6:34 PMlogConfiguration
issue after upgrading boto3
, because we weren’t passing it to the agent. We now have it running successfully again. Our IAM role includes the AWS managed policies AmazonECS_FullAccess
and AmazonECSTaskExecutionRolePolicy
, both of which include some cloudwatch actions. You might want to take a look at those…Darragh
06/03/2020, 6:47 PMjosh
06/03/2020, 6:49 PM"aws": ["boto3 >= 1.9, < 2.0"],
Jeff Brainerd
06/03/2020, 7:41 PMboto3
library upgraded from 1.12.x
to 1.13.20
— which looks like it’s the latest version, according to https://boto3.amazonaws.com/v1/documentation/api/latest/index.html# — so maybe you guys are grabbing a different library somehow?Darragh
06/03/2020, 7:48 PMboto3-1.13.22