Managing RLS policies
This section covers how to create, update, delete, list, and manage row-level security (RLS) policies and their attachments.
Permissions required
The following list shows the permissions required for each RLS policy operation.
- Create
-
Data lake administrators have implicit access. Non-admin principals need
CREATE_RLS_POLICYpermission on the catalog. - Update
-
Data lake administrators have implicit access. Non-admin principals need
ALTERpermission on the RLS policy resource. - Delete
-
Data lake administrators have implicit access. Non-admin principals need
DROPpermission on the RLS policy resource. - Attach, detach
-
Data lake administrators have implicit access. Non-admin principals need
ASSOCIATEpermission on the RLS policy resource, plusSELECTwith the grant option (orALL) on the target table. For tag-based attachments,MANAGE_TAG_POLICYon the referenced LF-Tag keys and values is required instead of table permissions. - List policies, list attachments
-
Any principal with
DESCRIBEpermission on the RLS policy resource. Data lake administrators can list all policies.
Data lake administrators have implicit permission to perform all RLS policy operations without explicit grants.
Creating an RLS policy
Field descriptions
The following table describes each field you specify when creating an RLS policy.
| Field | Required | Description |
|---|---|---|
| Name | Yes | A unique, case-insensitive name for the policy. Maximum 255 characters. |
| FilterExpression | Yes | The row filter expression. Maximum 2048 characters. Must use supported operators and reference only the declared attachment columns. |
| AttachmentColumns | Yes | List of columns referenced in the filter. Each entry has a Name
(string) and Type (string). |
Example Multi-column filter
aws lakeformation create-rls-policy \ --name "engineering-us-policy" \ --filter-expression "department = 'Engineering' AND country = 'US'" \ --attachment-columns '[{"Name": "department", "Type": "string"}, {"Name": "country", "Type": "string"}]'
Retrieving an RLS policy
aws lakeformation get-rls-policy \ --name "active-orders-policy"
Updating an RLS policy
You can update the filter expression of an existing policy. Attachment columns cannot be changed after creation. To change attachment columns, delete the policy and create a new one.
Important
Changes to the filter expression apply to all existing attachments. It can take a few seconds for principals with this policy attached to see the updated row set.
Deleting an RLS policy
Deleting a policy immediately removes all attachments and stops all filtering provided by the policy.
Warning
Deleting a policy is irreversible. Any RLS attachments made against the deleted policy
become inconsequential. Therefore, if no other policies are attached and no default policy
exists on the table, RLS no longer filters those principals' queries, and they see all rows
their Lake Formation SELECT permission allows.
Listing RLS policies and attachments
Example List RLS policies
aws lakeformation list-rls-policies \ --max-results 50
Example List RLS policy attachments
aws lakeformation list-rls-policy-attachments \ --name "active-orders-policy" \ --max-results 50
Attaching a policy to a table
For detailed instructions on attaching policies (including direct attachment, tag-based attachment, ABAC conditions, and default policies), see Attaching and detaching RLS policies.
Example Quick reference: Direct attachment
aws lakeformation attach-rls-policy \ --name "active-orders-policy" \ --resource '{"Table": {"DatabaseName": "analytics_db", "Name": "orders"}}' \ --principal '{"DataLakePrincipalIdentifier": "arn:aws:iam::111122223333:role/DataAnalyst"}'
Example Quick reference: Tag-based attachment
aws lakeformation attach-rls-policy \ --name "pii-filter-policy" \ --resource '{"LFTagPolicy": {"ResourceType": "TABLE", "Expression": [{"TagKey": "data-sensitivity", "TagValues": ["high"]}]}}' \ --principal '{"DataLakePrincipalIdentifier": "arn:aws:iam::111122223333:role/RestrictedUser"}'
Note
Tag-based attachment depends on the tags assigned to a table. If those tags change or are removed, the attachment can stop applying and principals may see all rows. For the risk and how to mitigate it, see Best practices for RLS policies.