Home

Awesome

Serverless Southwest Check In

Build Status

Serverless Southwest Check In is an email bot which will automatically check you into your Southwest flights. Never sit in a middle seat again!

This project is powered by the AWS Serverless Platform (Lambda, Step Functions, and SES) and was inspired by similar projects from Aaron Ortbals and Joe Beda.

Quickstart

Installation

Skip to the Deploy section if you already have Terraform installed and configured with your AWS credentials.

Requirements

Configure your AWS Credentials

Add your credentials to your environment, with aws configure, or directly with Terraform.

Here's an example of setting your credentials via environment variables. For more detailed explanations, see the Terraform AWS Provider documentation.

$ export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
$ export AWS_DEFAULT_REGION=us-east-1

Initialize Terraform state

Run the following command to configure Terraform's Remote State in S3.

$ terraform init terraform/

You will be prompted for an S3 location to store the remote statefile in. If you wish to use a local state, just remove terraform/backend.tf and rerun this command.

Usage

Terraform Variables

You need to either specify your variables in a terraform.tfvars file, or you will be prompted for the variables during the deploy.

You can rename the terraform.tfvars.example to terraform.tfvars and edit it. Alternatively, you can skip to the Deploy section below in which you will be prompted for the following variables:

Deploy

To package, build, and deploy to AWS, run:

$ make deploy

Or, if you don't have make installed:

$ pip install -r lambda/requirements.txt -t lambda/vendor/python && terraform apply terraform/

Add a flight

New flights can be added by an SES email trigger or by manually executing an AWS Step Function.

Add via Email

Forward your reservation email to the email address set above as var.recipients. The reservation email is sent by Southwest at purchase time and should be in the form:

Flight reservation (ABC123) | 25DEC17 | ABC-XYZ | LASTNAME/FIRSTNAME

Manually execute Step Function

Start an execution of the sw-check-in Step Function via the AWS cli, passing in your check-in details in JSON as input. Here's an example:

STEP_FN_INPUT='{
  "first_name": "George",
  "last_name": "Bush",
  "confirmation_number": "ABC123",
  "email": "gwb@example.com"
}'
STEP_FN_ARN=$(aws --output text stepfunctions list-state-machines --query 'stateMachines[*].stateMachineArn' | grep -E ':sw-check-in$')
aws stepfunctions start-execution \
  --state-machine-arn "$STEP_FN_ARN" \
  --input "$STEP_FN_INPUT"

The email parameter is optional and sets the email address to which notifications will be sent.

Other

Notifications

An SNS topic checkin-notifications is created as part of the Terraform deploy, but you must manually create and attach a subscription to it through the SNS dashboard. See the Amazon documentation on how to Subscribe to a Topic for more information.

Contributing

Testing

To run tests, you must first have the requirements provided in lambda/requirements-dev.txt installed:

$ pip install -r lambda/requirements-dev.txt

After you have installed the test dependencies, you can run the test suite with:

# unit tests
$ make test
# flake8 style check
$ make lint