maxime
maxime

Reputation: 2315

DigitalOcean: Getting Spaces credentials from an App

On DigitalOcean, I have an App and a Spaces Bucket with files.

I need my app to read and write on that bucket, therefore I need to provide it a Spaces Key and a Spaces Secret for my S3 Client.

However, I can't find any way to automatically provision those environment variables into a Digital Ocean App.

I tried to attach the Space to my app, but it is only possible with the databases. I also tried to use the Resources specific variables in the app env vars but nothing is suggested with the spaces.

Upvotes: 0

Views: 224

Answers (1)

Andrew Arrow
Andrew Arrow

Reputation: 4585

What about using:

APP_ID=<your_app_id>
SPACES_KEY=<your_spaces_key>
SPACES_SECRET=<your_spaces_secret>
ACCESS_TOKEN=<your_digitalocean_access_token>

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $ACCESS_TOKEN" \
     -d '{
       "variables": [
         {
           "key": "SPACES_KEY",
           "value": "'"$SPACES_KEY"'"
         },
         {
           "key": "SPACES_SECRET",
           "value": "'"$SPACES_SECRET"'"
         }
       ]
     }' \
     "https://api.digitalocean.com/v2/apps/$APP_ID/environment"

To automatically set those env vars?

Upvotes: 0

Related Questions