Ben Muller
06/10/2021, 8:50 PMprefect agent
in an ECS Fargate cluster.
I am feeding in all my secrets via the cdk namely, RUNNER_TOKEN_FARGATE_AGENT
, AWS_SECRET_ACCESS_KEY
and AWS_ACCESS_KEY_ID
I am getting some type of auth error when I run my image command
CMD [ "prefect", "agent", "ecs", "start", "--token", "$RUNNER_TOKEN_FARGATE_AGENT", \
"--task-role-arn=arn:aws:iam::********:role/ECSTaskS3Role", \
"--log-level", "INFO", "--label", "fargate-dev", "--label", "s3-flow-storage", \
"--name", "fargate-demo" ]
The trace in 🧵
``````
Any ideas would be great!
I assumed I dont have to register the agent with Prefect cloud as I did this with Ec2 and it didnt have to be done.
Thanks in advance for any help on this...Jenny
06/10/2021, 9:00 PMNatalie Smith
06/10/2021, 9:19 PMBen Muller
06/10/2021, 9:25 PMTraceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/prefect/agent/agent.py", line 890, in _setup_api_connection
self._verify_token(self.client.get_auth_token())
File "/usr/local/lib/python3.8/site-packages/prefect/agent/agent.py", line 824, in _verify_token
result = self.client.graphql(query="query { auth_info { api_token_scope } }")
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 311, in graphql
raise AuthorizationError(result["errors"])
prefect.utilities.exceptions.AuthorizationError: [{'path': ['auth_info'], 'message': 'AuthenticationError: Forbidden', 'extensions': {'code': 'UNAUTHENTICATED'}}]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/prefect", line 8, in <module>
Ben Muller
06/10/2021, 9:25 PMBen Muller
06/10/2021, 9:26 PMprefect auth create-token -n DemoFargateAgentToken -s RUNNER
Ben Muller
06/10/2021, 9:31 PMFROM prefecthq/prefect:latest-python3.8
RUN pip3 install "prefect[aws]"
ENV AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION
ENV RUNNER_TOKEN_FARGATE_AGENT=$RUNNER_TOKEN_FARGATE_AGENT
RUN prefect backend cloud
CMD [ "prefect", "agent", "ecs", "start", "--token", "$RUNNER_TOKEN_FARGATE_AGENT", \
"--task-role-arn=arn:aws:iam::****:role/ECSTaskS3Role", \
"--log-level", "INFO", "--label", "fargate-dev", "--label", "s3-flow-storage", \
"--name", "fargate-demo" ]
Natalie Smith
06/10/2021, 9:51 PMprefect auth create-token
command. You will need to get a new token. You can do that hereBen Muller
06/10/2021, 9:52 PMNatalie Smith
06/10/2021, 10:02 PMBen Muller
06/10/2021, 10:06 PMBen Muller
06/10/2021, 10:09 PM2021-06-10 22:08:38,568] ERROR - fargate-demo | Failed to verify authentication.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/prefect/agent/agent.py", line 890, in _setup_api_connection
self._verify_token(self.client.get_auth_token())
File "/usr/local/lib/python3.8/site-packages/prefect/agent/agent.py", line 824, in _verify_token
result = self.client.graphql(query="query { auth_info { api_token_scope } }")
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 311, in graphql
raise AuthorizationError(result["errors"])
prefect.utilities.exceptions.AuthorizationError: [{'path': ['auth_info'], 'message': 'AuthenticationError: Forbidden', 'extensions': {'code': 'UNAUTHENTICATED'}}]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/prefect", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/prefect/cli/agent.py", line 420, in start
start_agent(ECSAgent, **kwargs)
File "/usr/local/lib/python3.8/site-packages/prefect/cli/agent.py", line 103, in start_agent
agent.start()
File "/usr/local/lib/python3.8/site-packages/prefect/agent/agent.py", line 182, in start
self._setup_api_connection()
File "/usr/local/lib/python3.8/site-packages/prefect/agent/agent.py", line 894, in _setup_api_connection
raise RuntimeError(
RuntimeError: Error while contacting API at <https://api.prefect.io>
Ben Muller
06/10/2021, 10:16 PMBen Muller
06/10/2021, 10:17 PMCMD [ "sh", "-c", "prefect agent ecs start --token $PREFECT__CLOUD__AGENT__AUTH_TOKEN \
--task-role-arn=arn:aws:iam::****:role/ECSTaskS3Role \
--log-level INFO --label fargate-dev --label s3-flow-storage \
--name fargate-demo" ]
Natalie Smith
06/10/2021, 10:20 PM