Integrate AWS Glue with Astra DB Serverless

AWS Glue is a serverless data integration service you can use to create jobs that run extract, transform, and load (ETL) scripts.

This guide explains how to connect your Astra DB Serverless database to AWS Glue. After you import your non-vector data from Astra DB into AWS Glue, you can push the data to Redshift, SageMaker, and other AWS services.

Prerequisites

You need the following:

Load data

Load non-vector data in Astra DB to import to AWS Glue.

  1. Download the sample CSV file.

  2. In the Astra Portal navigation menu, select your database.

  3. Load the data:

    • For Partition key, select country_name.

    • Make a note of the Target keyspace. You need it for the connection to AWS Glue.

Create an IAM role

  1. In the AWS IAM console navigation pane, select Roles.

  2. Click Create Role.

  3. For Trusted entity type, select AWS service.

  4. For Use case, select Glue.

  5. Click Next, and then add the following permissions to the role:

    • AmazonS3FullAccess

    • AWSGlueServiceRole

    • AWSGlueConsoleFullAccess

    • SecretsManagerReadWrite

    • AWSGlueJobExecutor

  6. Click Next, and then enter a role name, such as AstraGlueRole.

  7. Click Create Role.

Configure the JDBC driver in S3

The Astra JDBC driver supports the connection between AWS Glue and your Astra DB database.

  1. Download the latest astra-jdbc-driver jar file.

  2. In the Amazon S3 console navigation pane, click Create Bucket.

  3. Make sure the AWS Region is the same as your Astra DB database.

  4. Enter a unique bucket name.

  5. In the Object Ownership section, select a permission model.

    DataStax recommends using Access Control Lists (ACLs).

    For information about S3 bucket settings, see Creating a bucket.

  6. Click Create bucket.

  7. On the list of buckets, click your new bucket to open it.

  8. Click Upload, and then upload the driver jar file.

  9. On your bucket’s Objects page, click the driver file, and then copy the S3 URI. You will use this when you create the Glue connector.

    glue integration s3 uri

Create secrets

  1. In the AWS Secrets Manager console, click Store a new secret.

  2. For Secret type, select Other type of secret.

  3. Enter the following key/value pairs:

  4. Click Next.

  5. Enter a name for the secret, such as AstraGlueCreds, and then click Next.

  6. On the Configure Rotation page, click Next.

  7. On the Review page, click Store.

Create an AWS Glue connector

  1. In the AWS Glue Studio console navigation pane, click Data connections.

  2. In the Custom connectors section, click Create custom connector.

  3. For Connector S3 URL, enter your JDBC driver’s S3 URI.

  4. Enter a connector name.

  5. For Connector type, select JDBC.

  6. For Class name, enter com.datastax.astra.jdbc.AstraJdbcDriver.

    The JDBC base URL is formatted as jdbc:astra://ASTRA_DB_NAME/ASTRA_KEYSPACE_NAME?user=token&password=APPLICATION_TOKEN.

    For example, jdbc:astra://astraglue_db/astraglue_ks?user=token&password=AstraCS:…​.

  7. For URL parameter delimiter, enter '&'.

  8. Click Create connector.

  9. On the Data connections page, in the Connectors section, click your JDBC connector.

  10. Click Create connection.

  11. Enter a connection name.

  12. For Connection credential type, select default.

  13. For AWS Secret, select your Astra DB secret.

  14. Click Create connection.

Create an AWS Glue database and table

  1. Download the sample schema.

  2. In the Amazon S3 Console, create a new, empty bucket for AWS Glue. Make sure the bucket is in the same region as your Glue instance.

  3. In the AWS Glue console navigation pane, click Data Catalog/Databases.

  4. Click Add database.

  5. Enter a database name, and then click Create database.

  6. Click Tables, and then click Add table.

  7. Enter a table name.

  8. Select your new database.

  9. Set the Data store to S3, and then select your AWS Glue S3 bucket.

  10. Set the Data format to CSV with comma (,) delimiters.

  11. Click Next, and then click Choose or define schema.

  12. Click Edit schema as JSON.

  13. Click Choose file, and then select the sample schema.txt file.

  14. Click Save, and then click Next.

  15. Review the table attributes, and then click Create.

Create an ETL job

Create an ETL job in AWS Glue that ingests data from Astra DB, transforms it to a defined schema, and then pushes it to your AWS Glue database and table.

  1. In the AWS Glue Studio console navigation pane, click Data connections.

  2. In the Connections section, click your JDBC connection.

  3. Click Create job.

  4. Enter a job name.

  5. On the Visual tab, click the Data source - Connection node for your JDBC connection.

  6. For Table name, enter demographics.

    If you changed the table name when you loaded data in Astra DB, use that name instead.

  7. On the Data preview tab, select your AWS Glue IAM role.

  8. To start the data transfer, click Start data preview session, and then wait for the job to run.

    If data extraction succeeded, the preview shows your data from Astra DB.

  9. On the Output schema tab, select Use data preview schema. This applies the data scheme from Astra DB to your AWS Glue job.

    glue integration output schema

  10. In the Visual tab, click add Add, click the Transform category, and then select Change Schema.

  11. Make sure the Transform - Change Schema node is connected to the Data source - Connection node.

    If they are not connected, click the Change Schema node, and then set the Parent node to the Connection node.

  12. Click the new Transform - Change Schema node, and then inspect the Transform settings:

    • Output schema: The schema received from the Data source - Connection node

    • Data preview: A preview of the data after transformation

  13. In the Visual tab, click add Add, click the Targets category, and then select Glue Data Catalog.

  14. Click the Target - Glue Data Catalog node, and then edit the following settings:

    1. Set the Parent node to Change Schema.

    2. Select your AWS Glue database and table.

      glue integration nodes

  15. Click Save.

Test the job

  1. In the AWS Glue Studio console navigation pane, click ETL jobs, and then select your ETL job.

  2. Click Run.

  3. After the job runs, go to the AWS S3 console, and then click your AWS Glue database bucket.

  4. Click Download to download a CSV file of the data imported to your AWS Glue database from Astra DB.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com