How AWS Payments migrated from Redash to Amazon Redshift Query Editor v2 | Amazon Web Services
AWS Payments is part of the AWS Commerce Platform (CP) organization that owns the customer experience of paying AWS invoices. It helps AWS customers manage their payment methods and payment preferences, and helps customers make self-service payments to AWS.
The Machine Learning, Data and Analytics (MLDA) team at AWS Payments enables data-driven decision-making across payments processes and partners by delivering data, business insights, and causal and ML inferences through a scalable set of data, insights, and ML inference services.
In this post, we discuss how to democratize data access to Amazon Redshift using the Amazon Redshift Query Editor V2 .
At AWS Payments, we had been using Redash to allow our users to author and run SQL queries against our Amazon Redshift data warehouse. Redash is a web-based SQL client application that can be used to author and run queries, visualize query results with charts, and collaborate with teams.
Over time, we began to notice incompatibilities between Redash’s operations and the needs of our workload.
We had the following requirements in mind when looking for an alternative tool:
- Authentication and authorization
- Provide data access without creating a database user and password
- Allow list users using permission groups (POSIX/LDAP) for accessing the tool
- Limit user access to database objects
- User experience
- Run SQL queries on the selected database
- Save a query and rerun it later
- Write a dynamic SQL query and run the query based on input parameters
- Export a query result to CSV
- Search saved queries
- Share a query with other users as a URL
After an evaluation of alternate services, we chose the Amazon Redshift Query Editor V2.
Amazon Redshift Query Editor V2
The Amazon Redshift Query Editor V2 has the following benefits:
- It makes data across analytics and data scientists more accessible with a unified web-based analyst workbench for data analysts to explore, share, and collaborate on data through a SQL interface
- It provides a managed service that allows you to focus on exploring your data without managing your infrastructure
- Users can log in to the Query Editor using single sign-on (SSO)
- Users can connect to Amazon Redshift using federated access without providing a user name and password
- It enables you to collaborate with team members by providing the ability to share saved queries securely
- You can benefit from new features as soon as they get released by the Amazon Redshift Query Editor team
- You can keep track of changes made to saved queries using the Query History feature
- You can write parameterized SQL queries, which allows you to reuse a query with different values
- You can turn on the Chart feature to display a graphic visualization of the current page of results
- You can use notebooks to organize, annotate, and share multiple SQL queries in a single document
- You can run multiple queries in parallel by running each query in a separate tab
However, it presented the following challenges:
- To restrict user access to other AWS services within our AWS account, we attached the AWS Identity and Access Management (IAM) policies (see the appendix at the end of this post) to the SAML IAM role. The policies promote the following:
- The user can only access the Query Editor V2 service.
- The federated user gets assigned to a database group with limited access.
- The Query Editor V2 currently doesn’t support cross-account Amazon Redshift connections. However, we set up Amazon Redshift data sharing to access the Amazon Redshift cluster from other AWS accounts. For more details, refer to Sharing data across clusters in Amazon Redshift.
The following diagram illustrates our architecture.
In the following sections, we will walk you through the steps to set up the query editor and migrate Redash queries.
To implement this solution, you must set up federated access to the Amazon Redshift Query Editor V2 using your identity provider (IdP) services.
You can find more information in the following posts:
Set up Amazon Redshift Query Editor V2
To set up the query editor, complete the following steps:
- Create an Amazon Redshift database group with read-only access.
- Create an IAM role for accessing Query Editor V2 in an AWS account and attach the required IAM policies based on your use case. For more information, refer to Configuring your AWS account.
- Create a trust relationship between your IdP and AWS.
- Add the principal tag
sqlworkbench-teamto the IAM role to share queries. For more information, refer to Sharing a query.
Migrate Redash queries to Amazon Redshift Query Editor V2
In this section, we walk you through different ways to migrate your Redash queries to the Amazon Redshift Query Editor V2.
Query without parameters
Querying without parameters is pretty straightforward, just copy your query from Redash and enter it in the query editor.
- In Redash, navigate to the saved query and choose Edit Source.
- Copy the source query.
- In Amazon RedShift Query Editor V2, enter the query into the editor, choose the Save icon, and give your query a title.
Query with parameters
In Redash, a string between will be treated as a parameter, but Amazon RedShift Query Editor V2 uses $ to identify a parameter. To migrate queries with parameters, follow the same steps but replace with $ and with .
The following screenshot shows an example query in Redash.
The following screenshot shows the same query in Amazon RedShift Query Editor V2.
Multi-part query to a Query Editor V2 notebook
For a multi-part query, copy the query of each section of a Redash dashboard and add it to a notebook. The notebook in Amazon Redshift Query Editor V2 runs queries successively. You also can add a description for your query.
The following screenshot shows an example query on the Redash dashboard.
The following screenshot shows the query in an Amazon Redshift Query Editor V2 notebook.
In this post, we demonstrated how we set up Amazon Redshift Query Editor V2 with SSO and Amazon Redshift federated access, and migrated our customers from Redash to Amazon Redshift Query Editor V2. This solution reduced our operational cost of maintaining a third-party application and its infrastructure.
If you have similar use cases and need to provide a web-based tool to your customers to explore data on your Amazon Redshift cluster, consider using Amazon Redshift Query Editor V2.
Appendix: Customer IAM policies
In this section, we provide the code for the IAM policies we attached to the SAML IAM role to restrict user access to other AWS services within our AWS account:
- query-editor-credentials-policy – In the following code, provide your Region, account, and cluster parameters to grant access to Amazon Redshift to get cluster credentials, create users, and allow users to join groups:
- query-editor-access-policy – See the following code:
- query-editor-notebook-policy – See the following code:
About the Authors
Mohammad Nejad leads the AWS Payments Data Platform team. He has experience leading teams, architecting designs, implementing solutions, and launching products. Currently, his team focuses on building a modern data platform on AWS to provide a complete solution for processing, analyzing, and presenting data.
Erol Murtezaoglu, a Technical Product Manager at AWS, is an inquisitive and enthusiastic thinker with a drive for self-improvement and learning. He has a strong and proven technical background in software development and architecture, balanced with a drive to deliver commercially successful products. Erol highly values the process of understanding customer needs and problems, in order to deliver solutions that exceed expectations.
Mohamed Shaaban is a Senior Software Engineer in Amazon Redshift and is based in Berlin, Germany. He has over 12 years of experience in the software engineering. He is passionate about cloud services and building solutions that delight customers. Outside of work, he is an amateur photographer who loves to explore and capture unique moments.
For more updates check below links and stay updated with News AKMI.
Life and style || E Entertainment || Automotive News || Consumer Reviewer || Most Popular Video Games || Lifetime Fitness || Giant Bikes