Question

How to use environment values of type SECRET "On following submissions"?

Your App Specification Reference says the following for the envs/value:

String. The value. If the type is SECRET, the value will be encrypted on first submission. On following submissions, the encrypted value should be used.

Could you please clarify what the last sentence means.

For example, I am declaring an environment variable in my yaml file as follows:

{
  "key": "MAILCHIMP_API_KEY",
  "scope": "RUN_AND_BUILD_TIME",
  "type": "SECRET",
  "value": "MY_UNENCRYPTED_API_KEY_VALUE"
}

Now, based on this:

On following submissions, the encrypted value should be used.

It is not clear if I must re-fetch the yaml file from DigitalOcean in order to get the encrypted values for the value keys? So that on the following submission, my yaml file will have this:

{
  "key": "MAILCHIMP_API_KEY",
  "scope": "RUN_AND_BUILD_TIME",
  "type": "SECRET",
  "value": ";lkajsdf;1lkm23r920s,lc;naksdjv;aldkjvad"
}

Is this correct, or am I misinterpreting the documentation?

Finally, if this is the case, how do I update the value of the value with the new api key when we need to? Do we go to the UI and update it there, and then refetch the yaml file again?

It is a bit confusing, please could you explain the workflow of setting AND updating the values of environment variables of type SECRET

Thanks!


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@ReWild 👋

Your assumptions on this are correct. When you’re submitting a new app or changing values of secret envs, you should submit the spec (or update via the UI) with those values unencrypted. The spec you get in response to that, and the one now persisted as your app desired state, will have that secret value encrypted in-place to look something like this:

{
  "key": "MAILCHIMP_API_KEY",
  "scope": "RUN_AND_BUILD_TIME",
  "type": "SECRET",
  "value": "EV[1:xWTjge/c/Oe6kPy0/AFs916m3LcXMzWO:/RoXzy12ATYCexS2h50jI2tJFTQ9+E415Yldtl4l5Ua0UeHrERbI6epjcnehWKZZ]"
}

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. If you’d like to make a change to the value itself, you just need to resubmit the spec with the plain-text value, and it will again be encrypted in-place on the app spec.