Terraform Sample for Twitch Extensions

This section walks you through setting up a cloud infrastructure using a sample Terraform configuration designed for the Twitch Extension Sample. This sample uses Amazon Web Services (AWS) as the cloud service-provider.

Overview

The steps in this section walk you through deploying the following:

  • New VPC and public / private subnets configuration.

  • Security Groups.

  • An application load balancer with:
    • HTTPS listeners on port 443.
    • A rule to redirect requests to leaf (/v1/ntp).
    • A rule to redirect requests to leaf for socket connection (/socket).
    • Rules to redirect traffic to your leaf backend (socket).
  • A DNS record to point to your load balancer.

  • An SSL Certificate issued by AWS Certificate Manager (ACM) to make your endpoint secure when deploying a Twitch extension. (Twitch requirement.)

  • A Genvid cluster for deploying your project configuration (EC2 Instances).

Important

Depending on your AWS account type, deploying this infrastructure might incur costs. Always verify with AWS if any fees might be encountered before deploying a Genvid SDK infrastructure.

Before You Start

  • If you don’t already have one, you need an AWS Account.

  • You need to create the DNS zone ahead of time, as propogation can take up to to 24 hours.

    You need to create the DNS zone in Route 53 and configure it as a subzone. Then create NS records to point a subdomain (twitch.yourdomain.com) at that subzone. This simplifies creating and validating SSL certificates.

    See the AWS documentation for information on how to set this up.

  • Use a tool like dig (bash) or Resolve-DnsName (PowerShell) to validate that your DNS has propagated.

Set Up the Infrastructure

  1. Install a bastion server and set up a local cluster on your computer.

    From that local bastion, you will then be able to deploy a cluster in the cloud on AWS.

  2. Create a new cluster.

  3. Import the Terraform module SDK-version/basic/alb_ssl_cluster.

    version will match the version of the Genvid SDK you’re using. (Currently 1.21.2.)

  4. Fill out the remaining settings.

    This deploys a new cluster in AWS with the required infrastructure to run the Twitch Sample.

  5. Follow the Twitch Sample Tutorial documentation to deploy the game, the web server backend, and the configuration.

Important Information about this Terraform configuration

  • This is not production ready: There is no backup or remote backend strategy included in this configuration.
  • The web port must be static and your Nomad job must match your Terraform settings for the web port (usually 30001).
  • The leaf port must be static and your Nomad job must matchyour Terraform settings for the leaf port (usually 30002).
  • The path for web socket connection configured in Terraform must match your Nomad template configuration (/socket). See the Consul key/value services/leaf/websocketUrlSuffix.