This page shows you how to create, disable, and delete Hash-based Message
Authentication Code (HMAC) keys associated with service accounts in your
project.
Before you begin
Before using this feature in Cloud Storage, you must meet the following
requirements:
Have sufficient permission to work with HMAC keys in the selected project:
If you own the project, you most likely have the necessary permissions.
You should have the IAM permissions that are prefixed withstorage.hmacKeysfor the project. SeeUsing IAM Permissionsfor
instructions on how to get a role, such asStorage HMAC Key Admin,
that has these permissions.
Have a service account in your project that you intend to create HMAC keys
for. SeeCreating a service accountif you don't currently have one.
Make sure the following organization policy constraints are disabled:
# Create a new service account
resource "google_service_account" "service_account" {
account_id = "my-svc-acc"
}
# Create the HMAC key for the associated service account
resource "google_storage_hmac_key" "key" {
service_account_email = google_service_account.service_account.email
}
When you change the state of an HMAC key, it takes up to 3 minutes for the
state change to propagate through the Cloud Storage system. For this
reason, you should wait at least 3 minutes between making an HMAC key inactive
and deleting the key.
Delete an HMAC key
An HMAC key must be in an inactive state in order to delete it.
To delete an inactive HMAC key:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-05-29 UTC."],[],[]]