<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nicolas Rouanne on Medium]]></title>
        <description><![CDATA[Stories by Nicolas Rouanne on Medium]]></description>
        <link>https://medium.com/@nicolasrouanne?source=rss-76335a297e79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MeY54qRO95dVeDJX.JPG</url>
            <title>Stories by Nicolas Rouanne on Medium</title>
            <link>https://medium.com/@nicolasrouanne?source=rss-76335a297e79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:05:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicolasrouanne/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rails deployment on AWS Elastic Beanstalk]]></title>
            <link>https://medium.com/@nicolasrouanne/rails-deployment-on-aws-elastic-beanstalk-fa0047ae5fba?source=rss-76335a297e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa0047ae5fba</guid>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[elastic-beanstalk]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Nicolas Rouanne]]></dc:creator>
            <pubDate>Thu, 17 Jan 2019 14:30:14 GMT</pubDate>
            <atom:updated>2020-03-09T08:50:41.527Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://aws.amazon.com/elasticbeanstalk"><strong>AWS Elastic Beanstalk</strong></a> is the <em>Platform As A Service</em> solution by <strong>AWS</strong>. It is thought as a replacement for <a href="https://www.heroku.com/home"><strong>Heroku</strong></a> which is <strong>great</strong> 🙌 but can become very expensive 💰 when the project is growing or in need of real performance 🏎.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qfzx-QVZ1dn33818q8qqaQ.jpeg" /><figcaption>That’s a really big beanstalk…</figcaption></figure><h3>Google App Engine comparison</h3><p><strong>Google Cloud</strong> also has its <em>Platform As A Service</em> product, <a href="https://cloud.google.com/appengine"><strong>Google App Engine</strong></a>. However very promising and notably simpler than <em>AWS Elastic Beanstalk</em>, we have been experiencing serious issues while testing it:</p><ul><li><em>downtime in deployment</em> 🚧: when deploying a new version of the app, it often becomes unreachable (5xx errors) for up to a whole minute.</li><li><em>veeeery long deploys</em> ⬆️ ⏲: it takes on average <strong>8 to 10 minutes ⏳</strong> waiting for a new version of the application to deploy. Compared to a <em>few seconds</em> on <strong>Heroku</strong> and a <em>few minutes</em> on <strong>Elastic Beanstalk</strong>. We found out that it truly harmed our development workflow, leading to more context switching, less deploys and tests.</li></ul><h3>Prerequisites</h3><p>Interacting with Elastic Beanstalk can be done either of 2 ways:</p><h3>Install EB CLI</h3><p><a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html">Install </a><a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html">eb cli</a> 🛠 on <em>Mac OS</em> with <em>Homebrew</em> 🍺:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53f7dfb55423e2c6d1378ff121889282/href">https://medium.com/media/53f7dfb55423e2c6d1378ff121889282/href</a></iframe><h3>Initialize an EB CLI project</h3><p>After installing eb cli you need to <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html">configure it</a> 👷‍♂️ for your project and with your credentials 🔑.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2244b3b8107363345ac8d3645456b953/href">https://medium.com/media/2244b3b8107363345ac8d3645456b953/href</a></iframe><h3>Set up</h3><h3>Application</h3><ol><li><strong><em>Create a New Application</em></strong> 🧙‍♂️on the <a href="https://console.aws.amazon.com/elasticbeanstalk"><em>AWS Console</em> for Elastic Beanstalk</a>. You’ll need to set an <em>application name</em> (e.g. goldengate)</li><li><strong>Create an <em>environment</em></strong> 🏜 for your application. <em>Environments</em> are essentially instances of your application. Environments can have different configurations (number and size of EC2 instances, databases, environment variables, etc.)<br><em>environments should be created using </em><em>eb cli ⌨️</em></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8874389c31e0f60cf420eabcd2614648/href">https://medium.com/media/8874389c31e0f60cf420eabcd2614648/href</a></iframe><blockquote><strong>IMPORTANT ⚠️</strong>: as with everything you do on AWS, <strong>carefully choose the <em>region</em></strong> 🌍 you start your application on. It’s not possible to change afterwards. Even when exploring the AWS console, make sure you are actually looking in the right region, or you won’t see your application 🤷‍♂️</blockquote><h3>Database</h3><p>To add a database to the newly created application, AWS provides integration with <a href="https://aws.amazon.com/rds/"><strong>AWS RDS</strong></a> (<em>Relational Database Service</em>). <strong>AWS RDS</strong> is AWS’s <em>DB As A Service</em> and offers MySQL, PostgreSQL, Oracle, or SQL Server databases.</p><h4>Create a database</h4><p><a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html">Adding a database</a> to your application comes in 2 options:</p><ol><li><strong>create the database </strong><a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html#environments-cfg-rds-create"><strong><em>in your environment 🏠</em></strong></a><strong><em><br></em></strong>the database is “linked” to the environment; i.e. if the environment is destroyed, the DB is destroyed as well</li><li><strong>launch a database <em>outside of your environment</em> 🏕</strong> and <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby.rds.html#ruby-rds-connect">link it</a> to your environment.</li></ol><blockquote><strong>Option 1. — database <em>in our environment</em> — seems like a reasonable choice</strong> since data is hardly shared between environments (e.g. production and staging).</blockquote><p><strong>Option 1. — Create a Database <em>in the environment</em></strong></p><p>Create the database In <em>AWS Elastic Beanstalk console</em> 🕹 using the <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html#environments-cfg-rds-create">documentation</a> An RDS instance created this way will <strong>automatically expose</strong> the following <em>environment variables</em> to your application: RDS_HOSTNAME, RDS_PORT, RDS_DB_NAME, RDS_USERNAME, RDS_PASSWORD</p><p>These environment variables should be used in your <em>rails application</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9708b0588742516c3e50801a71b7c243/href">https://medium.com/media/9708b0588742516c3e50801a71b7c243/href</a></iframe><p>Your application should now be able to connect to the database ☕️</p><p><strong>Option 2. — Create an external database</strong></p><p><strong>Create the database in </strong><a href="https://gist.github.com/nicolasrouanne/console.aws.amazon.com/rds"><strong><em>AWS RDS console</em></strong></a> using the <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.RDS.html#rds-external-defaultvpc">documentation</a>. Choose the <a href="https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html"><strong><em>Default VPC</em></strong></a> approach (aka <em>nothing to do</em>).</p><p>The whole process can be summed up in:</p><ol><li><strong>create the database</strong> 🧙‍♂️ in <em>RDS</em></li><li><strong>modify security rules</strong> 👮‍♂️(i.e. <em>security groups</em>) of the newly created DB to allow <em>Elastic Beanstalk</em> to connect</li><li><strong>manually create the RDS <em>environment variables</em></strong> 🏜 in <em>Elastic Beanstalk</em> holding credentials to connect to your database (e.g. RDS_DB_NAME, RDS_DB_NAME, etc.)</li></ol><h4>Database gotchas</h4><p>Some information is either <em>hidden</em> or a <em>sensible default</em> and can be hard to find. The <strong>database name</strong> 📛 is <em>always</em> ebdb.</p><h3>Sidekiq</h3><p>Setting up <strong>Sidekiq</strong> on <em>Elastic Beanstalk</em> requires using <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html">.ebextensions</a> feature. .ebextensions is a way to create <em>advanced environment customization with configuration files</em>.</p><p><a href="https://gist.github.com/ssaunier/44bbebb9c0fa01953860">Here is a </a><a href="https://gist.github.com/ssaunier/44bbebb9c0fa01953860">sidekiq.config</a> <em>.ebextension</em> file which seems to be working (not yet tested)</p><h3>Migrate from Heroku</h3><p>When migrating from <strong>Heroku</strong>, you <em>need to migrate 🚛 data</em> from <em>Heroku Postgres</em> to the <strong>Postgres DB</strong> on AWS RDS.</p><h4>Dump your Heroku DB</h4><p>Follow <strong>Heroku</strong> <em>Documentation</em> on <a href="https://devcenter.heroku.com/articles/heroku-postgres-import-export#export">exporting ⬇️ a Postgres database</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d534738e9c4560d09dd096f06fbef7be/href">https://medium.com/media/d534738e9c4560d09dd096f06fbef7be/href</a></iframe><h4>Import the dump to AWS</h4><h4>Temporarily open public access</h4><p>This requires <a href="https://serverfault.com/questions/656079/unable-to-connect-to-public-postgresql-rds-instance">temporarily making the RDS database <strong>Publicly Accessible</strong> 🔓</a>. In <em>Inbound rules</em> of your RDS instance grand access to Anywhere 0.0.0.0/0 on TCP 5432 port</p><blockquote><em>⚠️ this </em><strong><em>will need to be reverted afterwards</em></strong><em> because it’s far too much permissive</em></blockquote><h4>Check connection</h4><p>You need to make sure you <strong>can connect 🔗 to AWS RDS</strong> using <em>native commands</em> (i.e. psql and pg_restore )/ Check if you can psql into your account; you will be prompted for your password:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27414963078f1309cff924363117c3d9/href">https://medium.com/media/27414963078f1309cff924363117c3d9/href</a></iframe><ul><li>RDS_USERNAME: the username you entered when creating the RDS DB instance</li><li>RDS_HOSTNAME: the full hostname of the database such as aape7pwcqsdfs.cfynf9xjj89ys.eu-west-3.rds.amazonaws.com</li></ul><blockquote><em>Note: the </em><em>dbname is always </em><em>ebdb; yes that&#39;s a </em>gotcha<em> 😉🤷‍♂️</em></blockquote><h4>Import the dump</h4><p><strong>Import the dump</strong> ⬆️ to your RDS instance using pg_restore:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1cc4003ae191f5f116d85b9bf81b5c0/href">https://medium.com/media/b1cc4003ae191f5f116d85b9bf81b5c0/href</a></iframe><p><em>Source</em>: <a href="https://www.lewagon.com/blog/how-to-migrate-heroku-postgres-database-to-amazon-rds">How to migrate your postgresql database from heroku to Amazon RDS</a></p><h3>Usage</h3><h4>Deploy</h4><p>Deploy ⬆️ a new version of your application using eb deploy. 📡</p><blockquote><strong><em>IMPORTANT ⚠️</em></strong><em>: </em><em>eb deploy deploys the current state of your local </em>git<em> repository (branch and HEAD). It essentially means it </em><a href="https://stackoverflow.com/a/42133091/5186918"><strong><em>won&#39;t deploy</em></strong></a><strong><em> any non committed change</em></strong><em> (this can be quite confusing at first 😅)</em></blockquote><h4>rails console</h4><p>To run rails console 👨‍💻 on an <em>Elastic Beanstalk</em> application:</p><ol><li>ssh into your instance using eb ssh</li><li>run the following to run rails console (<a href="https://stackoverflow.com/a/37754922/5186918">source</a>)</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c56088e492ff7dc61986cb4fac72fbcc/href">https://medium.com/media/c56088e492ff7dc61986cb4fac72fbcc/href</a></iframe><p><em>Originally published at </em><a href="https://gist.github.com/nicolasrouanne/4bd107e8f7d46011518d1487961f4d1b"><em>gist.github.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa0047ae5fba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>