Amazon Redshift is a quick, scalable, safe, and absolutely managed cloud information warehouse that makes it easy and cost-effective to investigate all of your information utilizing customary SQL and your present ETL (extract, remodel, and cargo), enterprise intelligence (BI), and reporting instruments. Tens of 1000’s of shoppers use Amazon Redshift to course of exabytes of knowledge per day and energy analytics workloads similar to BI, predictive analytics, and real-time streaming analytics.
Amazon Redshift, a cloud information warehouse service, helps attaching dynamic information masking (DDM) insurance policies to paths of SUPER information sort columns, and makes use of the OBJECT_TRANSFORM operate with the SUPER information sort. SUPER information sort columns in Amazon Redshift include semi-structured information like JSON paperwork. Beforehand, information masking in Amazon Redshift solely labored with common desk columns, however now you may apply masking insurance policies particularly to components inside SUPER columns. For instance, you could possibly apply a masking coverage to masks delicate fields like bank card numbers inside JSON paperwork saved in a SUPER column. This enables for extra granular management over information masking in Amazon Redshift. Amazon Redshift offers you extra flexibility in the way you apply information masking to guard delicate data saved in SUPER columns containing semi-structured information.
With DDM assist in Amazon Redshift, you are able to do the next:
- Outline masking insurance policies that apply customized obfuscation insurance policies, similar to masking insurance policies to deal with bank card, personally identifiable data (PII) entries, HIPAA or GDPR wants, and extra
- Rework the information at question time to use masking insurance policies
- Connect masking insurance policies to roles or customers
- Connect a number of masking insurance policies with various ranges of obfuscation to the identical column in a desk and assign them to totally different roles with priorities to keep away from conflicts
- Implement cell-level masking through the use of conditional columns when creating your masking coverage
- Use masking insurance policies to partially or fully redact information, or hash it through the use of user-defined features (UDFs)
On this submit, we display how a retail firm can management the entry of PII information saved within the SUPER information sort to customers based mostly on their entry privilege with out duplicating the information.
Resolution overview
For our use case, we’ve got the next information entry necessities:
- Customers from the Buyer Service crew ought to be capable to view the order information however not PII data
- Customers from the Gross sales crew ought to be capable to view buyer IDs and all order data
- Customers from the Govt crew ought to be capable to view all the information
- Workers shouldn’t be in a position to view any information
The next diagram illustrates how DDM assist in Amazon Redshift insurance policies works with roles and customers for our retail use case.

The answer encompasses creating masking insurance policies with various masking guidelines and attaching a number of to the identical position and desk with an assigned precedence to take away potential conflicts. These insurance policies might pseudonymize outcomes or selectively nullify outcomes to adjust to retailers’ safety necessities. We seek advice from a number of masking insurance policies being hooked up to a desk as a multi-modal masking coverage. A multi-modal masking coverage consists of three elements:
- An information masking coverage that defines the information obfuscation guidelines
- Roles with totally different entry ranges relying on the enterprise case
- The power to connect a number of masking insurance policies on a person or position and desk mixture with precedence for battle decision
Stipulations
To implement this resolution, you want the next conditions:
Put together the information
To arrange our use case, full the next steps:
- On the Amazon Redshift console, select Question editor v2 underneath Explorer within the navigation pane.
In the event you’re acquainted with SQL Notebooks, you may obtain the SQL pocket book for the demonstration and import it to shortly get began.
- Create the desk and populate contents:
Implement the answer
To fulfill the safety necessities, we have to ensure that every person sees the identical information in numerous methods based mostly on their granted privileges. To do this, we use person roles mixed with masking insurance policies as follows:
- Create customers and roles, and add customers to their respective roles:
- Create masking insurance policies:
- Connect the masking insurance policies:
- Connect the masking coverage for the customer support use case:
- Connect the masking coverage for the gross sales use case:
- Connect the masking coverage for the employees use case:
Take a look at the answer
Let’s verify that the masking insurance policies are created and hooked up.
- Test that the masking insurance policies are created with the next code:

- Test that the masking insurance policies are hooked up:

Now you may take a look at that totally different customers can see the identical information masked in a different way based mostly on their roles.
- Take a look at that the shopper assist can’t see buyer PHI/PII information however can see the order ID, order particulars, and standing:

- Take a look at that the gross sales crew can see the shopper ID (non PII information) and all order data:

- Take a look at that the executives can see all information:

- Take a look at that the employees can’t see any information concerning the order. All columns ought to masked for them.

Object_Transform operate
On this part, we dive into the capabilities and advantages of the OBJECT_TRANSFORM operate and discover the way it empowers you to effectively reshape your information for evaluation. The OBJECT_TRANSFORM operate in Amazon Redshift is designed to facilitate information transformations by permitting you to control JSON information immediately inside the database. With this operate, you may apply transformations to semi-structured or SUPER information varieties, making it simpler to work with complicated information constructions in a relational database setting.
Let’s take a look at some utilization examples.
First, create a desk and populate contents:

Apply the transformations with the OBJECT_TRANSFORM operate:

As you may see within the instance, by making use of the transformation with OBJECT_TRANSFORM, the individual title is formatted in lowercase and the wage is elevated by 10%. This demonstrates how the transformation makes is simpler to work with semi-structured or nested information varieties.
Clear up
If you’re performed with the answer, clear up your sources:
- Detach the masking insurance policies from the desk:
- Drop the masking insurance policies:
- Revoke or drop the roles and customers:
- Drop the desk:
Issues and greatest practices
Contemplate the next when implementing this resolution:
- When attaching a masking coverage to a path on a column, that column have to be outlined because the SUPER information sort. You’ll be able to solely apply masking insurance policies to scalar values on the SUPER path. You’ll be able to’t apply masking insurance policies to complicated constructions or arrays.
- You’ll be able to apply totally different masking insurance policies to a number of scalar values on a single SUPER column so long as the SUPER paths don’t battle. For instance, the SUPER paths a.b and a.b.c battle as a result of they’re on the identical path, with a.b being the mum or dad of a.b.c. The SUPER paths a.b.c and a.b.d don’t battle.
Check with Utilizing dynamic information masking with SUPER information sort paths for extra particulars on issues.
Conclusion
On this submit, we mentioned the way to use DDM assist for the SUPER information sort in Amazon Redshift to outline configuration-driven, constant, format-preserving, and irreversible masked information values. With DDM assist in Amazon Redshift, you may management your information masking strategy utilizing acquainted SQL language. You’ll be able to reap the benefits of the Amazon Redshift role-based entry management functionality to implement totally different ranges of knowledge masking. You’ll be able to create a masking coverage to establish which column must be masked, and you’ve got the pliability of selecting the way to present the masked information. For instance, you may fully cover all the data of the information, exchange partial actual values with wildcard characters, or outline your individual solution to masks the information utilizing SQL expressions, Python, or Lambda UDFs. Moreover, you may apply conditional masking based mostly on different columns, which selectively protects the column information in a desk based mostly on the values in a number of columns.
We encourage you to create your individual user-defined features for numerous use circumstances and obtain your required safety posture utilizing dynamic information masking assist in Amazon Redshift.
Concerning the Authors
Ritesh Kumar Sinha is an Analytics Specialist Options Architect based mostly out of San Francisco. He has helped clients construct scalable information warehousing and massive information options for over 16 years. He likes to design and construct environment friendly end-to-end options on AWS. In his spare time, he loves studying, strolling, and doing yoga.
Tahir Aziz is an Analytics Resolution Architect at AWS. He has labored with constructing information warehouses and massive information options for over 15+ years. He loves to assist clients design end-to-end analytics options on AWS. Exterior of labor, he enjoys touring and cooking.
Omama Khurshid is an Acceleration Lab Options Architect at Amazon Net Providers. She focuses on serving to clients throughout numerous industries construct dependable, scalable, and environment friendly options. Exterior of labor, she enjoys spending time along with her household, watching motion pictures, listening to music, and studying new applied sciences.






