DigitalOcean Spaces access keys: scope them, rotate them, stop sharing them
A Spaces access key is a long-lived credential with no expiry date. Give each workload its own key limited to the buckets it needs, rotate by creating the new key before deleting the old one, and use presigned URLs when the real need is to share a file.
The earlier article on Spaces public access covers who can read a bucket without a key. This one is about the key itself. It is the credential that goes into your application, your backup job and your CI pipeline, and it is the one that tends to be created once and forgotten.
Two kinds of key, and the limits that come with them
DigitalOcean's access management page describes full access, which allows all supported S3 APIs on all buckets, and limited access, which grants Read or Read/Write/Delete on specific buckets. Two restrictions matter when you plan around them. Per-bucket keys are not compatible with S3-compatible bucket policies, and the limits page says a full-access key and a limited key cannot be converted into each other.
The same limits page caps an account at 100 buckets and 200 access keys. The page says nothing about a separate per-team figure. Two hundred is plenty for a careful team and not very many for one that makes a new key for every experiment.
One point where DigitalOcean's own pages disagree, and it affects how you edit keys. The control panel guide lets you edit a key's permissions. The Spaces keys API reference says you cannot convert a full-access key to a scoped one or the reverse, and that you can only update the name. The doctl update command lists a grants flag. With three sources saying three things, the safe habit is not to edit a broad key into a narrow one. Create a new narrow key, and retire the broad one.
One key per workload
If your site serves images, your backup job writes archives and your deploy script uploads builds, those are three keys. A leaked key then costs you one workload, and you can retire it without touching the other two.
The doctl reference documents the commands. create needs a name and a required grants flag, in the form bucket=<name>;permission=<level>, with levels read, readwrite and fullaccess. The reference's own example grants two buckets at different levels:
doctl spaces keys create site-images \
--grants 'bucket=my-assets;permission=read'
doctl spaces keys list
doctl spaces keys get <access-key-id> --format Name,Grants
The doctl spaces keys commands also include update and delete, and delete takes the access key ID, not the name. The list shows name, access key, grants and creation date. It has a SecretKey column too, but the control panel is clear that the secret appears only once, when the key is created, so copy it then.
Rotating a key without an outage
DigitalOcean's warning on the key page is blunt: deleting a key permanently revokes access for any application using it and can cause service disruption, so update your applications with a new key before deleting the old one. That sentence is the whole routine, and a few steps make it concrete.
- Create a new key with the same grants as the old one, and name it with the date, such as
backup-job-2026-11. - Put it into that workload's configuration and restart the workload.
- Confirm real traffic works with the new key. A test upload is not enough if the job only runs at night.
- Soft-revoke the old key. The documentation says you can revoke access by editing a key and removing all of its bucket permissions. That is a reversible way to find a forgotten user of the old key before you delete anything.
- After a quiet week, delete the old key.
The control panel also offers Regenerate key, which invalidates the existing secret and permanently revokes access for applications using it. That is right for a leaked key and wrong for a planned rotation, because it gives you no overlap.
Finding the keys you forgot
Here DigitalOcean does not give you what a rotation really needs. The key schema in the API reference holds the access key, the creation date, the grants and the name. There is no last-used field, so you cannot ask which of your keys has gone quiet.
The nearest tool is Spaces access logs. They became generally available in June 2025 and are disabled by default. The access logs page says you turn them on in the control panel, with aws s3api put-bucket-logging, or with Terraform, and that the destination bucket must differ from the source bucket. They record reads, writes and deletions of objects, plus requests through the CDN if it is enabled, in the Amazon S3 server access log format, delivered usually within an hour. The page does not state a retention period.
It also does not say whether a log line names the key used. The page defers to the AWS log format, which has a field for the requester, so enable logging on a test bucket and read a line before you build a rotation plan on it. Until you have confirmed it, treat logs as evidence of what was accessed, not proof of which key did it.
Where the key should live
DigitalOcean's SDK examples all read SPACES_KEY and SPACES_SECRET from environment variables, and the s3cmd page notes that you can leave the key prompts blank and use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY instead. The Spaces security guide warns that keys hard-coded into applications can be exposed through source repositories, and that rotating or revoking keys without planning can disrupt service.
On App Platform, the environment variables page offers an Encrypt option that hides a value from build, deployment and application logs. It also warns that encrypted variables are decrypted in the running application and can be visible to team members who can reach the app's console. A secret in an environment variable is only as private as the list of people who can open that console.
For Kubernetes, we found no DigitalOcean recommendation for holding a Spaces key, so we will not invent one. Follow your cluster's normal secret handling and give the workload a limited key.
Often the right answer is no key at all
A common reason to hand out a key is to let someone download or upload one file. A presigned URL does that without a credential. DigitalOcean's file permissions page describes it as time-limited access to a private file. In the control panel it is called Quick Share, and the durations offered are one hour, six hours, one day, three days or seven days.
From the command line, the page documents the AWS CLI form, with the expiry in seconds:
aws s3 presign s3://your-space-name/your-object-key --expires-in 3600
It also shows the Boto3 call, generate_presigned_url with an ExpiresIn value. We found no documented maximum expiry for the CLI or SDK, because seven days is only the longest choice in the control panel. Presigned URLs work with the CDN in one respect that matters: DigitalOcean notes that using them does not allow transferred files to be cached by the Spaces CDN.
One caution. A presigned URL is generated with a key, so it inherits that key's reach for as long as it lives. Generate them with a limited key that can only read the one bucket.
Where this leaves you
Spaces keys are not API tokens, though a token with the right scopes can create them, so the API tokens article belongs next to this one.
List your keys today. Anything named after a person, a project that ended or the word test is a candidate. Replace full-access keys with limited ones, one per workload, using the create-then-retire routine. Turn on access logs for the bucket that matters most. And keep a short list of key names, owners and the date each was last rotated, because DigitalOcean will not keep that list for you.
FAQ
Do DigitalOcean Spaces access keys expire?
We found no expiry setting for Spaces keys in the documentation. A key lives until you delete or regenerate it, so schedule rotation yourself.
Can I see when a Spaces key was last used?
No documented field does that. The key schema has only the access key, creation date, grants and name. Spaces access logs, generally available since June 2025, are the nearest source, but confirm that a log line names the key before relying on it.
What is the safest way to rotate a Spaces key?
Create a new key with the same grants, switch the workload to it, confirm it works, remove the old key's bucket permissions as a reversible test, and delete the old key after a quiet week.
How do I share one file without sharing a key?
Use a presigned URL. The control panel's Quick Share offers durations from one hour to seven days, and the AWS CLI can generate one with a chosen expiry.
Secorvia takes Spaces credentials as an optional extra when you connect DigitalOcean, separate from the read-scope API token. The DigitalOcean integration page and the DigitalOcean page say what that covers.