Salesforce Connect Demo: Virtualizing Athena

Kam Patel
AppExchange and the Salesforce Ecosystem
5 min readMay 16, 2022

If you’re looking for more information on how to virtualize AWS Athena within Salesforce, you’re in the right place. Virtualizing AWS Athena enables the users of Salesforce applications to seamlessly query AWS data stores using the Athena query engine — all without leaving the Salesforce native environment. Note: Salesforce Connect for Athena is still in pilot.

Disclaimer: Salesforce labapp and AWS steps in this blog post are provided as-is, use it as a general guidance. For AWS you are responsible for everything including all the expenses incurred and security aspects.

AppExchange partners looking for help with this topic can request an ISV Platform Expert consultation and have a deep, technically-focused conversation with me.

The Scenario

In this blog post, we’ll walk through a demo of using a fictitious e-bike company as the star. The B2B company sells high-tech bikes directly to third-party vendors. The challenge: Sales Executives at the e-bike company need the ability to get a daily operational matrix on the orders stored in AWS S3 and also right in their Slack channel. Let’s do it!

The architecture and data flow for this demo.

Pre-Requisites to Know

1. Use an existing AWS instance, or sign up for one here.

2. Sign up for a Salesforce Summer ’22 preview org here.

3. Request the Salesforce Athena pilot for your org (ask your account representative or partner account manager to nominate you for the pilot).

AWS Setup

Now, let’s get AWS in a good place. This setup should take around 15 minutes.

Step 1: Create a S3 bucket

In the AWS console, go to S3.

  • Create a S3 bucket ebikes-data-***& “ebikes-athena-***”

Note: S3 bucket names need to be unique across the regions so replace *** with some unique value.

  • Inside the bucket, create a folder called “data”
  • Download this sample orders file and upload it to the newly created “data” folder.

Step 2: Configure Athena

  • In the console, go to Athena.
  • Copy the create table query from the gist.
  • Select “primary” workgroup, click “View Settings”, click “Manage”, assign the ebikes-athena-*** bucket
  • In the query, update the S3 bucket name ebikes-data-***with your bucket name (excluding the folder that has the orders.csv file). Run the query to create the table.
  • Select the table and run preview, it should return the data.
  • Go to Athena Workgroups (left side menu), select “primary” workgroup and set the “Location of query results” as shown (you bucket name will be “s3://ebikes-athena-***”)

Salesforce Org Setup

Let’s configure your Salesforce org and test steps one through three. This should take around 10 minutes.

  • Step 1: Install this unmanaged package.
  • Step 2: Under setup, edit the NamedCredentials “ebikesathenanc”
  • Step 3: Update “AWS Access Key ID” and “AWS Secret Access Key” with your AWS credentials.

Create & Test Report

Create a report as shown using Athena External object. Select “OrdersAthenaTable” as shown

Add appropriate grouping as you like, save & run the report.

Lightning Reports to Slack (optional)

Imagine the ability to send daily reports to Sales Executives via Slack? Yes, you can — and without writing a single line of code! Now users have the option of bypassing checking reports or sending by email, and can truly leverage their digital HQs, thanks to the brand-new CRM Analytics app for Slack (beta).

Setup

Under Setup, Enable slack in Salesforce org.

Under Setup, Enable “CRM Analytics for Slack”

Follow this article to create permission set with required permissions and assign it to the admin user (you in this case).

Sign up for a free Slack workspace (if you don’t have an existing Slack workspace).

Go here and click “ADD THE CRM ANALYTICS FOR SLACK APP”. Follow the prompt and connect the Salesforce org.

Check out reports from Slack

Now you should see Lightning Reports when you run the Slack command “/analytics-recents”. Click on the three dots against the report and get a snapshot! Yes you can subscribe to the reports too so you don’t have to get it manually!

Call External Objects from LWC (optional)

Yes you can call external sobjects from LWC, super easy!

Step 1. Create an Apex method

@AuraEnabled(cacheable=true)

public static List<OrdersTable__x> getAthenaOrderList() {

return [SELECT ExternalId, orderid__c, amount__c, model__c, quantity__c,

status__c FROM OrdersTable__x limit 10];}

Step 2. Wire it up in your LWC

import fetchOrders from ‘@salesforce/apex/EbikesController.getAthenaOrderList’;

@wire(fetchOrders) wiredOrders({ error, data }) {}

And there you have it!

Clean-up

Always cleanup the AWS resources once done so you don’t incur additional cost.

Summary

Now at the e-bike company, Sales Executives are getting a daily operational matrix on the orders stored in AWS S3. We connected the Salesforce org to the Athena table, created a Lightning report, and even pushed the reports to the Slack — all without writing any code!

--

--

Kam Patel
AppExchange and the Salesforce Ecosystem

Hello! I work at Salesforce as a technical expert for ISV partners. I love going for long walks, socializing, public speaking and teaching kids in rural areas.