Ready to get started?

Learn more about CData Connect Cloud or sign up for free trial access:

Free Trial

Integrate with Live Amazon Athena Data in MuleSoft (via CData Connect Cloud)



Use CData Connect Cloud to connect to Amazon Athena from the MuleSoft Anypoint Platform to integrate live Amazon Athena data into custom reports and dashboards.

The MuleSoft Anypoint Platform enables the building, deployment, and management of APIs and integrations, facilitating seamless connectivity across applications and systems. When combined with CData Connect Cloud, it provides access to Amazon Athena data for visualizations, dashboards, and more. This article explains how to use CData Connect Cloud to create a live connection to Amazon Athena and how to connect and access live Amazon Athena data from the MuleSoft Anypoint Platform.

Prerequisites

Before configuring and using MuleSoft with CData Connect Cloud, you must first connect a data source to your CData Connect Cloud account. For more information, see the Connections section.

Additionally, you need to generate a Personal Access Token (PAT) on the Settings page. Be sure to copy it down, as it serves as your password during authentication.

Configure Amazon Athena Connectivity for MuleSoft

Connectivity to Amazon Athena from MuleSoft is made possible through CData Connect Cloud. To work with Amazon Athena data from MuleSoft, we start by creating and configuring a Amazon Athena connection.

  1. Log into Connect Cloud, click Connections and click Add Connection
  2. Select "Amazon Athena" from the Add Connection panel
  3. Enter the necessary authentication properties to connect to Amazon Athena.

    Authenticating to Amazon Athena

    To authorize Amazon Athena requests, provide the credentials for an administrator account or for an IAM user with custom permissions: Set AccessKey to the access key Id. Set SecretKey to the secret access key.

    Note: Though you can connect as the AWS account administrator, it is recommended to use IAM user credentials to access AWS services.

    Obtaining the Access Key

    To obtain the credentials for an IAM user, follow the steps below:

    1. Sign into the IAM console.
    2. In the navigation pane, select Users.
    3. To create or manage the access keys for a user, select the user and then select the Security Credentials tab.

    To obtain the credentials for your AWS root account, follow the steps below:

    1. Sign into the AWS Management console with the credentials for your root account.
    2. Select your account name or number and select My Security Credentials in the menu that is displayed.
    3. Click Continue to Security Credentials and expand the Access Keys section to manage or create root account access keys.

    Authenticating from an EC2 Instance

    If you are using the CData Data Provider for Amazon Athena 2018 from an EC2 Instance and have an IAM Role assigned to the instance, you can use the IAM Role to authenticate. To do so, set UseEC2Roles to true and leave AccessKey and SecretKey empty. The CData Data Provider for Amazon Athena 2018 will automatically obtain your IAM Role credentials and authenticate with them.

    Authenticating as an AWS Role

    In many situations it may be preferable to use an IAM role for authentication instead of the direct security credentials of an AWS root user. An AWS role may be used instead by specifying the RoleARN. This will cause the CData Data Provider for Amazon Athena 2018 to attempt to retrieve credentials for the specified role. If you are connecting to AWS (instead of already being connected such as on an EC2 instance), you must additionally specify the AccessKey and SecretKey of an IAM user to assume the role for. Roles may not be used when specifying the AccessKey and SecretKey of an AWS root user.

    Authenticating with MFA

    For users and roles that require Multi-factor Authentication, specify the MFASerialNumber and MFAToken connection properties. This will cause the CData Data Provider for Amazon Athena 2018 to submit the MFA credentials in a request to retrieve temporary authentication credentials. Note that the duration of the temporary credentials may be controlled via the TemporaryTokenDuration (default 3600 seconds).

    Connecting to Amazon Athena

    In addition to the AccessKey and SecretKey properties, specify Database, S3StagingDirectory and Region. Set Region to the region where your Amazon Athena data is hosted. Set S3StagingDirectory to a folder in S3 where you would like to store the results of queries.

    If Database is not set in the connection, the data provider connects to the default database set in Amazon Athena.

  4. Click Create & Test
  5. Navigate to the Permissions tab in the Add Amazon Athena Connection page and update the User-based permissions.

With the connection configured, you are ready to connect to Amazon Athena data from MuleSoft.

Connecting to CData Connect Cloud

Follow these steps to establish a connection from Mulesoft to CData Connect Cloud through the JDBC driver:

  1. Download and install the CData Connect Cloud JDBC driver.
    1. Open the Client Tools page of CData Connect Cloud.
    2. Locate MuleSoft and click on Download for Mac/Windows/Linux.
    3. Download and run the setup file.
    4. When the installation is complete, the JAR file can be found in the installation directory (inside the lib folder).
  2. Log into Mulesoft Anypoint Studio or launch the desktop application.
  3. Create a new Mulesoft project. The new project appears in a project folder.
  4. In the Mule Palette located on the right, drag an HTTP Listener to the Message Flow area.
  5. Click on the HTTP Listener to configure it.
  6. Click the + sign on the right of Connector configuration. The HTTP Listener config dialog appears.
  7. Configure the HTTP Listener, providing a Port on which to query your data, and click OK.
  8. Provide a path on which to perform the actions. The HTTP Listener is now configured.
  9. In the Mule Palette on the right, type database in the search bar.
  10. Drag the database operation you want to perform to the Message Flow area. For this example, we choose Select.
  11. Select Generic Connection from the Connection dropdown in the Database Config dialog.
  12. Click the Configure button to configure the JDBC driver. Select Use local file from the drop-down list.
  13. Locate the CData Connect Cloud JAR file from the JDBC driver installation and click OK.
  14. Provide the following information:
    • URL: the URL for the connection, for example: jdbc:connect:Authscheme=Basic;user=username;password=password Note: the password is the PAT created in the Prerequisites section.
    • Driver class name: Enter the Driver class name as: cdata.jdbc.connect.ConnectDriver
  15. Click Test Connection.
  16. If the connection is successful, provide the SQL Query Text in the editor. You can see the table metadata on the right side in the Output tab.
  17. In the Mule Palette, drag Transform Message to the Message Flow area.
  18. Click Transform Message to configure it. Change the Output as follows:
  19. Save your project and run it. In the console, Mulesoft starts initializing the dependencies.
  20. Once you see the message, "Message source 'listener' on flow your_project_name successfully started", you can start querying your data at the endpoint you provided.
  21. Query to check out the data using the Postman application (as shown below).

SQL Access to Amazon Athena Data from Cloud Applications

Now you have a direct connection to live Amazon Athena data from MuleSoft Anypoint Platform. You can create more connections to ensure seamless data flow, automate business processes, and manage APIs - all without replicating Amazon Athena data.

To get real-time data access to 100+ SaaS, Big Data, and NoSQL sources (including Amazon Athena) directly from your cloud applications, explore the CData Connect Cloud.