<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Zshawn Syed</title>
    <description>A collection of tips, blunders, and experiences of a programmer.
</description>
    <link>https://www.zshawnsyed.com/</link>
    <atom:link href="https://www.zshawnsyed.com/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Sun, 03 Jul 2022 04:59:35 +0000</pubDate>
    <lastBuildDate>Sun, 03 Jul 2022 04:59:35 +0000</lastBuildDate>
    <generator>Jekyll v3.9.2</generator>
    
      <item>
        <title>Running rails db:migrate in kubernetes</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;I am working on a dev project that is written in rails but deployed within kubernetes. While doing local development, I am
running the cluster using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;skaffold dev&lt;/code&gt;. This allows me to make changes locally and have it auto-sync to the running container
without having to rebuild the image and push it anywhere. One issue with this approach is that in order to run database migrations
locally, creating a deployment or job is a little bit heavy handed. Instead, we can simply connect to the running pod and run our
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db:migrate&lt;/code&gt; command there.&lt;/p&gt;

&lt;h2 id=&quot;connecting-to-a-kubernetes-pod&quot;&gt;Connecting to a kubernetes pod&lt;/h2&gt;

&lt;p&gt;In order to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails db:migrate&lt;/code&gt; we need to connect to a running pod. In order to determine which pod we need to connect to,
we can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubectl&lt;/code&gt; to get the name of the pod that is running the rails server. In my project, I have named that pod simply &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server-deployment&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; kubectl get pods
NAME                                   READY   STATUS    RESTARTS   AGE
server-deployment-6886cb479c-tt4mf   1/1     Running   36         73d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With the above, we can grab the full pod name and run the following command which will connect to the running pod, run the command, and exit.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;kubectl exec server-deployment-6886cb479c-tt4mf -- /bin/bash -c &quot;rails db:migrate&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, we can do this in one single step instead of two. The single line command looks like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;kubectl exec $(kubectl get pods | grep server | sed 's/ .*//') -- /bin/bash -c &quot;rails db:migrate&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The command above is doing the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The sub-command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$(kubectl ...)&lt;/code&gt; is getting all the pods, grepping for our server pod name, and then stripping everything but the first word that contains our full pod name&lt;/li&gt;
  &lt;li&gt;This is then substituted into the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubectl exec &amp;lt;our_pod_name&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Then finally, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/bin/bash -c &quot;rails db:migrate&quot;&lt;/code&gt; runs a one off command and auto-exits (we are not opening an interative connection&lt;/li&gt;
  &lt;li&gt;Profit!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;tldr&quot;&gt;TLDR&lt;/h3&gt;

&lt;p&gt;To run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails db:migrate&lt;/code&gt; during our development flow, we can connect to the running rails pod and run that command via:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;kubectl exec $(kubectl get pods | grep server | sed 's/ .*//') -- /bin/bash -c &quot;rails db:migrate&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Thu, 25 Nov 2021 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2021/11/25/running-rails-migrate-kubernetes/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2021/11/25/running-rails-migrate-kubernetes/</guid>
        
        
      </item>
    
      <item>
        <title>Ignoring .git directory when using skaffold dev</title>
        <description>&lt;p&gt;I was using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;skaffold dev&lt;/code&gt; to do my development work locally. Skaffold allows you to run your kubernetes cluster locally
without requiring building and pushing your container image anywhere. Instead it builds it locally 
and &lt;a href=&quot;https://skaffold.dev/docs/pipeline-stages/filesync/#manual-sync-mode&quot;&gt;deploys patched changes&lt;/a&gt;
as you edit the files. I was running into an issue where I set up my sync directive to listen to my ruby and javascript 
files (rails stack) and map them over. However, for all other file extensions, skaffold by default will attempt to rebuild 
the image and restart it instead of hot patching the files only.&lt;/p&gt;

&lt;p&gt;I noticed, whenever interacting with git, it would cycle through that entire process and generally slow things down
for a minute or so. This was both annoying and frequent enough for me to investigate if its possible to ignore
certain files and directories. The good thing is that not only is it supported but its not even required in skaffold.
Skaffold honors anything within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.dockerignore&lt;/code&gt; file. So to fix the issue, I simply created one and added the .git folder there.&lt;/p&gt;

&lt;p&gt;My &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.dockerignore&lt;/code&gt; file looks like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Ignore the .git folder entirely
.git
log/
*.tmp
*.temp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Mon, 22 Nov 2021 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2021/11/22/ignoring-git-in-skaffold/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2021/11/22/ignoring-git-in-skaffold/</guid>
        
        
      </item>
    
      <item>
        <title>Installing the eventmachine gem in WSL</title>
        <description>&lt;p&gt;I ran into this issue a few times and kept forgetting the fix for it which is why I am
writing a quick post on it. Generally when adding ruby gems, we add them to our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Gemfile&lt;/code&gt; and just throw &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle install&lt;/code&gt; at it to get everything configured. However I kept running into a strange issue when attempting to get event machine installed for a gem I was writing myself.&lt;/p&gt;

&lt;p&gt;The installation steps are actually quite simple if you run into this error.&lt;/p&gt;

&lt;h2 id=&quot;the-error&quot;&gt;The error&lt;/h2&gt;

&lt;p&gt;When trying to install eventmachine (1.2.7) on &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/wsl/install-win10&quot;&gt;WSL&lt;/a&gt;, I kept getting this stack error:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;user@DESKTOP:/mnt/f/code/project$ bundle install
Fetching gem metadata from https://rubygems.org/......
Using rake 10.5.0
Fetching eventmachine 1.2.7
Installing eventmachine 1.2.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/user/.rvm/gems/ruby-2.7.1/gems/eventmachine-1.2.7/ext
/home/user/.rvm/rubies/ruby-2.7.1/bin/ruby -I /home/user/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0 -r
./siteconf20201031-507-no2sha.rb extconf.rb --with-ssl-dir\=c:/OpenSS
-----
Cannot find OpenSSL include path c/include:/OpenSS/include
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/user/.rvm/rubies/ruby-2.7.1/bin/$(RUBY_BASE_NAME)
        --with-ssl-dir
        --with-ssl-include
        --without-ssl-include=${ssl-dir}/include
        --with-ssl-lib
        --without-ssl-lib=${ssl-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/user/.rvm/gems/ruby-2.7.1/extensions/x86_64-linux/2.7.0/eventmachine-1.2.7/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/user/.rvm/gems/ruby-2.7.1/gems/eventmachine-1.2.7 for inspection.
Results logged to /home/user/.rvm/gems/ruby-2.7.1/extensions/x86_64-linux/2.7.0/eventmachine-1.2.7/gem_make.out

An error occurred while installing eventmachine (1.2.7), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.2.7' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  project was resolved to 0.1.0, which depends on
    action_cable_client was resolved to 3.1.0, which depends on
      websocket-eventmachine-client was resolved to 1.3.0, which depends on
        websocket-eventmachine-base was resolved to 1.2.0, which depends on
          eventmachine
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;the-fix&quot;&gt;The fix!&lt;/h2&gt;

&lt;p&gt;To bypass this stack, the solution is to first install eventmachine locally before running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle install&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The command is simply:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gem install eventmachine --pre
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After this, you can successfully run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle install&lt;/code&gt; to install the rest of your dependencies.&lt;/p&gt;

</description>
        <pubDate>Sat, 31 Oct 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/10/31/wsl-installing-eventmachine/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/10/31/wsl-installing-eventmachine/</guid>
        
        
      </item>
    
      <item>
        <title>Add RuboCop to Existing Projects</title>
        <description>&lt;p&gt;Adding RuboCop to a project might seem daunting but is completely do-able. When working with an existing code base that might have grown in size, it can seem impossible to consider fixing all the RuboCop issues up front. To accomodate this, RuboCop has a built-in functionality to create a TODO file of existing violations that can then slowly be tackled over time.&lt;/p&gt;

&lt;h2 id=&quot;installing-rubocop&quot;&gt;Installing RuboCop&lt;/h2&gt;

&lt;p&gt;The following command will install rubocop globally:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;rubocop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you desire an installation directly into the project, you can add it to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Gemfile&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rubocop'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;require: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;generating-rubocop_todoyml&quot;&gt;Generating .rubocop_todo.yml&lt;/h2&gt;

&lt;p&gt;By default rubocop will turn off the entire cop if there are too many violations. This is &lt;strong&gt;not&lt;/strong&gt; what we want, because if we let the entire cop become disabled then any new code is allowed to continue that violation. Instead when we generate the whitelisting file, we’ll tell rubocop to keep whitelisting files instead of disabling the entire cop. To do that, we will run this command:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rubocop &lt;span class=&quot;nt&quot;&gt;--auto-gen-config&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--auto-gen-only-exlude&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--exclude-limit&lt;/span&gt; 10000&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;span class=&quot;bold&quot;&gt;auto-gen-config - &lt;/span&gt;runs RuboCop against the codebase and captures all violations into a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.rubocop_todo.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;bold&quot;&gt;auto-gen-only-exclude - &lt;/span&gt;ensures that RuboCop adds Exclude and not Max when generating the results. This flag is used in conjuction to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--exclude-limit&lt;/code&gt;. We need to ensure that the second flag is high enough otherwise &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auto-gen-only-exclude&lt;/code&gt; will revert back to using Max.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;bold&quot;&gt;exclude-limit - &lt;/span&gt;limits how many files will be added to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Exclude&lt;/code&gt; block for each cop. The default is very low (15) and if we do not adjust this higher, we will end up turning off the entire cop if there are too many violations. This flag is the key element to our whitelisting approach. As long as this value is high enough, none of our cops will be outright disabled and we can continue onboarding new code at higher standards while working to fix all the violations on the existing code.&lt;/p&gt;

&lt;p&gt;As a sanity check, once generating the file is complete make sure that no cops are disabled. If they are, re-run the command above with a higher &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--exclude-limit&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;addressing-existing-violations&quot;&gt;Addressing Existing Violations&lt;/h2&gt;

&lt;p&gt;The key takeaway with generating the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.rubocop_todo.yml&lt;/code&gt; is not to forget the old violations but to slowly tackle them while enforcing all new code to higher standards. This is a continuious improvement effort. When fixing the issues, make sure that the commits are solely for those and not regular feature work as well. It is much easier to push along changes that are code style improvements and provides a nice commit history of how the improvements were handled.&lt;/p&gt;

&lt;p&gt;RuboCop provides a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--auto-correct&lt;/code&gt; option that will attempt to clean up the violations for the supported cop. The feature is still experimental as of this post but worth starting off with. It’s easy to run the command and run a quick &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff&lt;/code&gt; to make sure that the new changes are valid and of course running your test suite to make sure there aren’t bugs. This is another reason why its much better to commit refactors and code cleanups into their own isolated commits.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;RuboCop makes it a lot easier to have newer engineers onboard to a Ruby project by leveraging consistent coding styles and enforcing new commits to adhere to them. For new or old projects, RuboCop can easily be part of the workflow to keep the code quality high and remove the burden of reviewing coding styles within the code review process. I hope that at this point it should clear that onboarding RuboCop is very straight forward.&lt;/p&gt;

&lt;p&gt;To learn more about the RuboCop command line flags, check out the &lt;a href=&quot;https://docs.rubocop.org/rubocop/usage/basic_usage.html#&quot;&gt;official docs&lt;/a&gt;. RuboCop uses the rules defined by the &lt;a href=&quot;https://rubystyle.guide/&quot;&gt;official ruby style guide&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Sun, 21 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/06/21/adding-rubocop-to-legacy-projects/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/06/21/adding-rubocop-to-legacy-projects/</guid>
        
        
      </item>
    
      <item>
        <title>Interesting Tech Podcasts - Part 1</title>
        <description>&lt;p&gt;These days I find myself listening to a variety of podcasts while working from home and doing random chores. I wanted to share the podcasts in the software field that I currently enjoy and have enjoyed over the past few years.&lt;/p&gt;

&lt;h2 id=&quot;podcast-apps&quot;&gt;Podcast Apps&lt;/h2&gt;

&lt;p&gt;You can use any app, your browser, or even just download the audio files to listen to podcasts. You don’t need anything fancy. I do have to call out my favorite podcast app however. I have been a long time user and fan of &lt;a href=&quot;https://podcastaddict.com/&quot;&gt;Podcast Addict&lt;/a&gt;. This is a great option with a lot of functionality on top of just listening to podcast. It supports discovery, automatically downloading episodes in your feed, and custom playlists. It keeps track of the episodes you have listened to and provides offline backups too. The only drawback is that this is an Android only app.&lt;/p&gt;

&lt;h2 id=&quot;1-ruby-on-rails-podcast&quot;&gt;1. Ruby on Rails Podcast&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href=&quot;https://5by5.tv/rubyonrails&quot;&gt;Ruby on Rails Podcast&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Ruby on Rails Podcast is hosted by &lt;a href=&quot;https://twitter.com/BrittJMartin&quot;&gt;Brittany Martin&lt;/a&gt; who invites a guest each week to discuss topics related to Ruby on Rails. The topics range from discussions about the Ruby ecosystem, Ruby on Rails, open source work, and stories about individual developers in the field. This is a great podcast to listen to that is not super technical and instead focuses more on the engineers and industry. This podcast has an easy entry bar for listening in.&lt;/p&gt;

&lt;h4 id=&quot;favorite-episodes&quot;&gt;Favorite Episodes&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;https://5by5.tv/rubyonrails/287&quot;&gt;287: Recruitment on Rails with Brian Mariani&lt;/a&gt; - Interesting episode from the perspective of a company the places Rails engineers. Brian from Mirror Placement, goes over how the company started, what the experience is like placing engineers, and what engineers can expect from the process. This was the most listened to episode for this podcast in 2019.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://5by5.tv/rubyonrails/306&quot;&gt;306: Ask For The Job with Brian Mariani (Part II)&lt;/a&gt; - This is the second episode that follows up and dives more into the actual recruiting process and provides helpful tips for engineers going through the process or interested in started the placement process.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://5by5.tv/rubyonrails/283&quot;&gt;283: Kill All Mutants with Dave Aronson&lt;/a&gt; - Very interesting podcast to listen to about mutation based testing. This is a radically different testing approach that performs bytecode manipulation during runtime to validate that your tests do fail on the right behaviour and that the tests themselves are testing the right things. Mutation testing can be considered a way of testing on tests. It validates whether we have gaps in the actual testing scenarios and makes sure that what are in actually testing is meaningful.&lt;/p&gt;

&lt;h2 id=&quot;2-the-ruby-blend&quot;&gt;2. The Ruby Blend&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href=&quot;https://www.therubyblend.com/&quot;&gt;The Ruby Blend Podcast&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This podcast is a relatively new one but already has a decent range of episodes. The podcast has a collection of interviews and discussions amongst ruby engineers in the field. The discussions are more technical but still very approachable regardless of experience. The podcast is ruby focused but still takes time to cover what its like from a personal perspective of being a Rails engineer.&lt;/p&gt;

&lt;h4 id=&quot;favorite-episodes-1&quot;&gt;Favorite Episodes&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;https://www.therubyblend.com/6&quot;&gt;Episode 6: Working From Home&lt;/a&gt; - With COVID-19 forcing most tech companies to quickly adopt a work from home policy, this episode provides some great insights into how engineers are handling the sudden transition. This is great episode to listen to if you have been working from home for the first time or are interesting in hearing what other’s experiences have been so far. There are several suggestions that the hosts discuss that will make sure that your experience is a positive one.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.therubyblend.com/8&quot;&gt;Episode 8: Tests and Webpacker&lt;/a&gt; - Testing is a common theme in the ruby community. This episode covers some interesting points in testing along with webpacker adoption into Rails. The hosts go into detail about what their experiences so far have been and how they approach testing legacy Rails applications. The hosts also talk a bit more about how working from home has been going, which builds a little bit on top of episode 6, which was an episode dedicated to that topic.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.therubyblend.com/9&quot;&gt;Episode 9: ViewComponent at GitHub with Joel Hawksley&lt;/a&gt; - ViewComponent extends functionality when building views. This was initially designed to be integrated into Rails but ended up being an optional drop in. The library allows for using ruby objects to generate views. This allows for creating better tests again the generated views. The library was created by Github and is used internally by them. If you are interested in seeing some interesting changes to how views could be generated in Rails and better testing against them, check this episode out. Joel Hawksley is the maintainer and goes into details on what inspired its creation, why it did not get merged into the Rails 6 code, and what he believes to be the future of this gem.&lt;/p&gt;

&lt;h2 id=&quot;3-ruby-rogues&quot;&gt;3. Ruby Rogues&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href=&quot;https://devchat.tv/podcasts/ruby-rogues/&quot;&gt;Ruby Rogues&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This podcast is part of the devchat.tv network which has a large collection of podcasts. Ruby rogues focuses on Ruby and Ruby on Rails but occasionally brings in guests from other stacks. This is a great podcast because it has so many episodes (approaching 500 at the time of this post). The podcast has a core panel with a few rotating hosts. Recently the podcast has been diving into Rails 6 and exploring javascript.&lt;/p&gt;

&lt;h4 id=&quot;favorite-episodes-2&quot;&gt;Favorite Episodes&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;https://devchat.tv/ruby-rogues/rr-446-development-environments/&quot;&gt;RR 446: Development Environments&lt;/a&gt; - Everyone has their own preference for local development regardless of tech stacks. I enjoyed this episode because its always great to see if there are other tools and setups that others are using that might make you more effecient. The hosts go over what they use locally, why they use it, and what works or doesn’t work with their setup. Its a great episode to see what other rubyists are using for local development. Another good episode on this topic is &lt;a href=&quot;https://devchat.tv/ruby-rogues/rr-389-developer-environment-with-the-panelists/&quot;&gt;RR 389: Developer Environment with the Panelists&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://devchat.tv/ruby-rogues/rr-434-surviving-webpack-with-ross-kaffenberger/&quot;&gt;RR 434: Surviving Webpack with Ross Kaffenberger&lt;/a&gt; - This is the episode that convinced me to take a look at using webpack, vue, and Rails 6. Ross goes into great detail on what his experience was adopting modern javascript and webpack into Rails along with the entire process of upgrading Rails 6. This is an excellent episode to listen in on if you are curious on what that process looks like, and some great things to watch out for as well. I ended up listening to this one several times.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://devchat.tv/ruby-rogues/rr-388-rubocop-and-code-linting-with-bozhidar-batsov/&quot;&gt;RR 388: RubyoCop and Code Linting with Bozhidar Batsov&lt;/a&gt; - The ruby community heavily invests in a testing culture and keeping readability in mind. The most popular code linting tool for ruby seems to be RuboCop. The author of the library, Bozhidar Batsov, is invited to discuss what inspired him to create it and what his experience is being the lead developer for it. Highly recommend listening into this one to learn more about the history of RuboCop and get an idea of its primary goals.&lt;/p&gt;

&lt;h2 id=&quot;4-developer-tea&quot;&gt;4. Developer Tea&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href=&quot;https://spec.fm/podcasts/developer-tea&quot;&gt;Developer Tea&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Developer Tea is a podcast that covers what its like being a software engineer from both a social and emotional point of view. The host of the podcast, &lt;a href=&quot;https://twitter.com/jcutrell&quot;&gt;Jonathan Cutrell&lt;/a&gt; hosts this podcast and provides small inspirations in each episode. The purpose of the podcast is to help software engineers that are mindful about growing their career by providing tips and suggestions that will help that goal. The episodes themselves are lightweight and usually only last about 10 minutes, which is easy to fit into your tea break :)&lt;/p&gt;

&lt;h4 id=&quot;favorite-episodes-3&quot;&gt;Favorite Episodes&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;https://spec.fm/podcasts/developer-tea/320284&quot;&gt;3 Ways to be a Better PR Author&lt;/a&gt; - This episode goes over some amazing tips and a change in thinking to create pull requests. This one is a great listen and the biggest takeaway is to step away from just creating pull requests to becoming a reviewer of your own code. Many people, myself included, initially either are defensive about the code we write or create the pull requests only to see that it takes a while to get reviewed. These can all be addressed by changing your mindset into becoming a reviewer of your own code so you become part of the process as well as changing exactly how to create the pull requests to get them processed faster.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://spec.fm/podcasts/developer-tea/320198&quot;&gt;4 Ways to be a Better PR Reviewer&lt;/a&gt; - This episode goes hand in hand with the one above. Everyone creates pull requests but everyone also reviews pull requests. In your career you will review many more pull requests than you will create them. This episode explains how changing the way you approach code reviews will also in turn change the way you create your own pull requests and have them processed.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://spec.fm/podcasts/developer-tea/312635&quot;&gt;Meetings can Trick Your Emotions&lt;/a&gt; - Most software engineers have at least some recurring meetings along with meetings that are scheduled on an as needed basis. Meetings are very different from coding or just working within your team. Meetings become a social activity where there are many different perspectives, backgrounds, and levels of power. This episode dives into how to make sure that meetings are useful, productive, and don’t leave in a false sense of positivity.&lt;/p&gt;
</description>
        <pubDate>Sat, 20 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/06/20/interesting-podcasts/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/06/20/interesting-podcasts/</guid>
        
        
      </item>
    
      <item>
        <title>[Rails 6 Series] Configuring Vue and Webpack</title>
        <description>&lt;h3 class=&quot;no_toc&quot;&gt;
Posts in Series
&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/01/starting-rails-6-vue-on-aws/&quot;&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;Rails 6 Series - Setting up AWS resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/10/deploying-to-aws/&quot;&gt;Rails 6 Series - Deploying to AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;overview&quot;&gt;Overview&lt;/h1&gt;

&lt;p&gt;We have successfully deployed the basic Rails 6 sample application to AWS. All that remains now is to configure both Vue and Webpack for production use. In local development we can serve our packs through &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bin/webpack-dev-server&lt;/code&gt; but in production we need everything pre-compiled so that Nginx can serve the content in the packs directory.&lt;/p&gt;

&lt;p&gt;In this post we will go over configuring webpack so that we can import Vue globally in each pack as required. We will configure Vue and some basic Vue plugins and also make it available in all packs as needed. Lastly we will go over how webpack differs from the traditional Rails Asset Pipeline.&lt;/p&gt;

&lt;h2 id=&quot;webpack-configuration&quot;&gt;Webpack Configuration&lt;/h2&gt;

&lt;p&gt;In the root directory of our application we have the webpack configuration files by stage. You can find these under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config/webpack/*.js&lt;/code&gt;. The main file we need to update is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;environment.js&lt;/code&gt;. This file imports webpack, vue, and any other top level library we need.&lt;/p&gt;

&lt;p&gt;When we created our initial Rails structure, we told rails that we will be using webpack and vue via the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--webpack=vue&lt;/code&gt; flag in the cli. By default this will create the following content in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;environment.js&lt;/code&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/f1aa077b35c187d113f7ecd1e41a9d4c.js?file=default_environment.js&quot;&gt; &lt;/script&gt;

&lt;p&gt;To properly configure Vue for production, lets make sure that Webpack is configured to load the right payload for it. Create a new file named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vue_config.js&lt;/code&gt; within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config/webpack&lt;/code&gt; directory and copy the contents below into it.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/f1aa077b35c187d113f7ecd1e41a9d4c.js?file=vue_config.js&quot;&gt; &lt;/script&gt;

&lt;p&gt;After that, update the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;environment.js&lt;/code&gt; file from earlier to load our custom vue config and override the default development payload for vue. This will configure it to load correctly in production.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/f1aa077b35c187d113f7ecd1e41a9d4c.js?file=environment.js&quot;&gt; &lt;/script&gt;

&lt;h2 id=&quot;packagejson&quot;&gt;Package.json&lt;/h2&gt;

&lt;p&gt;With webpack configured, we can sanity check that our packages are up to date and included. If any are missing or if you need additional packages, add them to your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt; file in the root directory of our application.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/f1aa077b35c187d113f7ecd1e41a9d4c.js?file=package.json&quot;&gt; &lt;/script&gt;

&lt;h2 id=&quot;vue-configuration&quot;&gt;Vue Configuration&lt;/h2&gt;

&lt;p&gt;The final bit is to load in Vue into our application pack found in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app/javascript/packs/application.js&lt;/code&gt;. We will import both Vue and BootstrapVue. If you do not want to use BootstrapVue, feel free to import just Vue. Since Rails uses Turbolinks, there is also a vue adapter for it. We will be importing all 3. Only Vue is absolutely required.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/f1aa077b35c187d113f7ecd1e41a9d4c.js?file=application.js&quot;&gt; &lt;/script&gt;

&lt;h2 id=&quot;migrating-away-from-asset-pipeline&quot;&gt;Migrating away from Asset Pipeline&lt;/h2&gt;

&lt;p&gt;Using webpack lets us migrate out of the Asset Pipeline for javascript files. This is a bit of a shift in thinking if you have been using Rails for a while. The key difference is that you can write your javascript files within &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app/javascript/&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app/assets&lt;/code&gt;. The way to model this approach is that you build your directory structure within &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app/javascript/*&lt;/code&gt; and use require statements to cross load all your local dependencies. Everything here will be compiled and minified by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;webpack&lt;/code&gt; during application build.&lt;/p&gt;

&lt;p&gt;Intead of using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;javascript_include_tag&lt;/code&gt;, use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;javascript_pack_tag&lt;/code&gt; to load files inside of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app/javascript/packs&lt;/code&gt; folder. Each pack can be considered a mini application bundle. You can generate as many as you need or bundle it all into 1 pack.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;At this point everything has been setup for both local development and pushing to production. Webpack will load the correct version of Vue and Vue has been configured to pull in both Turbolinks and BootstrapVue. With this, we can start building out our application and creating as many packs as we need. Webpack will handle the compilation, minification, and tree-shaking for us!&lt;/p&gt;

&lt;p&gt;To learn more about Webpack take a look at the &lt;a href=&quot;https://webpack.js.org/concepts/&quot;&gt;concepts page&lt;/a&gt; at the official docs. This was sorely missing in the Rails Guides and helped me understand how webpack works when learning how to use webpack &lt;strong&gt;with&lt;/strong&gt; rails.&lt;/p&gt;

&lt;h4 id=&quot;rails-6-series&quot;&gt;Rails 6 Series&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/01/starting-rails-6-vue-on-aws/&quot;&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;Rails 6 Series - Setting up AWS resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/10/deploying-to-aws/&quot;&gt;Rails 6 Series - Deploying to AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 15 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/06/15/configuring-webpack-and-vue/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/06/15/configuring-webpack-and-vue/</guid>
        
        
      </item>
    
      <item>
        <title>[Rails 6 Series] Deploying to AWS</title>
        <description>&lt;h3 class=&quot;no_toc&quot;&gt;
Posts in Series
&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/01/starting-rails-6-vue-on-aws/&quot;&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;Rails 6 Series - Setting up AWS resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Rails 6 Series - Deploying to AWS&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/15/configuring-webpack-and-vue/&quot;&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;overview&quot;&gt;Overview&lt;/h1&gt;

&lt;p&gt;Now that we have our empty Rails project and created our Elastic Beanstalk environment, we are ready to add our configuration scripts so that we may deploy our application.&lt;/p&gt;

&lt;h2 id=&quot;beanstalk-platform-hooks&quot;&gt;Beanstalk Platform Hooks&lt;/h2&gt;

&lt;p&gt;The latest beanstalk environment uses Amazon Linux 2 which no longer supports beanstalk extensions (ebextensions). Instead it introduces &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Platform Hooks&lt;/code&gt;. This allows us to create configuration files and setup scripts that will run on the EC2 hosts during the various build and deployment stages. AWS has a nice graph that shows the new platform hook process.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/images/platforms-linux-extend-order.png&quot; alt=&quot;Beanstalk Platform Hooks Lifecycle&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;nginx-setup&quot;&gt;Nginx Setup&lt;/h3&gt;

&lt;p&gt;By default webpack generated content will not be served by Nginx. We need to add an Nginx config file to our beanstalk environment that will add the packs directory to Nginx. Elastic Beanstalk has a default nginx.conf file that loads all files within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conf.d/elasticbeanstalk&lt;/code&gt; folder. With Amazon Linux 2, we will leverage &lt;a href=&quot;https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html&quot;&gt;platform hooks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Create a new folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.platform&lt;/code&gt; in the root directory of our Rails application. Within there, create a file in the following path &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.platform/nginx/conf.d/elasticbeanstalk/webpack.conf&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# .platform/nginx/conf.d/elasticbeanstalk/webpack.conf
&lt;/span&gt;
location /packs &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;alias&lt;/span&gt; /var/app/current/public/packs&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    gzip_static on&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;gzip &lt;/span&gt;on&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    expires max&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    add_header Cache-Control public&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With the above, whenever we deploy our application or an instance gets replaced, nginx will always automatically be configured to serve everything within the packs directory.&lt;/p&gt;

&lt;h3 id=&quot;yarn-and-node-setup&quot;&gt;Yarn and Node Setup&lt;/h3&gt;

&lt;p&gt;As we did with the nginx configuration, we can install &lt;a href=&quot;https://yarnpkg.com/&quot;&gt;Yarn&lt;/a&gt; and &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;Node JS&lt;/a&gt; automatically onto our EC2 hosts when beanstalk deploys the application. Both are requirements for using webpack and we will use platform hooks for this. Create a new file within the prebuild hooks folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.platform/hooks/prebuild/01_install_yarn.sh&lt;/code&gt;. Make sure that this file has executable permissions &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod +x 01_install_yarn.sh&lt;/code&gt;.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/e901ed51858e06fa1526149671fedbca.js&quot;&gt; &lt;/script&gt;

&lt;h2 id=&quot;database-setup&quot;&gt;Database Setup&lt;/h2&gt;

&lt;p&gt;The next step is to configure our application to connect to our database in production. For this we will use both environment variables and Rails encrypted credentials.&lt;/p&gt;

&lt;h4 id=&quot;rails-6-master-key&quot;&gt;Rails 6 Master Key&lt;/h4&gt;

&lt;p&gt;We need to let our beanstalk application have access to the master key to decrypt the credentials. In order to do this we need to go into our application and fetch the encryption key.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;config
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;master.key
&amp;lt;copy this key&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As an aside, &lt;strong&gt;do not commit the config/master.key&lt;/strong&gt; file!! It has already been added to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.gitignore&lt;/code&gt; file when we ran &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails new&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;rds-connection-details&quot;&gt;RDS Connection Details&lt;/h4&gt;

&lt;p&gt;The next piece of information we need is our database name and database endpoint. Log into the AWS console and go to the RDS page. Select your application database where you will find the connection details under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Connectivity &amp;amp; security&lt;/code&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_10_deploying_to_aws/rds_endpoint.png&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;beanstalk-environment-variables&quot;&gt;Beanstalk Environment Variables&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;From the AWS console, head over to the beanstalk configuration page for your environment&lt;/li&gt;
  &lt;li&gt;Go to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Software&lt;/code&gt; section configuration and hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Create 3 new environment variables with the values we fetched earlier
    &lt;ol&gt;
      &lt;li&gt;Database Name&lt;/li&gt;
      &lt;li&gt;Database Endpoint&lt;/li&gt;
      &lt;li&gt;Master Key&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_10_deploying_to_aws/environment_variables.png&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;encrypted-credentials&quot;&gt;Encrypted Credentials&lt;/h4&gt;

&lt;p&gt;To store the username and password for connecting to our RDS instance, we will be using Rails encrypted credentials. The file is located in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config/credentials.yml.enc&lt;/code&gt;. We will not be able to open the file without decrypting it first, for which there is a rails command available.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;EDITOR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;vim&quot;&lt;/span&gt; rails credentials:edit&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This will open up the file for editing and saving. The format of this file is just simple YAML. While we have this open we will add a few things to it.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/5f453183bab45c7b45262283fb9ed61d.js?file=credentials.yml&quot;&gt; &lt;/script&gt;

&lt;p&gt;Saving this file will encrypt it before saving it back to disk. WIth that in place we need to make a few adjustments. Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config/environments/production.rb&lt;/code&gt; and set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config.require_master_key = true&lt;/code&gt; to make sure that the application checks for the master key during start up.&lt;/p&gt;

&lt;p&gt;After that is done, accessing the values is super simple. From anywhere in our application we can access the yaml structure.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;production&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;database_username&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; will return username&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;databaseyml&quot;&gt;Database.yml&lt;/h4&gt;

&lt;p&gt;With our connection details entered in both the environment variables and encrypted credentials, the last step is to update our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config/database.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/5f453183bab45c7b45262283fb9ed61d.js?file=database.yml&quot;&gt; &lt;/script&gt;

&lt;h2 id=&quot;deply-to-aws&quot;&gt;Deply to AWS&lt;/h2&gt;

&lt;p&gt;In the &lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;previous post&lt;/a&gt; we created our necessary AWS resources and in this post we created our initialization scripts. The last step we need to do is hook it to beanstalk and deploy it! Make sure you have committed all the files we created and edited locally.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Ensure that you have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eb&lt;/code&gt; installed so that we can initialize our application&lt;/li&gt;
  &lt;li&gt;From your project root run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eb init&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;The command will ask you which region you want to use, select the one we created our beanstalk environment&lt;/li&gt;
  &lt;li&gt;Next select which platform to use. Select the one that has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ruby 2.7 (Puma)&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;no&lt;/code&gt; when it prompts for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CodeCommit&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eb status&lt;/code&gt; to make sure everything is hooked up, you should see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Status: Ready&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eb deploy&lt;/code&gt; and wait for it to deploy to your environment before visiting the page!&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;With the past few posts we installed our prerequisites, setup our AWS resources and beanstalk environment, and lastly configured our application to install our dependencies within EC2 and serve webpack content through Nginx. At this point your application should be up and running on AWS managed completely through beanstalk.&lt;/p&gt;

&lt;p&gt;Any further changes to your application can be done locally, saved via git, and deployed via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eb deploy&lt;/code&gt;. This will allow fast development cadence and remove the operational burden of maintaining a stack on AWS!&lt;/p&gt;

&lt;p&gt;The next post will go over actually using Vue with webpack now that our stack is deployable. We will import Vue, configure it, and lastly configure webpack so that we can create multiple packs&lt;/p&gt;

&lt;p&gt;The next post will go over actually using Vue with webpack now that our application can be deployed. We will import Vue, configure both Vue and Webpack, and learn how to migrate from using the Asset Pipeline to creating packs instead.&lt;/p&gt;

&lt;h4 id=&quot;rails-6-series&quot;&gt;Rails 6 Series&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/01/starting-rails-6-vue-on-aws/&quot;&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;Rails 6 Series - Setting up AWS resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Rails 6 Series - Deploying to AWS&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/15/configuring-webpack-and-vue/&quot;&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 10 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/06/10/deploying-to-aws/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/06/10/deploying-to-aws/</guid>
        
        
      </item>
    
      <item>
        <title>[Rails 6 Series] Setting up AWS resources</title>
        <description>&lt;h3 class=&quot;no_toc&quot;&gt;
Posts in Series
&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/01/starting-rails-6-vue-on-aws/&quot;&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Rails 6 Series - Setting up AWS resources&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/10/deploying-to-aws/&quot;&gt;Rails 6 Series - Deploying to AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/15/configuring-webpack-and-vue/&quot;&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;overview&quot;&gt;Overview&lt;/h1&gt;

&lt;p&gt;To begin hosting our application in AWS we will first go into the Console and set up our environment configuration on AWS Elastic Beanstalk manually. Beanstalk
can create your RDS instance as well however we will be creating our separately. This is because resetting or tearing down your beanstalk stack also deletes the
RDS instance which may not always be desired. This post will go through the Console but everything can be done via the CLI as well. Since this is a one time setup, I have opted to just use the Console directly.&lt;/p&gt;

&lt;p&gt;Let’s go into the &lt;a href=&quot;https://console.aws.amazon.com&quot;&gt;Console&lt;/a&gt; and log in. After that select the desired region to use, I will be using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;us-west-2&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;vpc&quot;&gt;VPC&lt;/h2&gt;

&lt;p&gt;For our beanstalk application, we will create our own VPC instead of using the default VPC. This is not strictly required but does make things cleaner down the road having the application separated into its own resources.
Doing so will not incur any additional cost either!&lt;/p&gt;

&lt;p&gt;From the main console page, head over to the VPC page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/vpc.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Create a VPC, you can name it whatever you want. I chose my project name for my VPC name. For the CIDR block we do not need to restrict ourselves so we will create a large VPC with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/16&lt;/code&gt; block.
If you feel that is excessive feel free to reduce it to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/18&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/20&lt;/code&gt;. We are also not using Dedicated tenancy so we will stick to Default.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/select_vpc_button.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_vpc.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The next thing to ensure is that DNS resolution is enabled within your VPC. If this is not toggled then you will be unable to use an ELB with your EC2 targets. Simply go to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit DNS resolution&lt;/code&gt; and ensure that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DNS resolution&lt;/code&gt; checkbox is enabled.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/edit_dns_resolution.png&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/enable_dns_resolution.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;subnet&quot;&gt;Subnet&lt;/h3&gt;

&lt;p&gt;Best practice is to create at least 2 subnets so that you can have hosts in 2 different availability zones. This increases the availability story of your application. Let’s go ahead and create 2 subnet’s in our new VPC (or default VPC if you decided not to create a new VPC). Head over to the VPC overview page and select the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Subnets&lt;/code&gt; link from the left navbar. Hit the Create Subnet button at the top of the page.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;First select the VPC you want to create the subnet&lt;/li&gt;
  &lt;li&gt;Pick an Availability Zone (make sure each subnet has a different one)&lt;/li&gt;
  &lt;li&gt;Create your CIDR range so that its a subset of the main VPC. For example use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;172.30.1.0/24&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;172.30.2.0/24&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/subnet_overview.png&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_subnet.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To make life a bit easier let’s make sure to enable public ip’s on our instances. We will be applying a security group so that only the ELB can talk to the instances but this will allow us to expand that later if need be.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Select each subnet on the Subnets page for our VPC&lt;/li&gt;
  &lt;li&gt;Select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Actions&lt;/code&gt; at the top and navigate to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Modify auto-assign IP settings&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Ensure that the checkbox is enabled&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/enable_public_ipv4_address.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;internet-gateway&quot;&gt;Internet Gateway&lt;/h3&gt;

&lt;p&gt;In order to route traffic to your ELB and ultimately your application, your VPC must be able to have ingress/egress from the internet. On the same VPC page, select the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Internet Gateways&lt;/code&gt; link and create a new Internet Gateway.
This will allow us to attach it to the VPC. Once the Internet Gateway is created, from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Actions&lt;/code&gt; dropdown attach it to the desired VPC.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/internet_gateway_overview.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;route-table&quot;&gt;Route Table&lt;/h3&gt;

&lt;p&gt;The next step is to make sure that your route table can route traffic correctly between resources inside your VPC and from the internet through your internet gateway.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;From the VPC page, select the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Route Tables&lt;/code&gt; tab&lt;/li&gt;
  &lt;li&gt;Select the route table for your VPC&lt;/li&gt;
  &lt;li&gt;Under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Actions&lt;/code&gt; select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit Routes&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;In the routes page, make sure you have your VPC ip CIDR map to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;local&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0.0.0/0&lt;/code&gt; route to your internet gateway&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/edit_routes.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/edit_routes_internet_gateway.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;ec2&quot;&gt;EC2&lt;/h2&gt;

&lt;p&gt;We will now setup our EC2 resources which will just consist of a new security group for our application. Go back to the console and head over to the EC2 page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/management_console_ec2_dropdown.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;security-group&quot;&gt;Security Group&lt;/h3&gt;

&lt;p&gt;We need 2 security groups for our application. The first one will be for our ELB/targets and the second will be for our RDS instance.&lt;/p&gt;

&lt;h4 id=&quot;application-security-group&quot;&gt;Application Security Group&lt;/h4&gt;

&lt;p&gt;From the left bar select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Security Groups&lt;/code&gt; which will be under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Network &amp;amp; Security&lt;/code&gt; heading. After that hit the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Create security group&lt;/code&gt; button.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;You can name the security group anything, I chose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app_name-web&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Select your VPC&lt;/li&gt;
  &lt;li&gt;Outbound rules can be simple: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;All Traffic&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0.0.0/0&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Inbound rules
    &lt;ol&gt;
      &lt;li&gt;Make sure to lock it to HTTP and HTTPS traffic only&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_security_group_button.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_security_group_inbound_rules.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;rds-security-group&quot;&gt;RDS Security Group&lt;/h4&gt;

&lt;p&gt;Create another security group following the same steps as above with a few adjustments.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;You can name the security group anything, I chose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app_name-db&lt;/code&gt; to distinguish that this is for RDS&lt;/li&gt;
  &lt;li&gt;Select your VPC&lt;/li&gt;
  &lt;li&gt;Outbound rules can be simple: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;All Traffic&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0.0.0/0&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Inbound rules
    &lt;ol&gt;
      &lt;li&gt;Use Protocol &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TCP&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Enter the port that you will use for the RDS instance, default Postgres port is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5432&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Source should be the security group id from our application security group, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app_name-web&lt;/code&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This will lock down the RDS instance to just the instances within our security group for the application.&lt;/p&gt;

&lt;h2 id=&quot;rds&quot;&gt;RDS&lt;/h2&gt;

&lt;p&gt;The last thing we need to setup before we create our Elastic Beanstalk environment is the database. RDS provides a free tier for most of the databases offered. From the main console page, go to the RDS page.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;From the RDS page, hit the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Create database&lt;/code&gt; button&lt;/li&gt;
  &lt;li&gt;Select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Standard Create&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Select desired DB type, I went with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PostgreSQL&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Make sure to select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Free Tier&lt;/code&gt; under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Templates&lt;/code&gt; unless you are creating an actual Production stack&lt;/li&gt;
  &lt;li&gt;Under the Settings section, pick your database name, master username and password&lt;/li&gt;
  &lt;li&gt;Leave &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DB instance size&lt;/code&gt; as default&lt;/li&gt;
  &lt;li&gt;Leave &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Storage&lt;/code&gt; as default&lt;/li&gt;
  &lt;li&gt;In the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Connectivity&lt;/code&gt; section make sure to select your VPC (not the default unless you want to)
    &lt;ol&gt;
      &lt;li&gt;Expand the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Additional connectivity configration&lt;/code&gt; area&lt;/li&gt;
      &lt;li&gt;Make the DB publicly accessible (note: this is a quality of life thing if we want to connect from our local machine to the DB, it will be locked down via the security group)&lt;/li&gt;
      &lt;li&gt;Remove the Default VPC security group and instead select the RDS security group we created earlier (ie, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app_name-db&lt;/code&gt;)&lt;/li&gt;
      &lt;li&gt;Pick any availability zone, ideally one of the ones that we selected for the subnets earlier&lt;/li&gt;
      &lt;li&gt;Pick a database port, or use the default one for Postgre (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5432&lt;/code&gt;)&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Scroll to the bottom and hit the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Create database&lt;/code&gt; button&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/management_console_rds_dropdown.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_rds.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_rds_step_1.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_rds_step_2.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;elastic-beanstalk&quot;&gt;Elastic Beanstalk&lt;/h2&gt;

&lt;p&gt;Now we get to the final part of our AWS setup, which is to create our Elastic Beanstalk environment and application. All the pre-work we did up to the point will make the configuration very straight forward.&lt;/p&gt;

&lt;h3 id=&quot;environment--application&quot;&gt;Environment &amp;amp; Application&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Elastic Beanstalk page&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;From the left navbar, select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Environments&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Create a new Environment
    &lt;ol&gt;
      &lt;li&gt;This will also create a new application at the same time&lt;/li&gt;
      &lt;li&gt;Create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Web server environment&lt;/code&gt; and hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Select&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Enter an application name and description&lt;/li&gt;
      &lt;li&gt;Enter an environment name and let EB generate your domain&lt;/li&gt;
      &lt;li&gt;Select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Managed platform&lt;/code&gt; and use Platform: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ruby&lt;/code&gt;, Platform branch: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ruby 2.7 running on 64bit Amazon Linux 2&lt;/code&gt;, and Platform version: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;3.0.2&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sample application&lt;/code&gt; for now, we will push our code eventually&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Hit the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Create environment button&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;lt;img src=”/images/2020_06_02_setting_up_aws/management_console_eb_dropdown.png”class=”center-image”  /&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_new_eb_environment.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_new_eb_step_1.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_new_eb_step_2.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/create_new_eb_step_3.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For the next sections, simply go to your application in beanstalk and click on the environment name. This will take you to a page that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/eb_configuration.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/eb_configuration_overview.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;beanstalk-configuration---software&quot;&gt;Beanstalk Configuration - Software&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Software section of the EB configuration section&lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Environment Properties&lt;/code&gt; section make sure the following environment variables are set
    &lt;ol&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BUNDLER_DEPLOYMENT_MODE = true&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BUNDLE_WITHOUT=&lt;/code&gt; (blank value)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NODE_ENV = production&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RACK_ENV = production&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RAILS_ENV = production&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RAILS_SKIP_ASSET_COMPILATION = false&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RAILS_SKIP_MIGRATIONS = false&lt;/code&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/eb_configuration_software.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;beanstalk-configuration---instances&quot;&gt;Beanstalk Configuration - Instances&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Instances section of the EB configuration section&lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EC2 security groups&lt;/code&gt; section select the web security group we created earlier along with the default EB security group that is already checked
    &lt;ol&gt;
      &lt;li&gt;The security group that should be added is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app_name-web&lt;/code&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Leave everything else as default values&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/eb_configuration_instances.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;beanstalk-configuration---capacity&quot;&gt;Beanstalk Configuration - Capacity&lt;/h3&gt;

&lt;p&gt;This step is &lt;strong&gt;completely optional&lt;/strong&gt; and you can skip this if you do &lt;strong&gt;not&lt;/strong&gt; want to use an ELB.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Capacity section of the EB configuration section&lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Auto Scaling Group&lt;/code&gt; section
    &lt;ol&gt;
      &lt;li&gt;Swap environment type to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Load balanced&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;[Optional] Set max instances to desired max count if scale out desired&lt;/li&gt;
      &lt;li&gt;[Optional] Set Instance type to a larger host depending on your application needs, this will incur charges!&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scaling triggers&lt;/code&gt; section
    &lt;ol&gt;
      &lt;li&gt;Update the scaling triggers to what your application needs or just leave it to the default values for now, we can change this at any time&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/eb_configuration_capacity.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;beanstalk-configuration---load-balancer-elb&quot;&gt;Beanstalk Configuration - Load Balancer (ELB)&lt;/h3&gt;

&lt;p&gt;This step is &lt;strong&gt;completely optional&lt;/strong&gt; and you can skip this if you do &lt;strong&gt;not&lt;/strong&gt; want to use an ELB.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Load Balancer section of the EB configuration section&lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Listeners&lt;/code&gt; section
    &lt;ol&gt;
      &lt;li&gt;Make sure you have at least an HTTP listener&lt;/li&gt;
      &lt;li&gt;Add in your HTTPS listener with your cert (you can use AWS ACM which will provision a free certificate)&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Not much is required, you can also leave everything as default to have an ALB with an HTTP listener by default&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;beanstalk-configuration---network&quot;&gt;Beanstalk Configuration - Network&lt;/h3&gt;

&lt;p&gt;This step is &lt;strong&gt;completely optional&lt;/strong&gt; and you can skip this if you do &lt;strong&gt;not&lt;/strong&gt; want to use an ELB.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Network section of the EB configuration section&lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Load balancer settings&lt;/code&gt; section
    &lt;ol&gt;
      &lt;li&gt;Make your ELB Public&lt;/li&gt;
      &lt;li&gt;Select the subnets created earlier&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Instance settings&lt;/code&gt; section
    &lt;ol&gt;
      &lt;li&gt;Make sure to enable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Public IP addreess&lt;/code&gt; on your instances so that the ELB will be able to send traffic to them&lt;/li&gt;
      &lt;li&gt;Enable all subnets here as well&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020_06_02_setting_up_aws/eb_configuration_network.png&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;Now our AWS stack is ready for us to deploy and iterate on top of! At this point we have created security groups, a VPC and subnets for it, configured the routing table and opened the VPC to the internet via an internet gateway, and lastly spun up an RDS database. With all of this and our elastic beanstalk environment, we can make changes and deploy our application with super ease, a simple call to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eb deploy&lt;/code&gt; will get us up and running. We will launch our application in the next post in this series.&lt;/p&gt;

&lt;p&gt;To check out the default application that elastic beanstalk has created for us, navigate to the endpoint that beanstalk provisioned to see the sample stack up and running.&lt;/p&gt;

&lt;h4 id=&quot;rails-6-series&quot;&gt;Rails 6 Series&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/01/starting-rails-6-vue-on-aws/&quot;&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Rails 6 Series - Setting up AWS resources&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/10/deploying-to-aws/&quot;&gt;Rails 6 Series - Deploying to AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/15/configuring-webpack-and-vue/&quot;&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 02 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/06/02/setting-up-aws/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/06/02/setting-up-aws/</guid>
        
        
      </item>
    
      <item>
        <title>[Rails 6 Series] Starting Rails 6 with Vue on AWS</title>
        <description>&lt;h3 class=&quot;no_toc&quot;&gt;
Posts in Series
&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;Rails 6 Series - Setting up AWS resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/10/deploying-to-aws/&quot;&gt;Rails 6 Series - Deploying to AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/15/configuring-webpack-and-vue/&quot;&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I recently started a personal project and wanted to try out Rails 6 with Vue (and Webpack). I was able to get this stack working locally with relative ease. However, when I attempted to push
this idea to production I was met with many roadblocks. My goal was to use AWS to host the project. AWS has migrated to using “Amazon Linux 2” which has resulted in a lot of
outdated tutorials and code snippets. Furthermore, I also found a lack of conscise and up to date documentation for pushing Rails 6 with Webpack to production.&lt;/p&gt;

&lt;p&gt;I will be documenting my journey on pushing my personal project to AWS through a series of posts to hopefully help with the lack of documentation. To kick the series off, I will note down
which resources I will be using:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/&quot;&gt;Ruby 2.7&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://edgeguides.rubyonrails.org/6_0_release_notes.html&quot;&gt;Rails 6&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/&quot;&gt;Vue.js&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://webpack.js.org/guides/&quot;&gt;Webpack&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://console.aws.amazon.com/&quot;&gt;AWS&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/Welcome.html&quot;&gt;EB (Elastic Beanstalk)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;RDS (Postgresql)&lt;/li&gt;
      &lt;li&gt;EC2 (VPC/Security Group setup)&lt;/li&gt;
      &lt;li&gt;[Optional] ELB (Elastic Load Balancing)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the most part we can get by using the free tier on AWS. However, because I will be using this to document my personal project some resources may not actually fall into the free tier. I will call these out as optional items or provide an alternative that is within the free tier.&lt;/p&gt;

&lt;h3 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h3&gt;

&lt;p&gt;For the purpose of this series, I will not go into the details on how to create an AWS account. If you do not have an account already I would highly advise just following the &lt;a href=&quot;https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/&quot;&gt;official guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;install-ruby&quot;&gt;Install Ruby&lt;/h3&gt;

&lt;p&gt;To install ruby locally there are several tools available that let you install multiple versions of ruby. We will use RVM.&lt;/p&gt;

&lt;p&gt;First install RVM: &lt;a href=&quot;https://rvm.io/rvm/install&quot;&gt;https://rvm.io/rvm/install&lt;/a&gt;. Once that is complete proceed with installing the latest ruby (2.7.1 at the time of this post).&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rvm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;ruby-2.7.1&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In case you have multiple versions of ruby installed, you can switch to using the one we just installed with the following command:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rvm use ruby-2.7.1&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You can see if you have other ruby versions installed as well with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rvm list&lt;/code&gt; and confirm which one is currently being used:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; rvm list
   ruby-2.4.0 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; x86_64 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
   ruby-2.4.3 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; x86_64 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; ruby-2.6.3 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; x86_64 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; ruby-2.7.1 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; x86_64 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# =&amp;gt; - current&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# =* - current &amp;amp;&amp;amp; default&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#  * - default&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;install-rails&quot;&gt;Install Rails&lt;/h3&gt;

&lt;p&gt;Installing rails should be fairly straight forward. Simply run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gem install rails&lt;/code&gt; and then you can call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails&lt;/code&gt; from your terminal.&lt;/p&gt;

&lt;p&gt;Confirm you have rails installed&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rails &lt;span class=&quot;nt&quot;&gt;--version&lt;/span&gt;
Rails 6.0.3&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;install-elastic-beanstalk&quot;&gt;Install Elastic Beanstalk&lt;/h3&gt;

&lt;p&gt;Elastic Beanstalk is a deployment orchestration engine provided by AWS. You can configure beanstalk to launch databases in RDS, spin up ELB’s, and launch the EC2 instances that will host your application. There are other options to perform this but for ease we will rely on AWS elastic beanstalk for the heavy lifting. The beanstalk binary is not part of the AWS SDK so we will have to install it separately. In order to get the CLI in your environment, AWS provides a nice &lt;a href=&quot;https://github.com/aws/aws-elastic-beanstalk-cli-setup&quot;&gt;automated installer&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;bootstrap-project&quot;&gt;Bootstrap Project&lt;/h3&gt;

&lt;p&gt;Now that we have installed the prerequisites, let’s go ahead and create the project in our local environment. We wil be calling the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails&lt;/code&gt; command and telling it to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue&lt;/code&gt; with webpack and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Postgres&lt;/code&gt; as our database. If you wish to either avoid RDS or use another database type, feel free. One option is to leverage &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sqlite&lt;/code&gt; but the catch is that this will run on the EC2 host itself. Having said that, we will be using the free tier with RDS.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rails new app_name &lt;span class=&quot;nt&quot;&gt;--webpack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;vue &lt;span class=&quot;nt&quot;&gt;--database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;postgresql
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;app_name
bundle &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;At this point we created our local environment and installed the necessary binaries. The next post will dive into setting up AWS resources including the beanstalk environment, RDS instance, and VPC/Security Groups.&lt;/p&gt;

&lt;h4 id=&quot;rails-6-series&quot;&gt;Rails 6 Series&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;Rails 6 Series - Starting Rails 6 with Vue on AWS&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/02/setting-up-aws/&quot;&gt;Rails 6 Series - Setting up AWS resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/10/deploying-to-aws/&quot;&gt;Rails 6 Series - Deploying to AWS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/2020/06/15/configuring-webpack-and-vue/&quot;&gt;Rails 6 Series - Configuring Vue and Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 01 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2020/06/01/starting-rails-6-vue-on-aws/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2020/06/01/starting-rails-6-vue-on-aws/</guid>
        
        
      </item>
    
      <item>
        <title>Github search api</title>
        <description>&lt;p&gt;I recently created the &lt;a href=&quot;https://github.com/zsyed91/pr_status&quot;&gt;pr_status gem&lt;/a&gt; to
be able to easily get the number of pull requests I opened in the current month.
The inspiration came from being able to track my progress to my commit of
&lt;a href=&quot;/2015/10/22/open-source-contribution/&quot;&gt;opening 2 pulls&lt;/a&gt;. I should hopefully sometime soon
be able to use this gem and officially keep track of my goal and progress each month.&lt;/p&gt;

&lt;p&gt;I found the documentation for the api a bit lacking as I was initially following
the url structure provided. Something like the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# did NOT work!&lt;/span&gt;
&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91+type:pr'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It turns out that the values are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;URI&lt;/code&gt; escaped and so using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; is not needed. A
simple space is sufficient. The full api documentation is available &lt;a href=&quot;https://developer.github.com/v3/search/#search-issues&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;find-issues-and-pull-requests-by-author&quot;&gt;Find issues and pull requests by author&lt;/h3&gt;

&lt;p&gt;This will return all issues and pull requests opened by the author.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;find-pull-requests-only&quot;&gt;Find pull requests only&lt;/h3&gt;

&lt;p&gt;This will return all pull requests opened by the author.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91 type:pr'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;find-pull-requests-opened-after-a-certain-date&quot;&gt;Find pull requests opened after a certain date&lt;/h3&gt;

&lt;p&gt;The date fields follow the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yyyy-mm-dd&lt;/code&gt; format. This is how to get all pull requests
opened by the author on or after January 1st, 2016.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91 type:pr created:&amp;gt;=2016-01-01'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In order to exclude the starting date simply change &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;=&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91 type:pr created:&amp;gt;2016-01-01'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In order to get all pull requests opened on a specific date remove the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;=&lt;/code&gt; qualifier.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91 type:pr created:2016-01-01'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;find-pull-requests-by-language&quot;&gt;Find pull requests by language&lt;/h3&gt;
&lt;p&gt;In order to get pull requests opened for a specific language for a certain user do the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;vi&quot;&gt;@octokit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;search_issues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'author:zsyed91 type:pr language:ruby'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;The gist of this post is just to show some examples on how to actually use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Octokit::Client&lt;/code&gt; api for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;search_issues&lt;/code&gt;.
As stated before, the full api options can be found &lt;a href=&quot;https://developer.github.com/v3/search/#search-issues&quot;&gt;here&lt;/a&gt;.
Keep in mind the api rate limit as of January 2016 is 10 requests per minute for unauthenticated requests and 30 requests per minute
for authenticated requests.&lt;/p&gt;
</description>
        <pubDate>Sun, 31 Jan 2016 00:00:00 +0000</pubDate>
        <link>https://www.zshawnsyed.com/2016/01/31/github-search-api/</link>
        <guid isPermaLink="true">https://www.zshawnsyed.com/2016/01/31/github-search-api/</guid>
        
        
      </item>
    
  </channel>
</rss>
