Last active
April 5, 2016 16:29
-
-
Save marano/cf1df481afd21b735a2b7ca11fcebd6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws configure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ec2 create-key-pair --key-name=example_app-dev-keypair |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
production: | |
adapter: postgresql | |
database: <%= ENV['DATABASE_NAME'] || 'example_app' %> | |
host: <%= ENV['DATABASE_HOST'] || 'localhost' %> | |
port: <%= ENV['DATABASE_PORT'] || 5432 %> | |
username: <%= ENV['DATABASE_USERNAME'] || 'my_user' %> | |
password: <%= ENV['DATABASE_PASSWORD'] %> | |
min_messages: ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EB_DEPLOYER_ENV=dev rake eb:deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :eb do | |
def eb_deployer_env | |
ENV["EB_DEPLOYER_ENV"] || "dev" | |
end | |
def eb_deployer_package | |
git_sha = `git log -n1 | awk '/^commit/ {print $2; exit;}' | cut -c 1-10`.strip | |
"tmp/pkg/example_app-#{git_sha}-#{ENV['VERSION_LABEL_SUFFIX']}.zip" | |
end | |
desc "Remove the package file we generated." | |
task :clean do | |
sh "rm -rf tmp/pkg" | |
end | |
desc "Build package for eb_deployer to deploy to a Ruby environment in tmp/pkg directory." | |
task :package => [:clean, :environment] do | |
sh "mkdir -p tmp/pkg" | |
to_exclude = %w(tmp .git coverage .idea .DS_Store).map { |file| "--exclude='*#{file}*'" }.join(' ') | |
sh "bundle exec rake assets:precompile" | |
sh "zip -9 -r #{to_exclude} '#{eb_deployer_package}' ." | |
end | |
desc "Deploy package we built in tmp directory. default to dev environment, specify environment variable EB_DEPLOYER_ENV to override, for example: EB_DEPLOYER_ENV=production rake eb:deploy." | |
task :deploy => [:package] do | |
sh "eb_deploy --package '#{eb_deployer_package}' --environment #{eb_deployer_env}" | |
end | |
desc "Destroy Elastic Beanstalk environments. It won't destroy resources defined in eb_deployer.yml. Default to dev environment, specify EB_DEPLOYER_ENV to override." | |
task :destroy do | |
sh "eb_deploy --destroy --environment #{eb_deployer_env}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: example_app | |
common: | |
solution_stack_name: 64bit Amazon Linux 2015.03 v1.3.1 running Ruby 2.1 (Passenger Standalone) | |
smoke_test: | | |
curl_http_code = "curl -s -o /dev/null -w \"%{http_code}\" http://#{host_name}" | |
Timeout.timeout(600) do | |
until ['200', '301', '302'].include?(`#{curl_http_code}`.strip) | |
sleep 5 | |
end | |
end | |
option_settings: | |
- namespace: aws:autoscaling:launchconfiguration | |
option_name: InstanceType | |
value: m1.small | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: DATABASE_NAME | |
value: example_app | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: DATABASE_USERNAME | |
value: example_app | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: DATABASE_PASSWORD | |
value: PleaseChangeMe | |
resources: | |
template: config/rds.json | |
inputs: | |
DBName: example_app | |
DBUser: example_app | |
DBPassword: PleaseChangeMe | |
outputs: | |
RDSPassSecurityGroup: | |
namespace: aws:autoscaling:launchconfiguration | |
option_name: SecurityGroups | |
RDSHost: | |
namespace: aws:elasticbeanstalk:application:environment | |
option_name: DATABASE_HOST | |
RDSPort: | |
namespace: aws:elasticbeanstalk:application:environment | |
option_name: DATABASE_PORT | |
environments: | |
dev: | |
strategy: inplace-update | |
production: | |
option_settings: | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: SECRET_KEY_BASE | |
value: 52f6fb66e2e8306dff7e5a0964f46df25239e377ceab35ba29966c1292862a1e00ca2e09333527b10427902fe287 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environments: | |
dev: | |
option_settings: | |
- namespace: aws:autoscaling:launchconfiguration | |
option_name: EC2KeyName | |
value: example_app-dev-keypair |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environments: | |
staging: | |
option_settings: | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: S3_BUCKET | |
value: example_app-dev.assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: RACK_ENV | |
value: production | |
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: RAILS_ENV | |
value: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'eb_deployer' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle install | |
rails generate eb_deployer:install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ebextensions/01_postgres_packages.config # Packages needed to install the `pg` postgres gem. | |
config/eb_deployer.yml # It configures eb_deployer options as well as Elastic Beanstalk. | |
config/rds.json # The CloudFormation stack configuration with a Postgres RDS instance. | |
lib/tasks/eb_deployer.rake # Deployment tasks for you to customize. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
option_settings: | |
- namespace: aws:autoscaling:launchconfiguration | |
option_name: SSHSourceRestriction | |
value: tcp, 22, 22, 0.0.0.0/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- namespace: aws:elasticbeanstalk:application:environment | |
option_name: RAILS_SKIP_ASSET_COMPILATION | |
value: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strategy: blue-green |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strategy: inplace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- namespace: aws:elasticbeanstalk:command | |
option_name: Timeout | |
value: "900" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version_label: example_app-<%= `git log -n1 | awk '/^commit/ {print $2; exit;}' | cut -c 1-10`.strip %>-<%= ENV['VERSION_LABEL_SUFFIX'] %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment