<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adarsh.K.Kumar</title>
    <description>The latest articles on DEV Community by Adarsh.K.Kumar (@adarshkkumar).</description>
    <link>https://dev.to/adarshkkumar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F64140%2Fe72fb7dd-7469-4dd0-bd6f-6ef6bb2aff81.jpg</url>
      <title>DEV Community: Adarsh.K.Kumar</title>
      <link>https://dev.to/adarshkkumar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adarshkkumar"/>
    <language>en</language>
    <item>
      <title>HTTP Status 401 vs 403</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Thu, 04 Apr 2019 16:27:21 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/http-status-401-vs-403-2c59</link>
      <guid>https://dev.to/adarshkkumar/http-status-401-vs-403-2c59</guid>
      <description>&lt;p&gt;&lt;code&gt;401 - Unauthorized&lt;/code&gt; - Well it should actually say unauthenticated. That is you have not provided/proven your identity or simply put you have not logged in. Can retry with proper credentials to get a 200 OK :D &lt;/p&gt;

&lt;p&gt;&lt;code&gt;403 - Forbidden&lt;/code&gt; - The server now know very well who you are (logged-in/authenticated) but won't give you what you are asking for because you are not authorized to know about it. No point in retrying unless you get your identity(User account) authorized for this information (that they are keeping from you ;) ). &lt;/p&gt;

</description>
      <category>programming</category>
      <category>http</category>
      <category>webdev</category>
      <category>rest</category>
    </item>
    <item>
      <title>Found any good Black Friday deals for developers ?</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Wed, 21 Nov 2018 02:11:04 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/found-any-good-black-friday-deals-for-developers--1pjh</link>
      <guid>https://dev.to/adarshkkumar/found-any-good-black-friday-deals-for-developers--1pjh</guid>
      <description>&lt;p&gt;Hello geeks did you find any deals on stuffs that developers care for ? please share &lt;/p&gt;

&lt;p&gt;I intend to buy a laptop primarily for personal programming projects.&lt;/p&gt;

&lt;p&gt;Also looking out for :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mechanical Keyboard (Currently using RedDragon K522)&lt;/li&gt;
&lt;li&gt;Earphones / in ear monitor (Currently using Mee M6 Pro)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>blackfriday</category>
    </item>
    <item>
      <title>On Making Tech Decisions</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Fri, 17 Aug 2018 19:47:55 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/on-making-tech-decisions-d2g</link>
      <guid>https://dev.to/adarshkkumar/on-making-tech-decisions-d2g</guid>
      <description>&lt;p&gt;I was always afraid to make decisions, even a simple one. Most of it was because I was afraid to be wrong. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What will others think of me ? + Imposter syndrome.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We discuss our ideas with our team and then come to a conclusion based on :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Points discussed by the team/pair.&lt;/li&gt;
&lt;li&gt;Evaluating pros &amp;amp; cons.&lt;/li&gt;
&lt;li&gt;The collective intellect of the team.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;We did the best we can, with the knowledge we had at that point in time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No person will take a decision to knowingly harm the project.&lt;/p&gt;

&lt;p&gt;Now this decision can be right or wrong. If its wrong one must not start a &lt;em&gt;blame game or point fingers&lt;/em&gt;. Its a sign of toxic workplace and senior folks/"manager" must identify and solve such issues at the earliest. If not, others in team who might have good ideas/solutions just keep quite and later quit because they are afraid of being shamed.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1027129061401710593-800" src="https://platform.twitter.com/embed/Tweet.html?id=1027129061401710593"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1027129061401710593-800');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1027129061401710593&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;A software as long as its used will go through continuous evolution. Now it depends how you handle the changes. If you think of short term and pushes changes with bad design and no tests because &lt;strong&gt;you don't have time&lt;/strong&gt;, Its fine just ensure this tech debt is addressed as soon as your urgency is taken care of. But if one urgent/"no-time" issues comes after another and you forget about the tech-debt it will bite you back. Something is terribly wrong with project/product management in this case. &lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1029970538347679744-866" src="https://platform.twitter.com/embed/Tweet.html?id=1029970538347679744"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1029970538347679744-866');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1029970538347679744&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fail fast -&amp;gt; Learn -&amp;gt; Improve&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Right or wrong we learn from the decisions we make.We discover data points which we didn't have earlier.But waiting without making no decision is no progress we are just delaying obvious disaster to happen.&lt;/p&gt;

&lt;p&gt;So when we figure out the decision we made was wrong, simply take the corrective step and evolve the software. Principles that aid in this are TDD/Refactoring. If we have enough test coverage one can confidently do a refactoring. The books &lt;strong&gt;Test Driven Development by Example&lt;/strong&gt; and &lt;strong&gt;Extreme Programming Explained&lt;/strong&gt; by &lt;strong&gt;Kent Beck&lt;/strong&gt; are really good resources for learning these techniques. Another book is &lt;strong&gt;Refactoring Improving the Design of Existing Code&lt;/strong&gt; by &lt;strong&gt;Martin Fowler&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Now that being said, one should not make same mistake twice that's waste of time.&lt;/p&gt;

&lt;p&gt;And if you don't know something, you should reach out and talk to people to learn from similar situation faced by them so that we don't make the mistake they might have made. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Most confusions or problems in a Software can be avoided if we just communicate/"talk" with other people "ASK" for help.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1026486946153938944-670" src="https://platform.twitter.com/embed/Tweet.html?id=1026486946153938944"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1026486946153938944-670');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1026486946153938944&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;With all that being said, I still sometimes feel that Fear of the dark !!! &lt;br&gt;
&lt;strong&gt;given dark='make decision'&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>learning</category>
      <category>career</category>
      <category>tips</category>
    </item>
    <item>
      <title>How to stay on track during Sabbatical / code retreat</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Thu, 26 Jul 2018 18:36:03 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/how-to-stay-on-track-during-sabbatical--code-retreat-2e1</link>
      <guid>https://dev.to/adarshkkumar/how-to-stay-on-track-during-sabbatical--code-retreat-2e1</guid>
      <description>&lt;p&gt;I'm starting my very first sabbatical which is going to be six long months atleast.&lt;/p&gt;

&lt;p&gt;I have two questions:&lt;/p&gt;

&lt;p&gt;I want to explore more about distributed systems. Plan is to build a KV database using Erlang.  What do you think about this?&lt;br&gt;
I will be learning about existing DBs and Consistency problem, Storage optimisation etc as part of this.&lt;/p&gt;

&lt;p&gt;How do I ensure I stay on track and won't lost focus. I know this is a broad questions. If you have done something similar would like to know the experience.&lt;/p&gt;

&lt;p&gt;Rough plan : read books to get concepts, write code, blog, talk at relevant local meetups regarding my learning/work.&lt;/p&gt;

&lt;p&gt;Starting off with :&lt;br&gt;
Designing for scalability with Erlang/OTP&lt;/p&gt;

&lt;p&gt;Designing Data intensive applications&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>help</category>
      <category>programming</category>
      <category>development</category>
    </item>
    <item>
      <title>What to learn next ?</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Sun, 10 Jun 2018 19:50:56 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/what-to-learn-next--ga6</link>
      <guid>https://dev.to/adarshkkumar/what-to-learn-next--ga6</guid>
      <description>&lt;p&gt;What languages, framework, technology or anything Computer Science are you planning to learn next or interested in ?&lt;/p&gt;

&lt;p&gt;For me it's RxJava, Erlang, Elixir and distributed computing.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>career</category>
      <category>dev</category>
    </item>
    <item>
      <title>Reusing LCD from old Laptop with Raspberry Pi.</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Sun, 03 Jun 2018 08:21:05 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/reusing-lcd-from-old-laptop-with-raspberry-pi-52p</link>
      <guid>https://dev.to/adarshkkumar/reusing-lcd-from-old-laptop-with-raspberry-pi-52p</guid>
      <description>&lt;p&gt;So I had this old Dell Studio 14 laptop lying around at home. Used it for close to 5 years before its motherboard gave up. I wanted a cheap display for my Raspberry Pi which I bought recently.&lt;/p&gt;

&lt;p&gt;I googled and found we can reuse LCD panel from laptop with RaspberryPi but we need a driver/controller board for it. The interface used for communication is &lt;a href="http://https://en.wikipedia.org/wiki/Low-voltage_differential_signaling" rel="noopener noreferrer"&gt;LVDS&lt;/a&gt;. I got the board for $30 from ebay. It was very easy to setup and now I have a 14" display for my Raspberry PI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.jigsawcode.com%2Fcontent%2Fimages%2F2018%2F06%2F0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.jigsawcode.com%2Fcontent%2Fimages%2F2018%2F06%2F0.jpeg" alt="1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.jigsawcode.com%2Fcontent%2Fimages%2F2018%2F06%2F1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.jigsawcode.com%2Fcontent%2Fimages%2F2018%2F06%2F1.jpeg" alt="1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there it is. We can Indeed hook up any thing that support HDMI or DVI to it, can use as a secondary monitor for your Laptop or maybe make a digital photo frame.If you want to give it a cool look do &lt;a href="http://https://www.youtube.com/watch?v=CfirQC99xPc&amp;amp;t=1s&amp;amp;lipi=urn%3Ali%3Apage%3Ad_flagship3_pulse_read%3BDzma6W%2F2TwOAo87gSCQ%2BYg%3D%3D" rel="noopener noreferrer"&gt;check out this video&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Originally posted in &lt;a href="https://www.jigsawcode.com/" rel="noopener noreferrer"&gt;JigsawCode&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>iot</category>
      <category>tech</category>
      <category>technology</category>
    </item>
    <item>
      <title>Mount a volume using systemd</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Tue, 29 May 2018 15:29:09 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/mount-a-volume-using-systemd-1h2f</link>
      <guid>https://dev.to/adarshkkumar/mount-a-volume-using-systemd-1h2f</guid>
      <description>&lt;h2&gt;
  
  
  What is systemd ?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;systemd&lt;/code&gt;  is a suite of software that provides fundamental building blocks for a Linux operating system. It is an initialization system and hence the first process to start (with pid 1). It will start and manage other services and manage dependencies between them.&lt;/p&gt;

&lt;p&gt;It replaced sysvinit, upstart in many Linux distributions. As of now almost all popular Linux distributions use systemd as the default init system (including my favorite Debian).&lt;/p&gt;

&lt;p&gt;All this while to mount a volume after boot automatically, we used to mess around with &lt;code&gt;fstab&lt;/code&gt;. Recently I came to know we can use systemd to mount volumes and here is how to do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unit configuration file
&lt;/h2&gt;

&lt;p&gt;Configuration for any entity (service,socket,device,mount point etc) that is managed by systemd is maintained in unit configuration files. They are usually located in &lt;code&gt;/etc/systemd/system&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use &lt;code&gt;systemctl&lt;/code&gt; command to start/stop/restart check status of services in your machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl status postgresql.service
systemctl start postgresql.service
systemctl stop postgresql.service
systemctl restart postgresql.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command offers much more functionality please refer the manpage for more details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# systemctl status postgresql.service 

● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2018-05-20 17:37:20 IST; 1 day 20h ago
  Process: 976 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 976 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/postgresql.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Mount unit Configuration
&lt;/h2&gt;

&lt;p&gt;To mount a filesystem using systemd we create special type of unit files which have an extension of &lt;code&gt;.mount&lt;/code&gt; and &lt;code&gt;.automount&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Mount units must be named after the mount point directories they control. Example: the mount point /home/lennart must be configured in a unit file home-lennart.mount.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Additional drive

[Mount]
What=/dev/disk/by-uuid/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Where=/mnt/driveone
Type=ext4
Options=defaults

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can enable this unit using :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl enable mnt-driveone.mount
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Automount
&lt;/h2&gt;

&lt;p&gt;These unit file configurations ends with &lt;code&gt;.automount&lt;/code&gt;. This can be used to automatically mount the filesystem on demand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Description=Automount Additional Drive

[Automount]
Where=/mnt/driveone

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Automount units must be named after the automount directories they control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every &lt;code&gt;automount&lt;/code&gt; unit file must have a matching &lt;code&gt;mount&lt;/code&gt; unit configuration, which is activated when the path (&lt;code&gt;Where&lt;/code&gt;) in &lt;code&gt;automount&lt;/code&gt; configuration is accessed.&lt;/p&gt;

&lt;p&gt;so the unit configuration required to mount &lt;code&gt;/mnt/mydata&lt;/code&gt; is :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/systemd/system/mnt-mydata.automount
/etc/systemd/system/mnt-mydata.mount
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Originally posted in &lt;a href="https://www.jigsawcode.com/"&gt;JigsawCode&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  References :
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.freedesktop.org/software/systemd/man/systemd.mount.html"&gt;Systemd mount reference&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freedesktop.org/software/systemd/man/systemd.automount.html"&gt;Systemd automount reference&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>os</category>
    </item>
    <item>
      <title>Introduction to Packer by creating an AMI (Amazon Machine Images)</title>
      <dc:creator>Adarsh.K.Kumar</dc:creator>
      <pubDate>Sat, 19 May 2018 15:28:41 +0000</pubDate>
      <link>https://dev.to/adarshkkumar/introduction-to-packer-by-creating-a-ami-amazon-machine-images-92h</link>
      <guid>https://dev.to/adarshkkumar/introduction-to-packer-by-creating-a-ami-amazon-machine-images-92h</guid>
      <description>&lt;h1&gt;
  
  
  What is Packer ?
&lt;/h1&gt;

&lt;p&gt;A tool from Hashicorp to build machine images for most platforms (AWS,Google Cloud,Digital Ocean,Docker,Azure to name a few) and automate configurations and installation of softwares that need to be present.&lt;/p&gt;

&lt;p&gt;We define how to build the image in a JSON template file.This should be version controlled and is treated like any other code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://infrastructure-as-code.com/"&gt;Infrastructure As Code.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Sections of Packer template
&lt;/h1&gt;



&lt;h2&gt;
  
  
  Builders
&lt;/h2&gt;

&lt;p&gt;A builder takes care of creating an image.Packer provides builders for various platforms.&lt;br&gt;
For this example we will be using &lt;strong&gt;amazon-ebs&lt;/strong&gt; as builder.&lt;br&gt;
We provide platform specific configurations in the builder section of the template.Like what type of instance (t2-micro m4-large etc) to spin up to create the image, SSH/Access details or credentials. You can create custom builders as well though we wont be covering this. &lt;/p&gt;

&lt;p&gt;Builders use Communicators to establish connection with the created instance. Either it can be a SSH connection or WINRM for Windows machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Provisioners
&lt;/h2&gt;

&lt;p&gt;Once a machine is created by the builder we will use provisioners to install softwares and configure the machine to a desired state.Packer provide provisioners for configuration management tools like Chef/Puppet/Ansible or good old shell script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Post-Processors
&lt;/h2&gt;

&lt;p&gt;Once the machine is created and softwares installed and configurations applied by Provisioners Post-Processors are run. We can use them for example to push a docker image to a registry. We wont be covering this and for details &lt;a href="https://www.packer.io/docs/post-processors/index.html"&gt;please refer this documentation.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;p&gt;Packer template should be made generic so it can be used in different environment and keeping secrets/credentials secure by not providing them in the template file. Use user variables in place of such configurations.&lt;/p&gt;

&lt;p&gt;In the template below we use user variables for &lt;em&gt;name, sourceami, accesskey, secretkey, region&lt;/em&gt;. For some of these we have provided a default  value in the variable sections other are left as empty,We can pass in the value while building the image using &lt;strong&gt;-var&lt;/strong&gt; parameter.&lt;/p&gt;

&lt;h2&gt;
  
  
  So What exactly does Packer do ?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Packer will spin up an instance for the specified platform based on the type of builder.&lt;/li&gt;
&lt;li&gt;Use the Communicator specified to connect to the machine.&lt;/li&gt;
&lt;li&gt;Run all the provisioners to configure and install softwares. &lt;/li&gt;
&lt;li&gt;It the runs any post-processors specified in the JSON template.&lt;/li&gt;
&lt;li&gt;Finally it terminates machines and any temporary resources it created in the process, eg: security group, temporary ssh key-pair etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Getting hands dirty with Packer
&lt;/h1&gt;



&lt;h2&gt;
  
  
  What are we going to do ?
&lt;/h2&gt;



&lt;ul&gt;
&lt;li&gt;Create an AMI with Nginx pre-installed

&lt;ul&gt;
&lt;li&gt;Choose source_ami as CentOS 7&lt;/li&gt;
&lt;li&gt;Install EPEL (Extra packages for enterprise Linux)&lt;/li&gt;
&lt;li&gt;Install nginx&lt;/li&gt;
&lt;li&gt;Enable nginx to start on boot
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "variables": {
      "name": "centos_7_nginx",
      "source_ami": "ami-d5bf2caa",
      "access_key":"",
      "secret_key":"",
      "region":"us-east-1"
    },
    "builders": [{
      "type": "amazon-ebs",
      "access_key": "{{user `access_key`}}",
      "secret_key":"{{user `secret_key`}}",
      "ami_name": "{{user `name`}}",
      "region": "{{user `region`}}",
      "source_ami": "{{user `source_ami`}}",
      "instance_type": "t2.micro",
      "communicator": "ssh",
      "ssh_username": "centos",
      "run_tags":{"Name":"packer-image"}
    }],
    "provisioners": [
        {
            "type": "shell",
            "inline": "sudo yum install -y epel-release"
        },
        {
            "type": "shell",
            "inline": ["sudo yum install -y nginx","sudo systemctl enable nginx", "sudo systemctl start nginx"]
        }
      ]
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Command to build image :
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;packer build -var 'access_key=XXXXXXXXXXX' -var 'secret_key=XXXXXXXXXXXXXXXXXXXXXXXX' aws_centos_nginx.json 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before running the above command you can validate the file using &lt;code&gt;packer validate template.json&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Note:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Generate a secret key and access key from AWS which have authorization for creating image and pass the packer build command.&lt;/li&gt;
&lt;li&gt;The source AMI specified above is CentOS Linux 7 x86_64 HVM EBS.&lt;/li&gt;
&lt;li&gt;Communicator used is SSH and we specify the default username which is centos.&lt;/li&gt;
&lt;li&gt;AMI are region specific so ensure you select us-east-1 or N.Virginia as your current region.&lt;/li&gt;
&lt;li&gt;run_tags are tags assigned to the machine used to create the image.This machine will be terminated once the image is created.&lt;/li&gt;
&lt;li&gt;We have used shell prvisioner in the above example with inline mode. First with just a single command then with an array of commands to run.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Originally posted in &lt;a href="https://www.jigsawcode.com"&gt;JigsawCode&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Where to next ?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.jigsawcode.com/packer-recipes-for-ec2-ami/"&gt;Packer Recipes to bake an EC2 AMI&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.packer.io/docs/index.html"&gt;Packer Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;P.S If you find it useful,I will write a second part exploring more features of Packer.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ami</category>
      <category>packer</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
