Hello! I am using AWS Fargate. I added to my agent...
# ask-community
i
Hello! I am using AWS Fargate. I added to my agent env_vars. How I can import Secrets from agent to flow which will be run in the container?
z
Hi Igor! Are you looking for something like the following? https://docs.prefect.io/orchestration/concepts/secrets.html#using-secrets-in-tasks
i
@Zach Angell Almost. Yes, I am using PrefectSecret in my flow. Also, I added env var to the agent PREFECT__CONTEXT__SECRETS__PASSWORD. But when I run the flow using ECSRun, I don't see these vars.
z
Got it, so if you set
PREFECT__CONTEXT__SECRETS__PASSWORD = 'my_password'
In the flow run, you should be able to do something like
Copy code
with Flow('my flow') as flow:
     password = PrefectSecret("PASSWORD")
i
The same code, but I caught: Unexpected error: KeyError('The secret PASSWORD was not found. Please ensure that it was set correctly in your tenant: https://docs.prefect.io/orchestration/concepts/secrets.html',)
k
Hey @Igor Bondartsov, could you share how you are setting it?
i
Copy code
ECSAgent(
    ...
    env_vars={         "PREFECT__CONTEXT__SECRETS__PASSWORD": "pass",
...
).start()
I expect that all env vars that I have in the agent will be added to the image:
Copy code
ECSRun(       image='bondartsov/prefectagent:latest')
I found an error, my bad.
👍 1
k
What was it @Igor Bondartsov? Would like to know
i
@Kevin Kho I added env vars to the agent container, but I didn't add all of them to env_vars field
k
Oh I see. Glad you figured it out. Was thinking what the issue could be.