You are currently viewing Use Amazon Athena to question information saved in Google Cloud Platform

Use Amazon Athena to question information saved in Google Cloud Platform

As clients speed up their migrations to the cloud and rework their companies, some discover themselves in conditions the place they need to handle information analytics in a multi-cloud atmosphere, corresponding to buying an organization that runs on a distinct cloud supplier. Prospects who use multi-cloud environments typically face challenges in information entry and compatibility that may create blockades and decelerate productiveness.

When managing multi-cloud environments, clients should search for companies that deal with these gaps by options offering interoperability throughout clouds. With the discharge of the Amazon Athena information supply connector for Google Cloud Storage (GCS), you possibly can run queries inside AWS to question information in Google Cloud Storage, which may be saved in relational, non-relational, object, and customized information sources, whether or not that be Parquet or comma-separated worth (CSV) format. Athena supplies the connectivity and question interface and may simply be plugged into different AWS companies for downstream use instances corresponding to interactive evaluation and visualizations. Some examples embrace AWS information analytics companies corresponding to AWS Glue for information integration, Amazon QuickSight for enterprise intelligence (BI), in addition to third-party software program and companies from AWS Market.

This publish demonstrates the best way to use Athena to run queries on Parquet or CSV recordsdata in a GCS bucket.

Resolution overview

The next diagram illustrates the answer structure.

The Athena Google Cloud Storage connector makes use of each AWS and Google Cloud Platform (GCP), so we will likely be referencing each cloud suppliers within the structure diagram.

We use the next AWS companies on this answer:

  • Amazon Athena – A serverless interactive analytics service. We use Athena to run queries on information saved on Google Cloud Storage.
  • AWS Lambda – A serverless compute service that’s occasion pushed and manages the underlying sources for you. We deploy a Lambda operate information supply connector to attach AWS with Google Cloud Supplier.
  • AWS Secrets and techniques Supervisor – A secrets and techniques administration service that helps defend entry to your purposes and companies. We reference the key in Secrets and techniques Supervisor within the Lambda operate so we are able to run a question on AWS and it could possibly entry the information saved on Google Cloud Supplier.
  • AWS Glue – A serverless information analytics service for information discovery, preparation, and integration. We create an AWS Glue database and desk to level to the proper bucket and recordsdata inside Google Cloud Storage.
  • Amazon Easy Storage Service (Amazon S3) – An object storage service that shops information as objects inside buckets. We create an S3 bucket to retailer information that exceeds the Lambda operate’s response dimension limits.

The Google Cloud Platform portion of the structure incorporates just a few companies as nicely:

  • Google Cloud Storage – A managed service for storing unstructured information. We use Google Cloud Storage to retailer information inside a bucket that will likely be utilized in a question from Athena, and we add a CSV file on to the GCS bucket.
  • Google Cloud Identification and Entry Administration (IAM) – The central supply to manage and handle visibility for cloud sources. We use Google Cloud IAM to create a service account and generate a key that can enable AWS to entry GCP. We create a key with the service account, which is uploaded to Secrets and techniques Supervisor.


For this publish, we create a VPC and safety group that will likely be used at the side of the GCP connector. For full steps, confer with Making a VPC for an information supply connector. Step one is to create the VPC utilizing Amazon Digital Personal Cloud (Amazon VPC), as proven within the following screenshot.

Then we create a safety group for the VPC, as proven within the following screenshot.

For extra details about the stipulations, confer with Amazon Athena Google Cloud Storage connector. Moreover, there are tables that spotlight the precise information varieties that can be utilized corresponding to CSV and Parquet recordsdata. There are additionally required permissions to run the answer.

Google Cloud Platform configuration

To start, it’s essential to have both CSV or Parquet recordsdata saved inside a GCS bucket. To create the bucket, confer with Create buckets. Be certain that to notice the bucket title—it is going to be referenced in a later step. After you create the bucket, add your objects to the bucket. For directions, confer with Add objects from a filesystem.

The CSV information used on this instance got here from Mockaroo, which generated random check information as proven within the following screenshot. On this instance, we use a CSV file, however you can too use Parquet recordsdata.

Moreover, it’s essential to create a service account to generate a key pair inside Google Cloud IAM, which will likely be uploaded to Secrets and techniques Supervisor. For full directions, confer with Create service accounts.

After you create the service account, you possibly can create a key. For directions, confer with Create and delete service account keys.

AWS configuration

Now that you’ve a GCS bucket with a CSV file and a generated JSON key file from Google Cloud Platform, you possibly can proceed with the remainder of the steps on AWS.

  1. On the Secrets and techniques Supervisor console, select Secrets and techniques within the navigation pane.
  2. Select Retailer a brand new secret and specify Different kind of secret.
  3. Present the GCP generated key file content material.

The subsequent step is to deploy the Athena Google Cloud Storage connector. For extra info, confer with Utilizing the Athena console.

  1. On the Athena console, add a brand new information supply.
  2. Choose Google Cloud Storage.

  1. For Information supply title, enter a reputation.
  2. For Lambda operate, select Create Lambda operate to be redirected to the Lambda console.

  1. Within the Utility settings part, enter the knowledge for Utility title, SpillBucket, GCSSecretName, and LambdaFunctionName.

  1. You additionally need to create an S3 bucket to reference the S3 spill bucket parameter so as to retailer information that exceeds the Lambda operate’s response dimension limits. For extra info, confer with Create your first S3 bucket.

After you present the Lambda operate’s utility settings, you’re redirected to the Evaluation and create web page.

  1. Verify that these are the proper fields and select Create information supply.

Now that the information supply connector has been created, you possibly can join Athena to the information supply.

  1. On the Athena console, navigate to the information supply.
  2. Beneath Information supply particulars, select the hyperlink for the Lambda operate.

You’ll be able to reference the Lambda operate to hook up with the information supply. As an non-obligatory step and for validation, the variables that had been put into the Lambda operate may be discovered inside the Lambda operate’s atmosphere variables on the Configuration tab.

  1. As a result of the built-in GCS connector schema inference functionality is restricted, it’s advisable to create an AWS Glue database and desk in your metadata. For directions, confer with Organising databases and tables in AWS Glue.

The next screenshot exhibits our database particulars.

The next screenshot exhibits our desk particulars.

Question the information

Now you possibly can run queries on Athena that can entry the information saved on Google Cloud Storage.

  1. On the Athena console, select the proper information supply, database, and desk inside the question editor.
  2. RunSELECT * FROM [AWS Glue Database name].[AWS Glue Table name]within the question editor.

As proven within the following screenshot, the outcomes will likely be from the bucket on Google Cloud Storage.

The info that’s saved on Google Cloud Platform may be accessed by AWS and used for a lot of use instances, corresponding to performing enterprise intelligence, machine studying, or information science. Doing so can assist unblock builders and information scientists to allow them to effectively present outcomes and save time.

Clear up

Full the next steps to scrub up your sources:

  1. Delete the provisioned bucket in Google Cloud Storage.
  2. Delete the service account underneath IAM & Admin.
  3. Delete the key GCP credentials in Secrets and techniques Supervisor.
  4. Delete the S3 spill bucket.
  5. Delete the Athena connector Lambda operate.
  6. Delete the AWS Glue database and desk.


If you happen to obtain a ROLLBACK_COMPLETE state and “cannot be up to date error” when creating the information supply in Lambda, go to AWS CloudFormation, delete the CloudFormation stack, and check out recreating it.

If the AWS Glue desk doesn’t seem within the Athena question editor, confirm that the information supply and database values are accurately chosen within the Information pane on the Athena question editor console.


On this publish, we noticed how one can decrease the effort and time required to entry information on Google Cloud Platform and use it effectively on AWS. Utilizing the information connector helps organizations turn out to be multi-cloud agnostic and helps speed up enterprise development. Moreover, you possibly can construct out BI purposes with the discoveries, relationships, and insights discovered when analyzing the information, which might additional your group’s information evaluation course of.

Concerning the Writer

Jonathan Wong is a Options Architect at AWS aiding with initiatives inside Strategic Accounts. He’s captivated with fixing buyer challenges and has been exploring rising applied sciences to speed up innovation.

Leave a Reply