In today’s data-driven world, the ability to seamlessly integrate and utilize diverse data sources is critical for gaining actionable insights and driving innovation. As organizations increasingly rely on data stored across various platforms, such as Snowflake, Amazon Simple Storage Service (Amazon S3), and various software as a service (SaaS) applications, the challenge of bringing these disparate data sources together has never been more pressing.
AWS Glue is a robust data integration service that facilitates the consolidation of data from different origins, empowering businesses to use the full potential of their data assets. By using AWS Glue to integrate data from Snowflake, Amazon S3, and SaaS applications, organizations can unlock new opportunities in generative artificial intelligence (AI), machine learning (ML), business intelligence (BI), and self-service analytics or feed data to underlying applications.
In this post, we explore how AWS Glue can serve as the data integration service to bring the data from Snowflake for your data integration strategy, enabling you to harness the power of your data ecosystem and drive meaningful outcomes across various use cases.
Use case Consider a large ecommerce company that relies heavily on data-driven insights to optimize its operations, marketing strategies, and customer experiences. The company stores vast amounts of transactional data, customer information, and product catalogs in Snowflake. However, they also generate and collect data from various other sources, such as web logs stored in Amazon S3, social media platforms, and third-party data providers. To gain a comprehensive understanding of their business and make informed decisions, the company needs to integrate and analyze data from all these sources seamlessly.
One crucial business requirement for the ecommerce company is to generate a Pricing Summary Report that provides a detailed analysis of pricing and discounting strategies. This report is essential for understanding revenue streams, identifying opportunities for optimization, and making data-driven decisions regarding pricing and promotions. After the Pricing Summary Report is generated and stored in Amazon S3, the company can use AWS analytics services to generate interactive BI dashboards and run one-time queries on the report. This allows business analysts and decision-makers to gain valuable insights, visualize key metrics, and explore the data in depth, enabling informed decision-making and strategic planning for pricing and promotional strategies.
Solution overview The following architecture diagram illustrates a secure and efficient solution of integrating Snowflake data with Amazon S3, using the native Snowflake connector in AWS Glue. This setup uses AWS PrivateLink to provide secure connectivity between AWS services across different virtual private clouds (VPCs), eliminating the need to expose data to the public internet, which is a critical need for organizations.
The following are the key components and steps in the integration process:
This approach offers the following benefits:
By following this architecture and taking advantage of the capabilities of AWS Glue, PrivateLink, and associated AWS services, organizations can achieve a robust, secure, and efficient data integration solution, enabling them to harness the full potential of their Snowflake and Amazon S3 data for advanced analytics and BI.
Prerequisites Complete the following prerequisites before setting up the solution:
privatelink-vpce-idprivatelink-account-urlprivatelink_ocsp-urlregionless-snowsight-privatelink-urlsnowflakeUser and password snowflakePassword with required permissions to read from and write to Snowflake. The user and password are used in the AWS Glue connection to authenticate within Snowflake.snowflakeWarehouse as a placeholder for the warehouse name; replace it with your actual warehouse name.Create resources with AWS CloudFormation This post includes a CloudFormation template for a quick setup of the base resources. You can review and customize it to suit your needs if needed. The CloudFormation template generates the following resources:
vpc-blog-glue-snowflake)blog-glue-snowflake-*)blog-glue-snowflake-GlueServiceRole-*)db_blog_glue_snowflake)blog-workgroup)To create your resources, complete the following steps:
privatelink-account-url obtained in the prerequisites.privatelink_ocsp-url obtained in the prerequisites.privatelink-vpce-id obtained in the prerequisites.regionless-snowsight-privatelink-url obtained in the prerequisites.After the CloudFormation stack is successfully created, you can see all the resources created on the Resources tab.
Navigate to the Outputs tab to see the outputs provided by CloudFormation stack. Save the value of the outputs GlueSecurityGroupId, VpcId, and PrivateSubnet1Id to use in the next step in this post.
Update the Secrets Manager secret with Snowflake credentials for the AWS Glue connection To update the Secrets Manager secret with user snowflakeUser, password snowflakePassword, and warehouse snowflakeWarehouse that you will use in the AWS Glue connection to establish a connection to Snowflake, complete the following steps:
blog-glue-snowflake-credentials.Under Secret value, choose Retrieve secret value.
Choose Edit.
snowflakePassword, and warehouse snowflakeWarehouse for the keys sfUser, sfPassword, and sfWarehouse, respectively.Create the AWS Glue connection for Snowflake An AWS Glue connection is an AWS Glue Data Catalog object that stores login credentials, URI strings, VPC information, and more for a particular data store. AWS Glue crawlers, jobs, and development endpoints use connections in order to access certain types of data stores. To create an AWS Glue connection to Snowflake, complete the following steps:
Choose Next.
For Snowflake URL, enter https://<privatelink-account-url>.
To obtain the Snowflake PrivateLink account URL, refer to parameters obtained in the prerequisites.
blog-glue-snowflake-credentials.VpcId value obtained from the CloudFormation stack output.PrivateSubnet1Id value obtained from the CloudFormation stack output.GlueSecurityGroupId value obtained from the CloudFormation stack output.Choose Next.
In the Connection Properties section, for Name, enter glue-snowflake-connection.
Choose Next.
Choose Create connection.
Create an AWS Glue job You’re now ready to define the AWS Glue job using the Snowflake connection. To create an AWS Glue job to read from Snowflake, complete the following steps:
On the AWS Glue console, under ETL jobs in the navigation pane, choose Visual ETL.
Choose the Job details tab.
Pricing Summary Report Job.blog-glue-snowflake-GlueServiceRole-*.Choose Save to save the job.
On the Visual tab, choose Add nodes.
For Sources, choose Snowflake.
Choose Data source – Snowflake in the AWS Glue Studio canvas.
Snowflake_Pricing_Summary.glue-snowflake-connection.snowflake_sample_data.SELECT l_returnflag , l_linestatus , Sum(l_quantity) AS sum_qty , Sum(l_extendedprice) AS sum_base_price , Sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price , Sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge , Avg(l_quantity) AS avg_qty , Avg(l_extendedprice) AS avg_price , Avg(l_discount) AS avg_disc , Count(*) AS count_orderFROM tpch_sf1.lineitemWHERE l_shipdate <= Dateadd(day, - 90, To_date('1998-12-01'))GROUP BY l_returnflag , l_linestatusORDER BY l_returnflag , l_linestatus;
The Pricing Summary Report provides a summary pricing report for all line items shipped as of a given date. The date is within 60–120 days of the greatest ship date contained in the database. The query lists totals for extended price, discounted extended price, discounted extended price plus tax, average quantity, average extended price, and average discount. These aggregates are grouped by RETURNFLAG and LINESTATUS, and listed in ascending order of RETURNFLAG and LINESTATUS. A count of the number of line items in each group is included.
sfSchema and Value as tpch_sf1.Next, you add the destination as an S3 bucket.
For Targets, choose Amazon S3.
Choose Data target – S3 bucket in the AWS Glue Studio canvas.
S3_Pricing_Summary.Snowflake_Pricing_Summary.s3://<YourBucketName>/pricing_summary_report/ (use the name of your bucket).db_blog_glue_snowflake.tb_pricing_summary.You successfully completed the steps to create an AWS Glue job that reads data from Snowflake and loads the results into an S3 bucket using a secure connectivity pattern. Eventually, if you want to transform the data before loading it into Amazon S3, you can use AWS Glue transformations available in AWS Glue Studio. Using AWS Glue transformations is crucial when creating an AWS Glue job because they enable efficient data cleansing, enrichment, and restructuring, making sure the data is in the desired format and quality for downstream processes. Refer to Editing AWS Glue managed data transform nodes for more information.
Validate the results After the job is complete, you can validate the output of the ETL job run in Athena, a serverless interactive analytics service. To validate the output, complete the following steps:
blog-workgroup.db_blog_glue_snowflake.SELECT l_returnflag , l_linestatus , sum_qty , sum_base_priceFROM db_blog_glue_snowflake.tb_pricing_summary
6. Choose Run.
You have successfully validated your data for the AWS Glue job Pricing Summary Report Job.
Clean up To clean up your resources, complete the following tasks:
Pricing Summary Report Job.glue-snowflake-connection.blog-glue-snowflake-*.blog-glue-snowflake.Conclusion Using the native Snowflake connector in AWS Glue provides an efficient and secure way to integrate data from Snowflake into your data pipelines on AWS. By following the steps outlined in this post, you can establish a private connectivity channel between AWS Glue and your Snowflake using PrivateLink, Amazon VPC, security groups, and Secrets Manager.
This architecture allows you to read data from and write data to Snowflake tables directly from AWS Glue jobs running on Spark. The secure connectivity pattern prevents data transfers over the public internet, enhancing data privacy and security.
Combining AWS data integration services like AWS Glue with data platforms like Snowflake allows you to build scalable, secure data lakes and pipelines to power analytics, BI, data science, and ML use cases.
In summary, the native Snowflake connector and private connectivity model outlined here provide a performant, secure way to include Snowflake data in AWS big data workflows. This unlocks scalable analytics while maintaining data governance, compliance, and access control. For more information on AWS Glue, visit AWS Glue.
About the Authors Caio Sgaraboto Montovani is a Sr. Specialist Solutions Architect, Data Lake and AI/ML within AWS Professional Services, developing scalable solutions according customer needs. His vast experience has helped customers in different industries such as life sciences and healthcare, retail, banking, and aviation build solutions in data analytics, machine learning, and generative AI. He is passionate about rock and roll and cooking, and loves to spend time with his family.
Kartikay Khator is a Solutions Architect within Global Life Sciences at AWS, where he dedicates his efforts to developing innovative and scalable solutions that cater to the evolving needs of customers. His expertise lies in harnessing the capabilities of AWS analytics services. Extending beyond his professional pursuits, he finds joy and fulfillment in the world of running and hiking. Having already completed two marathons, he is currently preparing for his next marathon challenge.
Navnit Shukla, an AWS Specialist Solution Architect specializing in Analytics, is passionate about helping clients uncover valuable insights from their data. Leveraging his expertise, he develops inventive solutions that empower businesses to make informed, data-driven decisions. Notably, Navnit is the accomplished author of the book “Data Wrangling on AWS,” showcasing his expertise in the field.
Kamen Sharlandjiev is a Sr. Big Data and ETL Solutions Architect, Amazon MWAA and AWS Glue ETL expert. He’s on a mission to make life easier for customers who are facing complex data integration and orchestration challenges. His secret weapon? Fully managed AWS services that can get the job done with minimal effort. Follow Kamen on LinkedIn to keep up to date with the latest Amazon MWAA and AWS Glue features and news!
Bosco Albuquerque is a Sr. Partner Solutions Architect at AWS and has over 20 years of experience working with database and analytics products from enterprise database vendors and cloud providers. He has helped technology companies design and implement data analytics solutions and products.