Hi,
I’m working on a Python function being deployed to Functions and it needs to access API keys and other secrets. I added the secrets to the environment variables section on the settings page for the function (via the web UI), but all the environment variables get deleted after each doctl serverless deploy package-name --remote-build
command.
I thought it might’ve been because in project.yml
I had set environment: {}
, so I removed environment: {}
and it’s now a barebones project.yml
file. Even after that change, the environment variables are gone after every update I deploy.
Is there a way to persist the environment variables across doctl
serverless deploys of the same function? Or am I setting something wrong to cause this behavior?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there,
You would actually need to explicitly declare the environment variables in the
project.yml
.That way you can ensure the env variables are set with every deployment, eg:
Otherwise, as you mentioned that your
project.yml
had an emptyenvironment: {}
block, which you later removed, ifenvironment: {}
is set, it will override environment variables set via the web UI during deployment as the platform will try to match whatever is in theproject.yml
file.Let me know how it goes!
Best,
Bobby