Igor Bondartsov

    Igor Bondartsov

    1 year ago
    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?
    Zach Angell

    Zach Angell

    1 year ago
    Hi Igor! Are you looking for something like the following? https://docs.prefect.io/orchestration/concepts/secrets.html#using-secrets-in-tasks
    Igor Bondartsov

    Igor Bondartsov

    1 year ago
    @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.
    Zach Angell

    Zach Angell

    1 year ago
    Got it, so if you set
    PREFECT__CONTEXT__SECRETS__PASSWORD = 'my_password'
    In the flow run, you should be able to do something like
    with Flow('my flow') as flow:
         password = PrefectSecret("PASSWORD")
    Igor Bondartsov

    Igor Bondartsov

    1 year ago
    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',)
    Kevin Kho

    Kevin Kho

    1 year ago
    Hey @Igor Bondartsov, could you share how you are setting it?
    Igor Bondartsov

    Igor Bondartsov

    1 year ago
    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:
    ECSRun(       image='bondartsov/prefectagent:latest')
    I found an error, my bad.
    Kevin Kho

    Kevin Kho

    1 year ago
    What was it @Igor Bondartsov? Would like to know
    Igor Bondartsov

    Igor Bondartsov

    1 year ago
    @Kevin Kho I added env vars to the agent container, but I didn't add all of them to env_vars field
    Kevin Kho

    Kevin Kho

    1 year ago
    Oh I see. Glad you figured it out. Was thinking what the issue could be.