This tool is deprecated. We cannot guarantee that it will work.
This documentation will remain for historical purposes.
A tool for defining and deploying containerized Ruby on Rails applications on AWS.
aws-rails-provisioner
is a command line tool using your configurations defined in aws-rails-provisioner.yml
file to generate AWS CDK stacks on your behalf, provisioning required AWS resources for running your containerized Ruby on Rails applications on AWS (current supported platform: AWS Fargate) within a few commands.
This tool is under developer preview (beta) stage, with active development, releases might lack features and might have future breaking changes.
Before using the aws-rails-provisioner
gem, you need to have:
install or update the [AWS CDK Toolkit] from npm (requires Node.js ≥ 8.11.x):
$ npm i -g aws-cdk
aws-rails-provisioner
gem is available from RubyGems, currently with preview versions.
gem install aws-rails-provisioner --pre
aws-rails-provisioner.yml
is a configuration file defining how aws-rails-provisioner
bootstraps required AWS resources for your Ruby on Rails applications.
version: '0'
vpc:
max_az: 2
enable_dns: true
services:
my_rails_foo:
source_path: ./path/to/my_rails_foo # relative path from `aws-rails-provisioner.yml`
fargate:
desired_count: 3
memory: 512
cpu: 256
envs:
PORT: 80
RAILS_LOG_TO_STDOUT: true
public: true
db_cluster:
engine: aurora-postgresql
db_name: app_development
scaling:
max_capacity: 5
on_cpu:
target_util_percent: 80
scale_in_cool_down: 300
on_requests:
requests_per_target: 1000
my_another_rails:
...
See ./examples
for more aws-rails-provisioner
examples (see tiny.yml
for a minimal aws-rails-provisioner.yml
configuration example). The full configuration options are documented here.
Once aws-rails-provisioner.yml
is defined, run the build command. This will boostrap AWS CDK stacks and define all required AWS resources and connections in CDK code.
aws-rails-provisioner build
By default, it defines a VPC with public and private subnets, an Amazon RDS Database Cluster, an ECS cluster with AWS Fargate services containing application images. When building with --with-cicd
option a CICD stack will be defined automatically (including a Rails data migration step).
aws-rails-provisioner build --with-cicd
After the build completes, run the deploy command to run CDK code that deploys all defined AWS resources:
aws-rails-provisioner deploy
Instead of deploying everything all at once, you can deploy stack by stack, application by application:
# only deploys the stack creates VPC and ECS cluster
aws-rails-provisioner deploy --init
# deploys fargate service and database cluster when defined
aws-rails-provisioner deploy --fargate
# deploy CICD stack
aws-rails-provisioner deploy --cicd
# deploy only :rails_foo application
aws-rails-provisioner deploy --fargate --service my_rails_foo
After the deployment completes, your applications are now running on AWS Fargate fronted with AWS Application LoadBalancer. You can view your website using the public IP address of the network interface's load balancer.
Note: for applications with databases, rails db migration is needed; the CICD stack contains a migration phase by default, running DB migration commands insides private subnets, connected to the DB Cluster.
When --with-cicd
is enabled at build, a CICD stack is created. Once deployment completes, an AWS CodePipeline is available with source, build, migration, and deploy phases for your Rails application. You need to commit your Rails application to the CodeCommit source repository in the pipeline with buildspec
files to activate the pipeline. Sample buildspec
s are availble under ./buildspecs
handling application image builds and rails migrations.
Full aws-rails-provisioner
command line options see:
aws-rails-provisioner -h
We welcome community contributions and pull requests. See CONTRIBUTING for details.
Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests.
aws-rails-provisioner
The aws-rails-provisioner
is distributed under Apache License, Version 2.0. See LICENSE for more information.