SageMaker Autopilot Tableau Connector on the AWS Cloud

Quick Start Reference Deployment

QS

DRAFT DOCUMENT / UNOFFICIAL GUIDANCE

This portion of the deployment guide is located at docs/partner_editable/__settings.adoc_

February 2021
Holt Calder, InterWorks Inc.
Shivansh Singh and Tony Bulding, AWS Quick Start team

Visit our GitHub repository for source files and to post feedback, report bugs, or submit feature ideas for this Quick Start.

This Quick Start was created by InterWorks Inc. in collaboration with Amazon Web Services (AWS). Quick Starts are automated reference deployments that use AWS CloudFormation templates to deploy key technologies on AWS, following AWS best practices.

Overview

This portion of the deployment guide is located at docs/partner_editable/overview_target_and_usage.adoc

This Quick Start deploys a solution that enables Tableau users to blend predictions from Amazon SageMaker hosted models into Tableau-powered visualizations. This deployment works with any Tableau product supported by the Tableau Analytics Extension, which includes Tableau Desktop and Tableau Server.

The deployment is designed to work with models trained using Amazon SageMaker Autopilot without the need for customizations. However, it supports integration of any machine learning (ML) models hosted by SageMaker hosting services can be integrated with Tableau. For models not trained with Autopilot, you are responsible for implementing transformations required to match the Tableau Analytics Extension and your custom-model input and output formats.

This Quick Start reference deployment guide provides instructions for using AWS CloudFormation templates to deploy a SageMaker Tableau analytic extension.

Amazon may share user-deployment information with the AWS Partner that collaborated with AWS on the Quick Start.

SageMaker Autopilot Tableau Connector on AWS

This portion of the deployment guide is located at docs/partner_editable/product_description.adoc

This Quick Start is for users who want to leverage Amazon SageMaker Autopilot machine learning (ML) models directly within their Tableau dashboards. Using AWS CloudFormation templates, it deploys a SageMaker Tableau analytic extension based on the Tableau Analytics Extension API. This allows you to include the analytics and visualization capabilities of Tableau Server in Autopilot.

The serverless application this Quick Start deploys uses AWS best practices for security and high availability, and includes the following:

  • A REST API to which Tableau can connect.

  • AWS Lambda functions to facilitate connectivity between Autopilot and Tableau.

  • Amazon Cognito for simple and secure user sign-in and authentication.

AWS costs

You are responsible for the cost of the AWS services and any paid third-party licenses used while running this Quick Start. There is no additional cost for using the Quick Start.

The AWS CloudFormation templates for Quick Starts include configuration parameters that you can customize. Some of the settings, such as the instance type, affect the cost of deployment. For cost estimates, see the pricing pages for each AWS service you use. Prices are subject to change.

After you deploy the Quick Start, create AWS Cost and Usage Reports to deliver billing metrics to an Amazon Simple Storage Service (Amazon S3) bucket in your account. These reports provide cost estimates based on usage throughout each month and aggregate the data at the end of the month. For more information, see What are AWS Cost and Usage Reports?

Software licenses

This portion of the deployment guide is located at docs/partner_editable/licenses.adoc

There is no license required to launch this Quick Start. However, to use the connector from your Tableau environment, a license is required for Tableau Server or Tableau Desktop.

Architecture

This portion of the deployment guide is located at docs/partner_editable/architecture.adoc

Deploying this Quick Start into a new virtual private cloud (VPC) with default parameters builds the following SageMaker Autopilot Tableau Connector environment in the AWS Cloud.

Architecture
Figure 1. Quick Start architecture for Amazon SageMaker Autopilot Tableau connector on AWS

As shown in Figure 1, this Quick Start sets up the following:

  • A VPC configured according to AWS best practices to provide you with your own virtual network on AWS.

  • Amazon API Gateway to maintain and secure a REST API containing two endpoints (info and evaluate). The API facilitates connection between Tableau and SageMaker.

  • In the Authentication group:

    • An API Gateway AWS Lambda authorizer to control access to REST API resources. When Tableau calls the REST API, API Gateway invokes the AWS Lambda authorizer to validate the caller.

    • Amazon Cognito providing a managed portal for sign-up and sign-in and a user pool to authenticate users.

  • Two AWS Lambda functions, one for each API Gateway endpoint. When Tableau sends a request to an endpoint (for example, to retrieve a SageMaker inference) API Gateway calls the associated AWS Lambda function.

Planning the deployment

Specialized knowledge

This deployment requires a moderate level of familiarity with AWS services. If you’re new to AWS, see Getting Started Resource Center and AWS Training and Certification. These sites provide materials for learning how to design, deploy, and operate your infrastructure and applications on the AWS Cloud.

This portion of the deployment guide is located at docs/partner_editable/specialized_knowledge.adoc

This Quick Start assumes familiarity with the AWS services listed in the References section, later in this guide.

AWS account

If you don’t already have an AWS account, create one at https://aws.amazon.com by following the on-screen instructions. Part of the sign-up process involves receiving a phone call and entering a PIN using the phone keypad.

Your AWS account is automatically signed up for all AWS services. You are charged only for the services you use.

Technical requirements

Before you launch the Quick Start, review the following information and ensure that your account is properly configured. Otherwise, deployment might fail.

Resource quotas

If necessary, request service quota increases for the following resources. You might request quota increases to avoid exceeding the default limits for any resources that are shared across multiple deployments. The Service Quotas console displays your usage and quotas for some aspects of some services. For more information, see What is Service Quotas? and AWS service quotas.

This portion of the deployment guide is located at docs/partner_editable/service_limits.adoc

Resource

This deployment uses

AWS Identity and Access Management (IAM) roles

3

AWS Lambda functions

3

AWS Lambda permissions

3

REST APIs

1

API Gateway stages

2

Amazon Cognito user pool domains

1

Amazon Cognito user pools

1

Amazon Cognito user pool token clients

1

Amazon Route53 record sets

1

API Gateway domain names

1

VPC endpoints

0 or 1

Security groups

0 or 1

Supported Regions

This portion of the deployment guide is located at docs/partner_editable/regions.adoc

This Quick Start supports the following Regions:

  • us-east-1 (N. Virginia)

  • us-east-2 (Ohio)

  • us-west-1 (N. California)

  • us-west-2 (Oregon)

  • eu-north-1 (Stockholm)

  • eu-central-1 (Frankfurt)

  • eu-west-1 (Ireland)

  • eu-west-2 (London)

  • eu-west-3 (Paris)

Certain Regions are available on an opt-in basis. For more information, see Managing AWS Regions.

IAM permissions

Before launching the Quick Start, you must sign in to the AWS Management Console with IAM permissions for the resources that the templates deploy. The AdministratorAccess managed policy within IAM provides sufficient permissions, although your organization may choose to use a custom policy with more restrictions. For more information, see AWS managed policies for job functions.

This portion of the deployment guide is located at docs/partner_editable/pre-reqs.adoc

Prerequisites

Before deploying the SageMaker Autopilot Tableau Connector on AWS, you must have the following:

  • An AWS account.

  • A domain managed by Amazon Route 53.

  • An SSL certificate managed by AWS Certificate Manager in the us-east-1 AWS Region.

Deployment options

This portion of the deployment guide is located at docs/partner_editable/deployment_options.adoc

This Quick Start provides three deployment options:

  • Deploy SageMaker Autopilot Tableau into a new VPC (end-to-end deployment). This option builds a new AWS environment consisting of a VPC, API, AWS Lambda functions, identity provider, and other networking components.

  • Deploy SageMaker Autopilot Tableau into an existing VPC. This option provisions the deployment resources in your existing AWS VPC.

  • Deploy SageMaker Autopilot Tableau into the AWS Cloud with no VPC. This option deploys the Quick Start resources into the AWS Cloud, but not into a VPC. To deploy this option, deploy the Deploy SageMaker Autopilot Tableau into an existing VPC template and set the Launch into VPC parameter to No.

The Quick Start provides separate templates for these options. It also lets you configure Classless Inter-Domain Routing (CIDR) blocks, instance types, and other settings, as discussed later in this guide.

Deployment steps

This portion of the deployment guide is located at docs/partner_editable/deploy_steps.adoc

Step 1. Prepare an AWS Account

  1. If you don’t already have an AWS account, create one at http://aws.amazon.com by following the on-screen instructions.

  2. Use the Region selector in the navigation bar to choose the AWS Region where you want to deploy the Quick Start on AWS. Deploy the Quick Start to the same Region where your SageMaker Autopilot models are deployed. If you have Autopilot models deployed to multiple Regions, the recommended architecture is to deploy an instance of the connector to each Region.

  3. Create an SSL Certificate in the us-east-1 Region. To do this, refer to Request a Public Certificate Using the Console.

Step 2. Launch the Quick Start

  1. Sign in to your AWS account, and choose one of the following options to launch the AWS CloudFormation template. For help with choosing an option, see deployment options earlier in this guide.

To deploy without a VPC, choose Deploy SageMaker Autopilot Tableau into an existing VPC on AWS and set the Launch to VPC parameter to No.

Deploy SageMaker Autopilot Tableau into a new VPC on AWS

View template

Deploy SageMaker Autopilot Tableau into an existing VPC on AWS

View template

You are responsible for the cost of the AWS services used while running this Quick Start reference deployment. There is no additional cost for using this Quick Start. Prices are subject to change. See the pricing pages for each AWS service you use in this Quick Start for full details.
  1. Check the Region that’s displayed in the upper-right corner of the navigation bar, and change it if necessary. This Region is where the Quick Start infrastructure is built. The template for this Quick Start is launched in the US-West (Oregon) Region by default. You can also download the templates to use as a starting point for your own implementation.

  2. On the Select Template page, keep the default setting for the template URL, and then choose Next.

  3. On the Specify Details page, change the stack name if needed. Review the parameters for the template. Provide values for the parameters that require input. For all other parameters, review the default settings and customize them as necessary. For details on each parameter, see the Parameter reference section of this guide. After reviewing and customizing the parameters, choose Next.

  1. On the Configure stack options page, you can specify tags (key-value pairs) for resources in your stack and set advanced options. When you’re finished, choose Next.

  2. On the Review page, review and confirm the template settings. Under Capabilities, select the two check boxes to acknowledge that the template creates IAM resources and might require the ability to automatically expand macros.

  3. Choose Create stack to deploy the stack.

  4. Monitor the status of the stack. When the status is CREATE_COMPLETE, the SageMaker Autopilot Tableau deployment is ready.

  5. Use the values displayed in the Outputs tab for the stack, as shown in Figure 2, to view the created resources.

cfn_outputs
Figure 2. SageMaker Autopilot Tableau outputs after successful deployment

This portion of the deployment guide is located at docs/partner_editable/additional_info.adoc

As shown in Figure 2, the AWS CloudFormation template creates the following resources on the Outputs tab:

  • SageMakerTableauApi: The URL for users to connect to the deployment from Tableau.

  • UserPoolDomain: The Amazon Cognito URL to sign up and sign in users of the deployment.

On the Resources tab, you find the SolutionSG security group. This security group is public by default. After testing the deployment, edit the inbound and outbound rules of the SolutionSG security group as necessary to ensure they conform to your VPC security policies. For more information, refer to Work with security groups.

Step 3. Test the deployment

To test the deployment, navigate to the UserPoolDomain URL displayed in the Outputs tab, and sign up as a user. Then, test signing in using the new credentials.

Optionally, you can test from Tableau (version 2020.1 or later) by doing the following:

  1. In Tableau Desktop, choose Help, Settings & Performance, Manage Analytics Extension Connection.

  2. For Select an Analytics Extension, choose TabPy/External API.

  3. Choose a server from the dropdown list.

  4. For Port, enter 443.

  5. Select Sign in with a username and password, then enter your credentials in the fields provided.

  6. Select Require SSL.

  7. Choose Test Connection.

  8. Click OK. If successful, the message Successfully connected to the analytics extension displays. If unsuccessful, an error message displays.

TableauConnection
Figure 3. Analytics Extension Connection dialog box

Additional Information

Best practices for using SageMaker Autopilot Tableau Connector on AWS

While using the SageMaker Autopilot Tableau Connector deployment, it is important to follow Tableau Desktop and SageMaker best practices. You can use any Amazon SageMaker hosted ML model in Tableau table calculations. However, you should pass data from Tableau table calculations to the analytics extension at the granularity level expected by the model (for example, with no aggregation or translation).

The SageMaker Autopilot Tableau Connector deployment can be called with Tableau SCRIPT_ functions SCRIPT_REAL, SCRIPT_STR, SCRIPT_INT, and SCRIPT_BOOL. With these table-calculation functions, you can pass a script along with a block of data to an external analytics engine. The syntax for these calculations is as follows:

Script_Function (‘[SageMaker Hosted Endpoint]’, <fields in dataset to pass to model>)

TableauCalc
Figure 4. Calculation syntax for mapping a data source in Tableau to the input schema of an SageMaker hosted model
  • Script functions. The function you use in your calculated field must match the return data type of your SageMaker model.

  • SageMaker hosted endpoint. The SageMaker model must have a hosted endpoint.

  • Fields to pass to model. You must pass each field in the dataset from Tableau, in the order that the SageMaker model is expecting.

Customization

We recommend that you use Autopilot trained ML models with this deployment. This Quick Start deploys an AWS Lambda function to translate the Tableau analytics extension API call to a format compatible with SageMaker endpoints trained with Autopilot. To use models that are not trained by Autopilot, you may need to customize the deployment.

Tableau sends data from the analytics extension in the following format:

Tableau analytics extension data format
{'_arg1': [37, 40, 56, 45, 46, 55, 52, 45], '_arg2': ['services', 'admin.', 'services', 'services', 'blue-collar', 'retired', 'technician', 'blue-collar'], '_arg3': ['married', 'married', 'married', 'married', 'married', 'single', 'married', 'married'], '_arg4': ['high.school', 'basic.6y', 'high.school', 'basic.9y', 'basic.6y', 'high.school', 'basic.9y', 'basic.9y'], '_arg5': ['no', 'no', 'no', 'unknown', 'unknown', 'no', 'no', 'no'], '_arg6': ['yes', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'yes'], '_arg7': ['no', 'no', 'yes', 'no', 'yes', 'no', 'no', 'no'], '_arg8': ['telephone', 'telephone', 'telephone', 'telephone', 'telephone', 'telephone', 'telephone', 'telephone'], '_arg9': ['may', 'may', 'may', 'may', 'may', 'may', 'may', 'may'], '_arg10': ['mon', 'mon', 'mon', 'mon', 'mon', 'mon', 'mon', 'mon'], '_arg11': [226, 151, 307, 198, 440, 342, 1666, 225], '_arg12': [1, 1, 1, 1, 1, 1, 1, 2], '_arg13': [999, 999, 999, 999, 999, 999, 999, 999], '_arg14': [0, 0, 0, 0, 0, 0, 0, 0], '_arg15': ['nonexistent', 'nonexistent', 'nonexistent', 'nonexistent', 'nonexistent', 'nonexistent', 'nonexistent', 'nonexistent'], '_arg16': [1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1], '_arg17': [93.994, 93.994, 93.994, 93.994, 93.994, 93.994, 93.994, 93.994], '_arg18': [-36.4, -36.4, -36.4, -36.4, -36.4, -36.4, -36.4, -36.4], '_arg19': [4.857, 4.857, 4.857, 4.857, 4.857, 4.857, 4.857, 4.857], '_arg20': [5191, 5191, 5191, 5191, 5191, 5191, 5191, 5191]}

The evaluate endpoint AWS Lambda function can be found on the Resources tab of the AWS CloudFormation console after stack deployment is complete. It is authored in Python 3.7, and contains the function create_sagemaker_body. This function facilitates the transformation of Tableau JSON into the following comma-separated text output, sent to the SageMaker endpoint:

Formatted data for SageMaker Autopilot trained model
37,services,married,high.school,no,yes,no,telephone,may,mon,226,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
40,admin.,married,basic.6y,no,no,no,telephone,may,mon,151,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
56,services,married,high.school,no,no,yes,telephone,may,mon,307,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
45,services,married,basic.9y,unknown,no,no,telephone,may,mon,198,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
46,blue-collar,married,basic.6y,unknown,yes,yes,telephone,may,mon,440,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
55,retired,single,high.school,no,yes,no,telephone,may,mon,342,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
52,technician,married,basic.9y,no,yes,no,telephone,may,mon,1666,1,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191
45,blue-collar,married,basic.9y,no,yes,no,telephone,may,mon,225,2,999,0,nonexistent,1.1,93.994,-36.4,4.857,5191

Data sent by the AWS Lambda function to the SageMaker endpoint is transformed by preprocessing logic into the format required by the ML model. This logic accommodates additional data transformations and facilitate integration of SageMaker Autopilot Tableau customizations.

We do not recommend modifying AWS Lambda function code if your ML model needs additional transformations. The best practice is to package input preprocessing logic alongside the ML model as an SageMaker inference pipeline. For more information, refer to Preprocess input data before making predictions using Amazon SageMaker inference pipelines and Scikit-learn.

References

Quick Start reference deployments

GitHub repository

You can visit our GitHub repository to download the templates and scripts for this Quick Start, to post your comments, and to share your customizations with others.

This portion of the deployment guide is located at docs/partner_editable/faq_troubleshooting.adoc

FAQ

Q. I encountered a CREATE_FAILED error when I launched the Quick Start.

A. If AWS CloudFormation fails to create the stack, relaunch the template with Rollback on failure set to Disabled. This setting is under Advanced in the AWS CloudFormation console on the Configure stack options page. With this setting, the stack’s state is retained, and you can troubleshoot the issue.

When you set Rollback on failure to Disabled, you continue to incur AWS charges for this stack. Ensure that you delete stack after troubleshooting.

For more information, see Troubleshooting AWS CloudFormation.

Q. I encountered a size-limitation error when I deployed the AWS CloudFormation templates.

A. Launch the Quick Start templates from the links in this guide or from another S3 bucket. If you deploy the templates from a local copy on your computer or from a location other than an S3 bucket, you might encounter template-size limitations. For more information, see AWS CloudFormation quotas.

Parameter reference

Unless you are customizing the Quick Start templates for your own deployment projects, we recommend that you keep the default settings for the parameters labeled Quick Start S3 bucket name, Quick Start S3 bucket Region, and Quick Start S3 key prefix. Changing these parameter settings automatically updates code references to point to a new Quick Start location. For more information, see the AWS Quick Start Contributor’s Guide.

Launch into a new VPC

Table 1. Network configuration
Parameter label (name) Default value Description

Availability Zones (AvailabilityZones)

Requires input

List of Availability Zones to use for the subnets in the VPC. Only two Availability Zones are used for this deployment, and the logical order is preserved.

VPC CIDR (VPCCIDR)

10.0.0.0/16

CIDR block for the VPC.

Private subnet 1 CIDR (PrivateSubnet1CIDR)

10.0.0.0/19

CIDR block for private subnet 1, located in Availability Zone 1.

Private subnet 2 CIDR (PrivateSubnet2CIDR)

10.0.32.0/19

CIDR block for private subnet 2, located in Availability Zone 2.

Public subnet 1 CIDR (PublicSubnet1CIDR)

10.0.128.0/20

CIDR Block for the public DMZ subnet 1, located in Availability Zone 1.

Public subnet 2 CIDR (PublicSubnet2CIDR)

10.0.144.0/20

CIDR Block for the public DMZ subnet 2, located in Availability Zone 2.

VPC tenancy (VPCTenancy)

default

Tenancy of instances launched into the VPC.

Table 2. AWS Quick Start configuration
Parameter label (name) Default value Description

Quick Start S3 bucket name (QSS3BucketName)

aws-quickstart

S3 bucket name for the Quick Start assets. Quick Start bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).

Quick Start S3 key prefix (QSS3KeyPrefix)

quickstart-linux-bastion/

S3 key prefix for the Quick Start assets. Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), dots (.) and forward slash (/) and it should end with a forward slash (/).

Quick Start S3 bucket Region (QSS3BucketRegion)

us-east-1

AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. When using your own bucket, you must specify this value.

Table 3. Domain configuration
Parameter label (name) Default value Description

Domain Name (DomainName)

Requires input

Route 53 hosted domain, with prefix. For example, tableauapi.domain.com.

Hosted Zone ID (HostedZoneId)

Requires input

Route 53 hosted zone ID of the domain.

Certificate ARN (CertificateARN)

Requires input

Amazon Resource Number (ARN) of the domain certificate.

Launch into existing VPC

Table 4. Network configuration
Parameter label (name) Default value Description

Launch into VPC (LaunchToVpc)

Requires input

Choose Yes to deploy into a VPC. Choose No to deploy into the AWS Cloud without a VPC.

VPC ID (VpcId)

Requires input

ID of the VPC to deploy into.

Subnet IDs (SubnetIds)

Requires input

ID of the subnet to deploy into.

Table 5. Domain configuration
Parameter label (name) Default value Description

Domain name (DomainName)

Requires input

Route 53 hosted domain, with prefix. For example, tableauapi.domain.com.

Hosted zone ID (HostedZoneId)

Requires input

Domain Route 53 hosted zone ID.

Certificate ARN (CertificateARN)

Requires input

ARN of domain certificate.

Table 6. AWS Quick Start configuration
Parameter label (name) Default value Description

Quick Start S3 bucket name (QSS3BucketName)

aws-quickstart-interworks-tableau-sagemaker-autopilot

S3 bucket name for the Quick Start assets. This string can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).

Quick Start S3 bucket Region (QSS3BucketRegion)

us-west-2

The AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. When using your own bucket, you must specify this value.

Quick Start S3 key prefix (QSS3KeyPrefix)

quickstart-linux-bastion/

S3 key prefix for the Quick Start assets. Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), dots (.) and forward slash (/) and it should end with a forward slash (/).

Send us feedback

To post feedback, submit feature ideas, or report bugs, use the Issues section of the GitHub repository for this Quick Start. To submit code, see the Quick Start Contributor’s Guide.

Quick Start reference deployments

GitHub repository

Visit our GitHub repository to download the templates and scripts for this Quick Start, to post your comments, and to share your customizations with others.


Notices

This document is provided for informational purposes only. It represents AWS’s current product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS’s products or services, each of which is provided “as is” without warranty of any kind, whether expressed or implied. This document does not create any warranties, representations, contractual commitments, conditions, or assurances from AWS, its affiliates, suppliers, or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.

The software included with this paper is licensed under the Apache License, version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the accompanying "license" file. This code is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for specific language governing permissions and limitations.