This page shows you how to enable, disable, and check the status of
uniform bucket-level access on a bucket in Cloud Storage.
Required roles
To get the permissions that you need to set and manage uniform bucket-level access on a
bucket, ask your administrator to grant you the Storage Admin
(roles/storage.admin) role on the bucket. This
predefined role contains the permissions required to set and manage
uniform bucket-level access. To see the exact permissions that are required, expand the
Required permissions section:
Required permissions
storage.buckets.get
storage.buckets.list
This permission is only required if you plan on using the
Google Cloud console to perform the instructions on this page.
storage.buckets.update
You might also be able to get these permissions with custom roles.
Before you enable uniform bucket-level access, use Cloud Monitoring to ensure your
bucket is not using ACLs for any workflows. For more information, see
Check object ACL usage.
Console
To view the metrics for a monitored resource by using the
Metrics Explorer, do the following:
In the Google Cloud console, go to the
leaderboardMetrics explorer page:
If you use the search bar to find this page, then select the result whose subheading is
Monitoring.
In the toolbar of the Google Cloud console, select your Google Cloud project.
For App Hub configurations, select the
App Hub host project or the app-enabled folder's management project.
In the Metric element, expand the Select a metric menu,
enter ACLs usage
in the filter bar, and then use the submenus to select a specific resource type and metric:
In the Active resources menu, select GCS Bucket.
In the Active metric categories menu, select Authz.
In the Active metrics menu, select ACLs usage.
Click Apply.
The fully qualified name for this metric is storage.googleapis.com/authz/acl_operations_count..
To add filters, which remove time series from the query results, use the
Filter element.
Configure how the data is viewed. For example, to view your data by the ACL
operation, for the Aggregation element, set the first menu to Sum
and the second menu to acl_operation.
The following sample enables uniform bucket-level access on a bucket:
usingGoogle.Apis.Storage.v1.Data;usingGoogle.Cloud.Storage.V1;usingSystem;publicclassEnableUniformBucketLevelAccessSample{publicBucketEnableUniformBucketLevelAccess(stringbucketName="your-unique-bucket-name"){varstorage=StorageClient.Create();varbucket=storage.GetBucket(bucketName);bucket.IamConfiguration.UniformBucketLevelAccess.Enabled=true;bucket=storage.UpdateBucket(bucket);Console.WriteLine($"Uniform bucket-level access was enabled for {bucketName}.");returnbucket;}}
The following sample disables uniform bucket-level access on a bucket:
usingGoogle.Apis.Storage.v1.Data;usingGoogle.Cloud.Storage.V1;usingSystem;publicclassDisableUniformBucketLevelAccessSample{publicBucketDisableUniformBucketLevelAccess(stringbucketName="your-unique-bucket-name"){varstorage=StorageClient.Create();varbucket=storage.GetBucket(bucketName);bucket.IamConfiguration.UniformBucketLevelAccess.Enabled=false;bucket.IamConfiguration.BucketPolicyOnly.Enabled=false;bucket=storage.UpdateBucket(bucket);Console.WriteLine($"Uniform bucket-level access was disabled for {bucketName}.");returnbucket;}}
The following sample enables uniform bucket-level access on a bucket:
importcom.google.cloud.storage.Bucket;importcom.google.cloud.storage.BucketInfo;importcom.google.cloud.storage.Storage;importcom.google.cloud.storage.Storage.BucketTargetOption;importcom.google.cloud.storage.StorageException;importcom.google.cloud.storage.StorageOptions;publicclassEnableUniformBucketLevelAccess{publicstaticvoidenableUniformBucketLevelAccess(StringprojectId,StringbucketName)throwsStorageException{// The ID of your GCP project// String projectId = "your-project-id";// The ID of your GCS bucket// String bucketName = "your-unique-bucket-name";Storagestorage=StorageOptions.newBuilder().setProjectId(projectId).build().getService();// first look up the bucket, so we will have its metagenerationBucketbucket=storage.get(bucketName);BucketInfo.IamConfigurationiamConfiguration=BucketInfo.IamConfiguration.newBuilder().setIsUniformBucketLevelAccessEnabled(true).build();storage.update(bucket.toBuilder().setIamConfiguration(iamConfiguration).setAcl(null).setDefaultAcl(null).build(),BucketTargetOption.metagenerationMatch());System.out.println("Uniform bucket-level access was enabled for "+bucketName);}}
The following sample disables uniform bucket-level access on a bucket:
importcom.google.cloud.storage.Bucket;importcom.google.cloud.storage.BucketInfo;importcom.google.cloud.storage.Storage;importcom.google.cloud.storage.Storage.BucketTargetOption;importcom.google.cloud.storage.StorageException;importcom.google.cloud.storage.StorageOptions;publicclassDisableUniformBucketLevelAccess{publicstaticvoiddisableUniformBucketLevelAccess(StringprojectId,StringbucketName)throwsStorageException{// The ID of your GCP project// String projectId = "your-project-id";// The ID of your GCS bucket// String bucketName = "your-unique-bucket-name";Storagestorage=StorageOptions.newBuilder().setProjectId(projectId).build().getService();// first look up the bucket, so we will have its metagenerationBucketbucket=storage.get(bucketName);BucketInfo.IamConfigurationiamConfiguration=BucketInfo.IamConfiguration.newBuilder().setIsUniformBucketLevelAccessEnabled(false).build();storage.update(bucket.toBuilder().setIamConfiguration(iamConfiguration).build(),BucketTargetOption.metagenerationMatch());System.out.println("Uniform bucket-level access was disabled for "+bucketName);}}
The following sample enables uniform bucket-level access on a bucket:
/** * TODO(developer): Uncomment the following lines before running the sample. */// The ID of your GCS bucket// const bucketName = 'your-unique-bucket-name';// Imports the Google Cloud client libraryconst{Storage}=require('@google-cloud/storage');// Creates a clientconststorage=newStorage();// Enables uniform bucket-level access for the bucketasyncfunctionenableUniformBucketLevelAccess(){awaitstorage.bucket(bucketName).setMetadata({iamConfiguration:{uniformBucketLevelAccess:{enabled:true,},},});console.log(`Uniform bucket-level access was enabled for ${bucketName}.`);}enableUniformBucketLevelAccess().catch(console.error);
The following sample disables uniform bucket-level access on a bucket:
/** * TODO(developer): Uncomment the following lines before running the sample. */// The ID of your GCS bucket// const bucketName = 'your-unique-bucket-name';// Imports the Google Cloud client libraryconst{Storage}=require('@google-cloud/storage');// Creates a clientconststorage=newStorage();asyncfunctiondisableUniformBucketLevelAccess(){// Disables uniform bucket-level access for the bucketawaitstorage.bucket(bucketName).setMetadata({iamConfiguration:{uniformBucketLevelAccess:{enabled:false,},},});console.log(`Uniform bucket-level access was disabled for ${bucketName}.`);}disableUniformBucketLevelAccess().catch(console.error);
The following sample enables uniform bucket-level access on a bucket:
fromgoogle.cloudimportstoragedefenable_uniform_bucket_level_access(bucket_name):"""Enable uniform bucket-level access for a bucket"""# bucket_name = "my-bucket"storage_client=storage.Client()bucket=storage_client.get_bucket(bucket_name)bucket.iam_configuration.uniform_bucket_level_access_enabled=Truebucket.patch()print(f"Uniform bucket-level access was enabled for {bucket.name}.")
The following sample disables uniform bucket-level access on a bucket:
fromgoogle.cloudimportstoragedefdisable_uniform_bucket_level_access(bucket_name):"""Disable uniform bucket-level access for a bucket"""# bucket_name = "my-bucket"storage_client=storage.Client()bucket=storage_client.get_bucket(bucket_name)bucket.iam_configuration.uniform_bucket_level_access_enabled=Falsebucket.patch()print(f"Uniform bucket-level access was disabled for {bucket.name}.")
The following sample enables uniform bucket-level access on a bucket:
defenable_uniform_bucket_level_accessbucket_name:# The ID of your GCS bucket# bucket_name = "your-unique-bucket-name"require"google/cloud/storage"storage=Google::Cloud::Storage.newbucket=storage.bucketbucket_namebucket.uniform_bucket_level_access=trueputs"Uniform bucket-level access was enabled for #{bucket_name}."end
The following sample disables uniform bucket-level access on a bucket:
defdisable_uniform_bucket_level_accessbucket_name:# The ID of your GCS bucket# bucket_name = "your-unique-bucket-name"require"google/cloud/storage"storage=Google::Cloud::Storage.newbucket=storage.bucketbucket_namebucket.uniform_bucket_level_access=falseputs"Uniform bucket-level access was disabled for #{bucket_name}."end
Rust
The following sample enables uniform bucket-level access on a bucket:
usegoogle_cloud_storage::client::StorageControl;usegoogle_cloud_storage::model::bucket::IamConfig;usegoogle_cloud_storage::model::bucket::iam_config::UniformBucketLevelAccess;usegoogle_cloud_wkt::FieldMask;pubasyncfnsample(client:&StorageControl,bucket_id:&str)->anyhow::Result<()>{letbucket=client.get_bucket().set_name(format!("projects/_/buckets/{bucket_id}")).send().await?;letmetageneration=bucket.metageneration;letiam_config=IamConfig::new().set_uniform_bucket_level_access(UniformBucketLevelAccess::new().set_enabled(true));letbucket=client.update_bucket().set_bucket(bucket.set_iam_config(iam_config)).set_if_metageneration_match(metageneration).set_update_mask(FieldMask::default().set_paths(["iam_config.uniform_bucket_level_access"])).send().await?;println!("Uniform bucket-level access enabled for bucket {bucket_id}: {:?}",bucket.iam_config);Ok(())}
The following sample disables uniform bucket-level access on a bucket:
usegoogle_cloud_storage::client::StorageControl;usegoogle_cloud_storage::model::bucket::IamConfig;usegoogle_cloud_storage::model::bucket::iam_config::UniformBucketLevelAccess;usegoogle_cloud_wkt::FieldMask;pubasyncfnsample(client:&StorageControl,bucket_id:&str)->anyhow::Result<()>{letbucket=client.get_bucket().set_name(format!("projects/_/buckets/{bucket_id}")).send().await?;letmetageneration=bucket.metageneration;letiam_config=IamConfig::new().set_uniform_bucket_level_access(UniformBucketLevelAccess::new().set_enabled(false));letbucket=client.update_bucket().set_bucket(bucket.set_iam_config(iam_config)).set_if_metageneration_match(metageneration).set_update_mask(FieldMask::default().set_paths(["iam_config.uniform_bucket_level_access"])).send().await?;println!("Uniform bucket-level access disabled for bucket {bucket_id}: {:?}",bucket.iam_config);Ok(())}
namespacegcs=::google::cloud::storage;using::google::cloud::StatusOr;[](gcs::Clientclient,std::stringconst&bucket_name){StatusOr<gcs::BucketMetadata>bucket_metadata=client.GetBucketMetadata(bucket_name);if(!bucket_metadata)throwstd::move(bucket_metadata).status();if(bucket_metadata->has_iam_configuration()&&
bucket_metadata->iam_configuration().uniform_bucket_level_access.has_value()){gcs::UniformBucketLevelAccessuniform_bucket_level_access=*bucket_metadata->iam_configuration().uniform_bucket_level_access;std::cout << "Uniform Bucket Level Access is enabled for " << bucket_metadata->name() << "\n";std::cout << "Bucket will be locked on " << uniform_bucket_level_access << "\n";}else{std::cout << "Uniform Bucket Level Access is not enabled for " << bucket_metadata->name() << "\n";}}
usingGoogle.Cloud.Storage.V1;usingSystem;usingstaticGoogle.Apis.Storage.v1.Data.Bucket.IamConfigurationData;publicclassGetUniformBucketLevelAccessSample{publicUniformBucketLevelAccessDataGetUniformBucketLevelAccess(stringbucketName="your-unique-bucket-name"){varstorage=StorageClient.Create();varbucket=storage.GetBucket(bucketName);varuniformBucketLevelAccess=bucket.IamConfiguration.UniformBucketLevelAccess;booluniformBucketLevelAccessEnabled=uniformBucketLevelAccess.Enabled??false;if(uniformBucketLevelAccessEnabled){Console.WriteLine($"Uniform bucket-level access is enabled for {bucketName}.");Console.WriteLine($"Uniform bucket-level access will be locked on {uniformBucketLevelAccess.LockedTime}.");}else{Console.WriteLine($"Uniform bucket-level access is not enabled for {bucketName}.");}returnuniformBucketLevelAccess;}}
import("context""fmt""io""time""cloud.google.com/go/storage")// getUniformBucketLevelAccess gets uniform bucket-level access.funcgetUniformBucketLevelAccess(wio.Writer,bucketNamestring)(*storage.BucketAttrs,error){// bucketName := "bucket-name"ctx:=context.Background()client,err:=storage.NewClient(ctx)iferr!=nil{returnnil,fmt.Errorf("storage.NewClient: %w",err)}deferclient.Close()ctx,cancel:=context.WithTimeout(ctx,time.Second*10)defercancel()attrs,err:=client.Bucket(bucketName).Attrs(ctx)iferr!=nil{returnnil,fmt.Errorf("Bucket(%q).Attrs: %w",bucketName,err)}uniformBucketLevelAccess:=attrs.UniformBucketLevelAccessifuniformBucketLevelAccess.Enabled{fmt.Fprintf(w,"Uniform bucket-level access is enabled for %q.\n",attrs.Name)fmt.Fprintf(w,"Bucket will be locked on %q.\n",uniformBucketLevelAccess.LockedTime)}else{fmt.Fprintf(w,"Uniform bucket-level access is not enabled for %q.\n",attrs.Name)}returnattrs,nil}
importcom.google.cloud.storage.Bucket;importcom.google.cloud.storage.BucketInfo;importcom.google.cloud.storage.Storage;importcom.google.cloud.storage.StorageException;importcom.google.cloud.storage.StorageOptions;importjava.util.Date;publicclassGetUniformBucketLevelAccess{publicstaticvoidgetUniformBucketLevelAccess(StringprojectId,StringbucketName)throwsStorageException{// The ID of your GCP project// String projectId = "your-project-id";// The ID of your GCS bucket// String bucketName = "your-unique-bucket-name";Storagestorage=StorageOptions.newBuilder().setProjectId(projectId).build().getService();Bucketbucket=storage.get(bucketName,Storage.BucketGetOption.fields(Storage.BucketField.IAMCONFIGURATION));BucketInfo.IamConfigurationiamConfiguration=bucket.getIamConfiguration();Booleanenabled=iamConfiguration.isUniformBucketLevelAccessEnabled();DatelockedTime=newDate(iamConfiguration.getUniformBucketLevelAccessLockedTime());if(enabled!=null && enabled){System.out.println("Uniform bucket-level access is enabled for "+bucketName);System.out.println("Bucket will be locked on "+lockedTime);}else{System.out.println("Uniform bucket-level access is disabled for "+bucketName);}}}
/** * TODO(developer): Uncomment the following lines before running the sample. */// The ID of your GCS bucket// const bucketName = 'your-unique-bucket-name';// Imports the Google Cloud client libraryconst{Storage}=require('@google-cloud/storage');// Creates a clientconststorage=newStorage();asyncfunctiongetUniformBucketLevelAccess(){// Gets Bucket Metadata and checks if uniform bucket-level access is enabled.const[metadata]=awaitstorage.bucket(bucketName).getMetadata();if(metadata.iamConfiguration){constuniformBucketLevelAccess=metadata.iamConfiguration.uniformBucketLevelAccess;console.log(`Uniform bucket-level access is enabled for ${bucketName}.`);console.log(`Bucket will be locked on ${uniformBucketLevelAccess.lockedTime}.`);}else{console.log(`Uniform bucket-level access is not enabled for ${bucketName}.`);}}getUniformBucketLevelAccess().catch(console.error);
fromgoogle.cloudimportstoragedefget_uniform_bucket_level_access(bucket_name):"""Get uniform bucket-level access for a bucket"""# bucket_name = "my-bucket"storage_client=storage.Client()bucket=storage_client.get_bucket(bucket_name)iam_configuration=bucket.iam_configurationifiam_configuration.uniform_bucket_level_access_enabled:print(f"Uniform bucket-level access is enabled for {bucket.name}.")print("Bucket will be locked on {}.".format(iam_configuration.uniform_bucket_level_locked_time))else:print(f"Uniform bucket-level access is disabled for {bucket.name}.")
defget_uniform_bucket_level_accessbucket_name:# The ID of your GCS bucket# bucket_name = "your-unique-bucket-name"require"google/cloud/storage"storage=Google::Cloud::Storage.newbucket=storage.bucketbucket_nameifbucket.uniform_bucket_level_access?puts"Uniform bucket-level access is enabled for #{bucket_name}."puts"Bucket will be locked on #{bucket.uniform_bucket_level_access_locked_at}."elseputs"Uniform bucket-level access is disabled for #{bucket_name}."endend
Rust
usegoogle_cloud_storage::client::StorageControl;pubasyncfnsample(client:&StorageControl,bucket_id:&str)->anyhow::Result<()>{letbucket=client.get_bucket().set_name(format!("projects/_/buckets/{bucket_id}")).send().await?;println!("IAM Config for bucket {bucket_id} is: {:?}",bucket.iam_config);Ok(())}
[[["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-06-09 UTC."],[],[]]