Lesson 8 of 13 Amazon Redshift

Securing Data in Amazon Redshift

This lesson explains how Redshift security combines IAM, database permissions down to rows and columns, encryption and auditing, for a warehouse that holds sensitive data used by many people with different rights.

Learning outcomes

After completing this lesson, you will be able to:

  • Combine IAM roles with database users, roles and grants.
  • Apply row-level security and dynamic data masking.
  • Encrypt data and audit activity.
  • Apply least privilege with role-based permissions.

Authentication and authorisation

Redshift security combines IAM with controls inside the database. For Redshift to reach other services, for COPY and UNLOAD to S3, Spectrum and Redshift ML, IAM roles are attached to the cluster or namespace, so no access keys are stored. Users sign in as database users, with temporary credentials generated from IAM, or through federation with IAM Identity Center or an identity provider.

Inside the database, roles created with CREATE ROLE receive grants, including on individual columns. Row-level security policies filter the rows each user or role can see, and dynamic data masking replaces sensitive values, such as card numbers, with masked versions at query time for users not authorised to see them. The following table summarises the controls.

ControlHow
Access to other servicesIAM roles on the cluster or namespace, for COPY, UNLOAD, Spectrum and ML
User sign-inDatabase users, IAM-based temporary credentials, or federation with IAM Identity Center or an IdP
Role-based accessCREATE ROLE and GRANT, including column-level grants
Row-level security (RLS)Policies filter rows by user or role
Dynamic data masking (DDM)Masks values such as card numbers at query time for unauthorised users
Match the pairs

Redshift security controls

Exam skills 4.2.3 · 4.3.1

Match each requirement with the Redshift control.

Log in to try this activity Interactive activities are free with an account.

Encryption, auditing and networking

Data at rest in Redshift is encrypted with AWS KMS keys, including snapshots and backups, and the require_ssl parameter forces clients to connect over TLS, so data is also protected in transit. Audit logging records connections, user activity and queries, and delivers the logs to Amazon S3 or CloudWatch Logs, where they support investigations and compliance reporting.

Network controls keep the warehouse private. Clusters and Serverless workgroups can be made private, reachable only from within the VPC or through VPC endpoints. Enhanced VPC routing forces the traffic that COPY and UNLOAD send to Amazon S3 through the VPC, so it can be controlled with VPC endpoint policies, security groups and network monitoring rather than travelling outside the VPC.

Least privilege in practice

In practice, least privilege in Redshift means granting permissions to roles that represent jobs, such as analyst, finance analyst or ETL loader, and assigning users to roles, rather than granting permissions to individual users. Default privileges ensure that tables created in the future automatically receive the right grants, so new tables are not accidentally left inaccessible or overexposed.

Sensitive columns are protected with column-level grants or dynamic data masking policies, and rows with row-level security policies attached to roles. Together, these let one table safely serve several audiences: a sales table can show each regional team only its own rows, show finance every row, and mask customer contact details for everyone except the customer service role.

The following diagram shows the same rows as each role sees them.

The customers table as two roles see it. A row-level security policy attached to the regional_manager role shows a manager in the North region only North customers. A masking policy attached to the analyst role shows every row but replaces the part of each email before the @ sign.
The rows are illustrative; grey cells are filtered out by the policy.
Select all that apply

Least privilege in Redshift

Exam skills 4.2.3 · 4.2.6

Identify the least-privilege practices for Redshift.

Log in to try this activity Interactive activities are free with an account.
Worked example

One table, several audiences

A customers table is used by regional managers, who may see only their own region's customers, and by analysts, who may see all regions but not full email addresses. Row-level security and dynamic data masking serve both from the same table, as follows.

CREATE RLS POLICY own_region WITH (region VARCHAR(20))
USING (region IN (SELECT region FROM manager_regions WHERE manager = current_user));
ATTACH RLS POLICY own_region ON customers TO ROLE regional_manager;
ALTER TABLE customers ROW LEVEL SECURITY ON;

CREATE MASKING POLICY mask_email WITH (email VARCHAR(256))
USING ('***' || SUBSTRING(email, POSITION('@' IN email)));
ATTACH MASKING POLICY mask_email ON customers(email) TO ROLE analyst;

Managers see only their rows, analysts see masked emails, and no copies of the table are needed. Policies are attached to roles, so new staff receive the right access when they are granted the role.

Check yourself

How is COPY and UNLOAD traffic forced through the VPC?

Show answer

By enabling enhanced VPC routing.

Exam Tips

Remember for the exam

  • To filter rows per user, use row-level security; to mask sensitive columns, use dynamic data masking.
  • To force COPY and UNLOAD traffic through the VPC, enable enhanced VPC routing.
  • Give Redshift an IAM role for COPY, UNLOAD and Spectrum.
  • To require encrypted connections, set require_ssl.
  • Audit logging records connections and queries for investigations.