| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
An example of using our Terraform module for implementing a data ETL pipeline from ControlShift to Amazon Redshift.
The output of this plan is a replica of all of the tables that underlie your ControlShift instance in a new Redshift instance which allows for querying via SQL or other analysis.
If you are already using Terraform or Redshift it is probably best to either fork this example or use the module we provide directly in your own plan.
The Terraform plan sets up resources in your AWS environment to process webhooks generated by the ControlShift Bulk Data API.
The integration is based on the aws-lambda-redshift-loader provided by AWS but replaces the manual setup steps from their README with a Terraform plan. In addition the Terraform plan includes resourced that are specific to accepting ControlShift Bulk Data API webhooks.
The resources created include:
If you are starting from scratch, these steps should get you a Redshift instance with data flowing into it.
First, we're going to make sure you have the right permissions set up to use with Terraform. These instructions assume you're using aws-vault.
Once this is done, you should be able to run aws-vault exec bulk-data -- echo "success" without getting an error.
This Terraform config has several input variables that you'll need to define based on your organization and AWS account. Make a copy of terraform.tfvars.example, named terraform.tfvars, and replace the placeholders with your settings.
Here's a guide to what the variables do:
| Name | Description |
|---|---|
| aws_region | The AWS Region to use. Should match the location of your Redshift instance, defaults to us-east-1. |
| controlshift_environment | The environment of your ControlShift instance. Either staging or production. |
| controlshift_hostname | The hostname of your ControlShift instance. Likely to be something like action.myorganization.org. |
| controlshift_organization_slug | The organization's slug in ControlShift platform. Ask support team (support@controlshiftlabs.com) to find this value. |
| failed_manifest_prefix | A file prefix that will be used for manifest logs on failure, defaults to failed. |
| failure_topic_name | An SNS topic name that will be notified about batch processing failures, defaults to ControlshiftLambdaLoaderFailure. |
| failure_topic_name_for_run_glue_job_lambda | An SNS topic name that will be notified about batch processing failures, defaults to ControlshiftLambdaLoaderFailure. |
| glue_scripts_bucket_name | Your S3 bucket name to store Glue scripts in. |
| manifest_bucket_name | Your S3 bucket name to store manifests of ingests processed in. Terraform will create this bucket for you. Must be globally unique. |
| manifest_prefix | A file prefix that will be used for manifest logs on success, defaults to manifests. |
| receiver_timeout | The timeout for the receiving Lambda, in seconds, defaults to 60. |
| redshift_password | Redshift Password to use for database loads. |
| redshift_schema | The Redshift schema to load tables into, defaults to public. |
| redshift_username | Redshift Username to use for database loads. |
| success_topic_name | An SNS topic name that will be notified about batch processing successes, defaults to ControlshiftLambdaLoaderSuccess. |
| success_topic_name_for_run_glue_job_lambda | An SNS topic name that will be notified about batch processing successes, defaults to ControlshiftGlueJobSuccess. |
It's time to use Terraform to create all the AWS resources! This is where the magic happens.
First, tell Terraform to set itself up:
terraform initThen, run a Terraform apply:
aws-vault exec bulk-data -- terraform applyThis will show you a huge diff and ask your permission to proceed. Type "yes" and wait while Terraform creates all the resources.
When it's done, Terraform will output a Webhook URL. Hang on to this, because we're going to need it in a minute.
For the ingest process to work correctly, tables that match the output of the ControlShift Bulk Data API must be set up in Redshift first. We've provided a create_tables.rb script that will use the ControlShift Bulk Data Schema API to generate CREATE TABLE DDL statements that you'll need to run to populate the tables for ingest.
./create_tables.rb > tables.sqlLog in to the AWS web console and navigate to Redshift. Open the Redshift query editor for redshift-cluster, and connect to the agra_replica database using your redshift_username and redshift_password.
Copy the contents of tables.sql into the editor and click the Run button. Once it's finished, you should be able to expand redshift-cluster > agra_replica > public > Tables and see a bunch of tables have been created.
We're almost there! It's time to tell ControlShift to send some bulk data over.
Once this is done, you can use the "Test Ingest" button to send over a full set of tables. This is the same export that should automatically happen nightly when "Do nightly CSV exports" is checked.
The pipeline logs its activity several places that are useful for debugging.
| Back | FazBrowse Home | New Git URL |