https://prefect.io logo
l

Levi Leal

01/28/2021, 3:17 PM
How do I run an agent on ECS? I've tried the docs on https://docs.prefect.io/orchestration/agents/ecs.html#agent-configuration but it doesn't work. I always get an error. The error stack is on the thread
Copy code
[2021-01-28 15:15:55,597] ERROR - agent | Failed to infer default networkConfiguration, please explicitly configure using `--run-task-kwargs`
Traceback (most recent call last):
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/bin/prefect", line 8, in <module>
    sys.exit(cli())
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/prefect/cli/agent.py", line 374, in start
    start_agent(ECSAgent, **kwargs)
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/prefect/cli/agent.py", line 108, in start_agent
    agent = agent_cls(labels=labels, env_vars=env_vars, **kwargs)
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/prefect/agent/ecs/agent.py", line 240, in __init__
    ] = self.infer_network_configuration()
  File "/home/levi_leal/.ve/prefect.io-VQPvrm3t/lib/python3.8/site-packages/prefect/agent/ecs/agent.py", line 280, in infer_network_configuration
    raise ValueError(msg)
ValueError: Failed to infer default networkConfiguration, please explicitly configure using `--run-task-kwargs`
I've also created a task definition using the image prefecthq/prefect:all_extras but the task never runs. It always stop after a minute or two. I'm trying to use Fargate
m

Mariia Kerimova

01/28/2021, 5:39 PM
Hello Levi! Looks like the error is related to Network Configurations. Do you provide any awsvpcConfigurations in ECSRun?
l

Levi Leal

01/28/2021, 5:41 PM
I'm not trying to deploy any flow yet. I'm just trying to add an agent to my server. I'm running
prefect agent ecs start
m

Mariia Kerimova

01/28/2021, 5:47 PM
Gotcha! Could you show a redacted flow you are trying to run and also can you check if there is a default VPC in your default AWS region?
If you don’t provide any network configuration and you don’t have default vpc, you might see this error
l

Levi Leal

01/28/2021, 5:54 PM
I'm not trying to run any flow yet. I'm just trying to get to see my agent on prefect's dashboard. I've just checked and I don't have a default VPC on my region.
m

Mariia Kerimova

01/28/2021, 6:02 PM
it’s necessary to provide information about the network configuration to ECS agent. So, just for testing purposes you can switch to the region with default vpc, set AWS_DEFAULT_REGION to that region and start the agent
l

Levi Leal

01/28/2021, 6:06 PM
Worked with a default VPC
Now my problem is how to configure it to work on the other region. And how to set a task on ECS to run the agent.
Thanks for the help. I'll try to find something on their docs. If you have anything that might help me with this, I'd appreciate it a lot 🙂
m

Mariia Kerimova

01/28/2021, 6:56 PM
I’m glad it worked. So you will have to create a VPC in that region and provide it in ECSRun config. I was running my agent on EC2 instance. I didn’t document my steps, but I’m going to terraform the provisioning of VPC and EC2 soon, and I’ll post it here
l

Levi Leal

01/29/2021, 2:30 PM
Thanks a mil
I managed to get a "Local" agent running on ECS. I'll have to ask IT to set the VPC for me later. One question I have now is how to use ECS' health check
Usually I use a
wget
or
curl
, but prefect's image doesn't have any of those. Do you know how I can do this health check?