Hello Everyone, ```ECSAgent( cluster="NAME OF T...
# ask-community
s
Hello Everyone,
Copy code
ECSAgent(
		cluster="NAME OF THE CLUSTER",
		task_role_arn="ROLE ARN"
	)
Above code is working perfectly for one Prefect account but giving below error for another account. Can anyone please guide me what I am missing?
ValueError: Failed to infer default networkConfiguration, please explicitly configure using
--run-task-kwargs`` I did not required any configuration for first account for networkConfiguration. I am using Prefect 0.15.9.
a
@Sandip Viradiya when you create your ECS agent and you use Fargate with awsvpc as network mode, then you need to provide network configuration so that AWS knows to which VPC and subnets to deploy your ECS tasks. You can use the 
--network-configuration
 option in the command below - this is the configuration that seems to be missing in your agent startup command:
Copy code
aws ecs create-service \
    --service-name $ECS_SERVICE_NAME\
    --task-definition $ECS_SERVICE_NAME:1 \
    --desired-count 1 \
    --launch-type FARGATE \
    --platform-version LATEST \
    --cluster $ECS_CLUSTER_NAME \
    --network-configuration awsvpcConfiguration="{subnets=[$SUBNET1, $SUBNET2, $SUBNET3],assignPublicIp=ENABLED}" --region $AWS_REGION
The one account for which it worked, has most likely taken the default VPC, but defining it explicitly is better to avoid surprises such as this one. We’ve recently updated the docs for the ECS Agent and the ECSRun, incl. examples in the docstring. There is also this blog post explaining how to set up an ECS service for the agent to ensure your agent is running reliably 24/7.
s
Got it working! Thanks 🙂
👍 1