Sub topic 9
Controlling access to cloud storage
This chapter assumes you know the Unity Catalog object hierarchy, how GRANT and REVOKE work, and the difference between a principal and a group. It covers how Unity Catalog controls access to files in cloud storage, not just to tables.
Why storage needs its own securables
Tables are governed by privileges on catalogs, schemas and tables. Files in a cloud bucket or container are different. They live outside the metastore, and the cloud provider decides who can read them. Unity Catalog does not hand users cloud credentials directly. Instead, it holds one credential on their behalf and checks Unity Catalog privileges before using it.
Two securable objects make this work:
- A storage credential wraps a cloud identity that can reach storage, such as an IAM role on AWS or a managed identity on Azure.
- An external location pairs a storage path, such as
s3://my-bucket/landing, with a storage credential.
Users receive privileges on the external location. They never receive the cloud identity itself.
Granting access on an external location
Privileges on an external location are granted with the same GRANT statement used elsewhere. The privilege you choose decides what the principal can do with files under that path.
GRANT CREATE EXTERNAL TABLE ON EXTERNAL LOCATION landing_zone TO `data-engineers`;Common privileges on an external location are:
| Privilege | What it allows |
|---|---|
| `READ FILES` | Read files directly from the path |
| `WRITE FILES` | Write files directly to the path |
| `CREATE EXTERNAL TABLE` | Register an external table whose data sits in the path |
| `CREATE EXTERNAL VOLUME` | Register an external volume on the path |
| `CREATE MANAGED STORAGE` | Use the path as managed storage for a catalog or schema |
Access to a path covers its subdirectories. Do not create external locations that overlap, because Unity Catalog uses the path hierarchy to decide which location applies.
Why this is safer than direct cloud access
If you gave users cloud permissions directly, you would manage two permission systems. Their access would also bypass Unity Catalog auditing. With external locations, you manage access in one place, and Unity Catalog records the access in the audit log.
Grant on the external location to a group, not to individuals. Reserve READ FILES and WRITE FILES for the few people who need raw file access. Most analysts should query governed tables and never touch the path.
SHOW GRANTS ON EXTERNAL LOCATION landing_zone;Common errors
- Permission denied on a path you can see in the cloud console. Cloud permissions do not matter to the user. They need a privilege on an external location that covers the path.
- Creating an external table fails. You also need
CREATE TABLEon the schema. TheCREATE EXTERNAL TABLEprivilege alone is not enough. - No external location covers the path. Unity Catalog cannot find one, so access fails even for an administrator. Create the location first.
- Overlapping locations. Creating a location inside an existing one can be rejected. Plan your path layout before you create locations.
- Storage credential works in one place only. The cloud identity behind the credential must have permission on the specific bucket or container. A credential is only as broad as its cloud role.
Exercise
A group needs to register external tables over files in s3://my-bucket/landing, which is covered by the external location landing_zone. Which statement grants the storage-side privilege, and what else do they need on the schema?
Show answer
Run GRANT CREATE EXTERNAL TABLE ON EXTERNAL LOCATION landing_zone TO the group. They also need CREATE TABLE (plus USE SCHEMA and USE CATALOG) on the target schema, because registering the table is a schema-level action.
Exercise
Why is it safer to grant READ FILES on an external location than to give users read access to the bucket in the cloud console?
Show answer
Unity Catalog checks the privilege, uses its own storage credential on the user's behalf, and records the access in the audit log. Direct cloud access would bypass this governance and add a second permission system to manage.