Data and Analytics
Amazon Kinesis Data Streams On-demand vs. Provisioned Billing Mode Cost Comparison
Is on-demand pricing really ‘serverless’ pricing?
AWS recently released a new set of APIs for Amazon QuickSight. These APIs have the potential to completely transform the way we leverage QuickSight and how we build for it. These APIs are; DescribeAnalysisDefinition
, DescribeTemplateDefinition
, DescribeDashboardDefinition
. In addition to these new APIs, the create
, update
, and list
versions of the APIs have also been updated to support the full definition.
These new and updated APIs allow us to export, manipulate, and upload entire QuickSight Dashboards and Analysis as code. The managed resources in QuickSight are collectively referred to as Assets, therefore this update ushers in the beginning of an exciting new approach: Assets as Code for QuickSight. Most traditional visualization implementations collectively lack the ability to programmatically manage the content in their environments in ways that are consistent with Software Development Lifecycle (SDLC) implementations. This update provides an opportunity for these SDLC features to be built for QuickSight. You can think of this as analogous to Infrastructure as Code (IaC) which is the best practice for deploying cloud infrastructure. Why not manage your QuickSight assets like your cloud infrastructure? Some of the benefits of this approach include:
Automate creation of specialized user dashboards on a per-user basis as part of onboarding or other process.
Enforce consistent design concepts by analyzing exported assets for consistency.
Build reusable components to be programmatically added to assets.
Automatically add branding to all dashboards as they promote through environments.
Reliable, automated process for testing changes to reports and dashboards and then releasing those to production.
Git repository gives you a history of changes and a built-in backup of all artifacts.
We can begin to build operational processes mimicking lessons learned from other disciplines such as DevOps. With the ability to export the entirety of an asset consistent with the documentation provided by the AWS QuickSight team, we can start to build solutions less prone to errors introduced through untracked changes in the QuickSight tool. In this article, we will go over a very simple use of the new API features. We will export the totality of a selected Analysis, then show how this export can be persisted in any way consistent with operational best practices and used as a backup for our QuickSight environment.
In order to do this process, we simply follow the following steps with the API:
List all analysis and filter the results.
Execute the DescribeAnalysisDefinition
API with the filtered analysis.
Save the resulting payload,
To see this with python code we will first want to get the AnalysisId which will be needed, so to start, we run list_analyses
:
import boto3
# Update these for your environment
account = '1234567890'
desired_dashboard = 'MY_DASHBOARD'
# Quicksight client resource
qs = boto3.client('quicksight')
# List all analysis
analyses_resp = qs.list_analyses(
AwsAccountId=account,
)['AnalysisSummaryList']
# filter list for dashboard name
analysis = list(
filter(
lambda value: value['Name'] == desired_dashboard,
analyses_resp
)
)[0]
The output here will look like this, with datetime objects instead of date strings:
Since we now have the AnalysisId, we can run the describe_analysis_definition
API call:
analyses_describe_resp = qs.describe_analysis_definition(
AwsAccountId=account,
AnalysisId=analysis['AnalysisId']
)
The general output will look like this:
However, the interesting bits are in the Definition section. This section is far too large to show in this post, however, the API documentation shows all the available features of this API. Once we have this information in git, we can leverage our traditional DevOps tools to deploy assets to a development environment or any other new environment. Simply run the create or update APIs to deploy the asset to any and all environments you desire. You will still need to validate dependencies of any assets migrated up to ensure that all assets have everything they need. The effort to accomplish this validation is not trivial and would require some extra effort depending on the unique data environment.
As promised, the final step is to persist this to a file:
# additional import needed for this
import json
# If your asset definition includes datetime values, that will need to be resolved independently.
with open(f'{desired_dashboard}.json', 'w') as asset_file:
asset_file.write(
json.dumps(analyses_describe_resp['Definition'])
)
The final solution as one piece without comments looks like this:
import boto3
import json
account = '1234567890'
desired_dashboard = 'MY_DASHBOARD'
qs = boto3.client('quicksight')
analyses_resp = qs.list_analyses(
AwsAccountId=account,
)['AnalysisSummaryList']
analysis = list(
filter(
lambda value: value['Name'] == desired_dashboard,
analyses_resp
)
)[0]
analyses_describe_resp = qs.describe_analysis_definition(
AwsAccountId=account,
AnalysisId=analysis['AnalysisId']
)
with open(f'{desired_dashboard}.json', 'w') as asset_file:
asset_file.write(
json.dumps(analyses_describe_resp['Definition'])
)
This solution discussed is almost trivial given what QuickSight has now provided us, but don’t let it stop there. The ability to programmatically alter Analysis and Dashboards and dynamically create and edit content can revolutionize how dashboards are built, maintained, and developed. We’re excited to start using this API and building solutions for QuickSight asset management. If you are interested in these solutions, please contact us.
Is on-demand pricing really ‘serverless’ pricing?