Deploy on AWS with Terraform
Introduction
The following Steps will deploy the solution accelerator to AWS using Terraform. There is no need to manually install Terraform. It is executed via Docker using the terraform.sh
script.
Steps to Deploy the Application
Step 0: Prerequisites
- Open a terminal.
- Install Docker and Docker Compose.
- Clone the project and navigate to its directory.
git clone https://github.com/snowplow-industry-solutions/kafka-live-viewer-profiles.git
- Create a
.env
file based on.env.example
and configure AWS variables.
ACCEPT_LICENSE="true"
AWS_REGION=eu-west-2
AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxx
Step 1: Initialize the Project
$ ./terraform/terraform.sh init
Step 2: Create the Infrastructure
$ ./terraform/terraform.sh apply
Step 3: Access the EC2 Instance that Runs the Apps in AWS
$ ./terraform/apps/ssh.sh
Inside the EC2 instance, you can control the Docker images in a similar way to how you do locally:
$ cd snowplow-demo
$ ./stats.sh # <- show the statistics for the Docker containers
$ ./down.sh # <- stop the Docker containers
$ ./up.sh # <- start the Docker containers
Step 4: Open Access to the Applications
Review the LocalStack guide for the default configuration for each component. Open public access to the two frontend applications and the Snowplow Collector using a HTTP load balancer so that anyone can watch the video, submit events to the pipeline, and see information on concurrent users.
The applications listen for HTTP traffic on the following ports
- Web tracker front end - 3000
- Live viewer front end - 8280
- Snowplow collector - 9090
Next Steps
- You can implement Snowplow media tracking on any HTML5 or YouTube media of your choice
- Look into the output from Kafka and extend the Live Viewer to include information on the media being watched and the user.
- Replace Amazon DynamoDB with an alternative to be cloud agnostic, e.g. Google Bigtable or MongoDB.
Other Commands
Check Versions
$ ./terraform/terraform.sh --version
Example response
Terraform v1.10.0
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v5.79.0
+ provider registry.terraform.io/hashicorp/local v2.5.2
+ provider registry.terraform.io/hashicorp/tls v4.0.6
Check the Terraform Plan
$ ./terraform/terraform.sh plan
Generate a PNG Image for the Terraform Modules in This Project
$ ./terraform/terraform.sh png
Current PNG image of the available modules:
Destroy the Infrastructure
$ ./terraform/terraform.sh destroy