Manage access keys
See when each access key was last used and when it expires, deactivate or reactivate a key, delete it, and set how long new keys live.
Deactivating a key stops it working and keeps it, so it can be turned back on; deleting it is
final. Replace key-id with the key's id (a UUID, not the EWS1… key ID).
Prerequisites
- To list keys:
iam:ListAccessKeys. The console's Access keys page needs it for every task below; without it the page shows only "You do not have permission to list access keys." - To deactivate or activate a key, or give old keys an expiry:
iam:UpdateAccessKey. - To delete a key:
iam:DeleteAccessKey.
List keys
- Open Identity, then choose Access keys.
- (Optional) Choose Active, Inactive or Stale to narrow the list.
The table shows each key's Status, Principal, Last used, Expires and Created. Last used is updated at most once a minute.
dcloud iam access-keys list --iam-user-id 3f8b6c2e-1d4a-4b7e-9c2f-5a6b7c8d9e0fGET /iam/api/access-keys?iamUserId=3f8b6c2e-1d4a-4b7e-9c2f-5a6b7c8d9e0fNot available in Terraform. Terraform manages the keys it created; it does not list others.
Deactivate or activate a key
- On Access keys, open the key's actions menu.
- Choose Deactivate, or Activate for an inactive key.
To deactivate several keys at once, select them and choose Deactivate above the table.
dcloud iam access-keys set-status key-id --status inactivePATCH /iam/api/access-keys/key-id
{ "status": "inactive" }resource "dcloud_iam_access_key" "ci" {
iam_user_id = dcloud_iam_user.ci.id
status = "inactive"
}A request signed with an inactive key is refused with 401 Invalid or inactive access key.
Delete a key
Warning
Anything using the key loses access at once, through the API and S3 alike. A deleted key cannot be restored.
- On Access keys, open the key's actions menu and choose Delete key.
- Choose Delete.
dcloud iam access-keys delete key-idDELETE /iam/api/access-keys/key-idRemove the dcloud_iam_access_key resource from your configuration and apply.
Expiry
Every key made now expires. A request signed with an expired key is refused with 401
Access key has expired; the key stays listed, marked Expired.
- Lifetime of new keys. Your organization's settings, under Access keys, hold the
Default lifetime (days) (90 unless changed) and the Maximum lifetime (days) (365 unless
changed, at most 3650). Changing them needs
iam:UpdateOrganizationAuthPolicyand affects only keys created afterwards. - Keys without an expiry. Keys made before every key expired have none. Give them all one at once, counted from today:
- Open your organization's settings and find Access keys.
- Under Keys that never expire, choose Give them an expiry.
The keys get the default lifetime from today.
dcloud iam access-keys set-expiry --expires-in-days 90POST /iam/api/access-keys/set-expiry
{ "expiresInDays": 90 }Not available in Terraform. This is a one-off change to existing keys, not a resource.
Keys the platform made for app machines and keys from a role's token exchange are left out. The
answer says how many keys changed and their new expiry date. More days than the organization's
maximum is refused with 400 expiresInDays is …; this organization allows at most … days.
Related
- Create an access key
- Revoke role sessions: end temporary credentials of a role.
GET /iam/api/access-keys·PATCH /iam/api/access-keys/{id}·DELETE /iam/api/access-keys/{id}·POST /iam/api/access-keys/set-expiry