# Deployment
# Serverless Function
# build functions
./_script/build.sh
# deploy
sls deploy --stage=prod
# or
sls deploy --stage=dev
Specific service:
sls deploy --stage=prod --service=fetch-canada
# EC2 Worker
# Config
The aws-cli
is pre-installed on the ec2 instance we just need to add credentials. SSH onto the box and run:
aws configure
and follow the prompts.
# User-Data
Add this to the EC2 user-data. With this in place the Go app (or any script) will run every time the EC2 instance is booted. More on this here (opens new window).
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
/bin/main
--//--
# Build + Upload
./_script/build.sh
# upload
scp -i ~/.ssh/<my_keys> functions/canada/bin/main ec2-user@<some_ip_address>:/home/ec2-user
# upload .env if needed
scp -i ~/.ssh/<my_keys> .env ec2-user@<some_ip_address>:/home/ec2-user
# move files.
# ssh onto the box.
sudo mv main /bin/main
sudo mv .env /.env
This whole process could probably be cleaned up / automated with Puppet or Jenkins or something...
← Development About →