By Jem
I am receiving the following error when doing a subsequent deployment through doctl:
errors validating app spec; first error in field "envs.0.value": secret env value must not be encrypted before app is created
This is the command: doctl apps create --upsert --spec app-spec.yml --wait --verbose
Version: 1.68.0
Here is the relevant section of the app-spec.yml file:
envs:
- key: DISCORD_BOT_TOKEN
scope: RUN_AND_BUILD_TIME
type: SECRET
value: <REDACTED>
I have tried multiple approaches (wondering if I did something wrong), and I am getting the error no matter what.
Approach 1:
Approach 2:
I have read the documentation and community questions, and it seems that I am doing this correctly. e.g. https://www.digitalocean.com/community/questions/how-to-use-environment-values-of-type-secret-on-following-submissions
As you make updates to your app spec, if you don’t intend to change those encrypted values, then you should just submit with the in-place encrypted values unchanged.
What is the correct approach to this? If there is an issue with the DOAP, is there a temporary workaround?
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!
This comment has been deleted
Hey!
The error you’re encountering with doctl when deploying an app and using secret environment variables seems to come from how doctl handles the encryption of secret values. The error message “secret env value must not be encrypted before app is created” indicates that the secret value should not be pre-encrypted in your app-spec.yml file when creating or upserting an app.
When you first create an app with a secret environment variable, you should provide the plain text value in the app-spec.yml file. DigitalOcean’s App Platform will then encrypt this value for you. When you subsequently update or upsert the app and don’t intend to change the secret, you should use the encrypted value that the platform provides, not the original plain text.
Here’s how you can handle this:
Initial Deployment:
Subsequent Updates:
Using doctl apps update vs doctl apps create --upsert:
doctl apps update seems to work because it’s designed to update existing resources, where the platform expects encrypted secrets.--upsert flag with doctl apps create should theoretically handle both creation and updating seamlessly. However, if it’s causing issues with secrets, it might be a bug or a limitation in how doctl processes the app-spec.yml file. In this case, using doctl apps update for updates after the initial creation is a valid workaround.If you believe this is a bug with doctl, consider reporting an issues related to this in the doctl GitHub repository:
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.