#!/bin/bash

set -euo pipefail

tmp_dir=$(mktemp -d)

cp rollover.py "$tmp_dir"
pip --quiet install --requirement requirements.txt --target "$tmp_dir"

cd "$tmp_dir"
zip --recurse-paths package.zip .

aws s3 cp package.zip s3://zoox-es-rollover-lambda-us-west-2/package-blue.zip
aws s3 cp package.zip s3://zoox-es-rollover-lambda-us-west-2/package-green.zip

echo ""
echo "Swap green/blue in Terraform."
