Define and deploy containerized Ruby on Rails Applications on AWS
A tool for defining and deploying containerized Ruby on Rails applications on AWS.
aws-rails-provisioneris a command line tool using your configurations defined in
aws-rails-provisioner.ymlfile 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-provisionergem, you need to have:
$ npm i -g aws-cdk
aws-rails-provisionergem is available from RubyGems, currently with preview versions.
gem install aws-rails-provisioner --pre
aws-rails-provisioner.ymlis a configuration file defining how
aws-rails-provisionerbootstraps required AWS resources for your Ruby on Rails applications.
vpc: max_az: 2 enable_dns: true services: my_rails_foo: source_path: ./path/to/my_rails_foo # relative path from
aws-rails-provisioner.ymlfargate: 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: ...
tiny.ymlfor a minimal
aws-rails-provisioner.ymlconfiguration example). The full configuration options are documented here.
aws-rails-provisioner.ymlis defined, run the build command. This will boostrap AWS CDK stacks and define all required AWS resources and connections in CDK code.
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-cicdoption 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:
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.
--with-cicdis 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
buildspecfiles to activate the pipeline. Sample
buildspecs are availble under
./buildspecshandling application image builds and rails migrations.
aws-rails-provisionercommand line options see:
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-provisioneris distributed under Apache License, Version 2.0. See LICENSE for more information.