Bin Scripts (Build & Deploy)

Our Quick Start cookiecutter includes a single bin/deploy script that wraps three SAM commands needed to deploy your application.

Think of our provided bin scripts as starting points! You should add to or adjust each to meet your needs. Well maintained deploy scripts are critical to good CI/CD practices no matter if they are used from your personal machine or automated via GitHub Actions. From a Lamby perspective, here are a few helpful topics about our deploy process.

Overview of Deploy Process

Remember, our Docker usage plays a major role here. Especially with shared git/aws credentials & environment variables.

Using Private Gems on GitHub

Even though we do share your git setup with the Docker container, you may have auth issues accessing them. This may be more so true on CI/CD systems. One solution we like requires adding this line prior to the build's bundle deployment step.

bundle config --local GITHUB__COM "$(git config github.token):x-oauth-basic"

It sets a Bundler config to use your personal GitHub OAuth token. Make sure to set that up using this GitHub help article. Lastly, make sure your Gemfile uses this git source format. Most newer Rails apps do this already.

git_source(:github) { |repo| "https://github.com/#{repo}.git" }

CloudFormation Bucket

Your code needs to be packaged and uploaded to an S3 bucket prior to being deployed. We dynamically create a bucket name during the cookiecutter bootstrap script. This bucket name is saved in a .bucket-name file in your project. It is a great idea for you to change this to something that makes sense for you! If you have the AWS CLI installed, creating a bucket is a simple command like so.

$ aws s3 mb cloudformation.mycomany.com

Multiple Environments

Feel free to make more per-environment deploy scripts. For example bin/deploy-staging may look like this. The AWS_PROFILE is an useful environment variable that helps you manage different AWS accounts via all CLI tools. We pass it and RAILS_ENV via our docker compose scripts. Learn more about AWS Environment Variables.

#!/bin/bash
set -e
export AWS_PROFILE="staging"
export RAILS_ENV="staging"
./bin/deploy
Lamby 🆕 HTTP API Support     GitHub