is there anyway to pass a secret into an environme...
# ask-community
z
is there anyway to pass a secret into an environment variable in prefect cloud? e.g. I know i can set env variables using a template or via the KubernetesRun object, but both approaches get displayed in plain text in the UI
k
Hey @Zach Schumacher you mean the secret is stored on Prefect Cloud and you’re pulling it to set an environment variable?
z
yeah thats exactly right
k
And you are you setting that environment variable?
os.environ
?
z
Copy code
- name: AWS_ACCESS_KEY_ID
  value: {Secret("PROD__AWS_ACCESS_KEY_ID").get()}
- name: AWS_SECRET_ACCESS_KEY
  value: {Secret("PROD__AWS_SECRET_ACCESS_KEY").get()}
setting it in my template like this, but kind of just feels like im doing something wrong
i actually did read that i can just set the aws key/secret as a dict and prefect handles those for me, but i have other env vars that need set from secrets as well
k
Just bringing up other ideas. Have you seen this task?
Ignore last message. That’s not relevant. Ok I’ll ask the team about this
z
tbh i could just write a little python func that sets whatever i need from secrets in the environment if there isn’t a way
but just wanted to check if i was missing something
actually jk, that wouldn’t work in k8s world
k
The team advice is that k8s secrets probably serve you better in this case unfortunately
z
yeah fair enough