<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vaibhav Khullar on Medium]]></title>
        <description><![CDATA[Stories by Vaibhav Khullar on Medium]]></description>
        <link>https://medium.com/@vaibhavkhullar55?source=rss-7f35a5ef74e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZV089NZrz2upSu1-NTrTjg@2x.jpeg</url>
            <title>Stories by Vaibhav Khullar on Medium</title>
            <link>https://medium.com/@vaibhavkhullar55?source=rss-7f35a5ef74e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:52:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vaibhavkhullar55/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Short Message for my readers :-)]]></title>
            <link>https://medium.com/@vaibhavkhullar55/short-message-for-my-readers-dd1626dd94c9?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd1626dd94c9</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 22:29:56 GMT</pubDate>
            <atom:updated>2023-04-16T22:29:56.504Z</atom:updated>
            <content:encoded><![CDATA[<h3>Short Message for my readers :-)</h3><p>Hey beautiful readers👋. Hope you are having an amazing day. I hope this message finds you well. I am writing to apologize for the lack of blogs on this platform recently. As many of you know, I am currently a university student, and I have been preparing for my exams, which have taken up a considerable amount of my time and energy. Additionally, I am pleased to announce that I have recently passed the AWS Certified Cloud Practitioner (CCP) exam, which required a lot of studying and preparation.</p><p>I understand that many of you were looking forward to reading new content on my blog, and I apologize for any disappointment or inconvenience that my absence may have caused. However, I want to assure you that I am committed to creating quality content and will do my best to make up for the missed posts.</p><p>In the coming weeks, I plan to share my experiences preparing for the AWS CCP exam and offer some tips and advice for those who are interested in pursuing this certification. I will also continue to publish blogs on other topics related to cloud and devops.</p><p>Once again, I apologize for the delay in posting and thank you for your understanding and patience during this time. I appreciate your support and look forward to sharing more content with you soon.</p><p>Thanks for cooperating.</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd1626dd94c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[S3 Bucket Policy Hands-On]]></title>
            <link>https://medium.com/@vaibhavkhullar55/s3-bucket-policy-hands-on-2023c4644ff6?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2023c4644ff6</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Tue, 14 Mar 2023 21:20:24 GMT</pubDate>
            <atom:updated>2023-03-14T21:20:24.114Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v8ZaH6eA-D4x3td9.png" /></figure><p>Hey beautiful learners 👋. Hope you are having a good day. Today we will be learning what S3 bucket and its bucket policies is. Furthermore, we will also be doing some hands on practice🔥 on generating bucket policies. We will be facing one issue which we’ll be resolving in the matter of few clicks. So fasten your seat belts and lets get started.</p><h3>What is S3?</h3><p><strong>S3:-</strong> A cloud-based object storage tool offered by Amazon Web Services is called Amazon S3 (Simple Storage Service) (AWS). Any quantity of data can be stored and retrieved using it from any location on the internet.</p><p>With built-in security, encryption, and access control features, S3 offers a storage system that is incredibly scalable and long-lasting. It is used by people, groups, and companies of all sizes to store and secure their data, including everything from straightforward text files to sophisticated multimedia files.</p><p>The following are some of the main attributes and advantages of Amazon S3:-</p><ul><li><strong>Scalability:</strong> S3 can store and retrieve any amount of data, from gigabytes to petabytes and beyond, with virtually unlimited scalability.</li><li><strong>Durability:</strong> S3 is designed to provide 99.999999999% durability for your data, with built-in redundancy and data replication across multiple locations.</li><li><strong>Security:</strong> S3 provides several security features, such as data encryption, access control, and audit logging, to help you protect your data.</li><li><strong>Flexibility:</strong> S3 can be used to store and retrieve any type of data, such as text files, images, videos, audio files, and application data.</li><li><strong>Integration:</strong> S3 integrates with a wide range of AWS services, such as Amazon EC2, Amazon RDS, and Amazon CloudFront, as well as many third-party services and tools.</li><li><strong>Cost-effectiveness:</strong> S3 provides a pay-as-you-go pricing model, which means you only pay for the storage and data transfer that you use.</li></ul><p>Overall, Amazon S3 is a reliable and cost-effective storage solution for businesses of all sizes, with a wide range of features and benefits to meet your data storage and retrieval needs.</p><p><strong>Lets create a S3 bucket first:-</strong></p><ol><li>Log in to your AWS Management Console.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hv-woFdq9NjPcO3R6v08wA.png" /></figure><p>2. Click on the Services dropdown menu and select S3 under the Storage section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWLRstnoghmU0XcWJx9DzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rdk3byqIfZ8UOt6xYFUvxA.png" /></figure><p>3. Click on the Create bucket button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rdk3byqIfZ8UOt6xYFUvxA.png" /></figure><p>4. Choose a unique and descriptive name for your bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIThU6EZxSWzipBLK3cM-A.png" /></figure><p>5. Select a region where you want your bucket to be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ol3X45jafLHkIbpEHU9EzQ.png" /></figure><p>6. You can select an existing bucket policy or keep the default settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5u9380dkot4biojQE4kUg.png" /></figure><p>7. Set up versioning if you want to keep multiple versions of your files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0w6a0d7PtRlA_i8FKkvpA.png" /></figure><p>8. Review your settings and click Create bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uAllKfbsZWk-maMYWGiAug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zdfDg9_pyXEC6HTxTQYoAg.png" /></figure><p>9. Your bucket will be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RofSc2uPeXbZII5MwgPTTg.png" /></figure><p>10. Now upload any file in the bucket. Click on “<strong>Upload</strong>”, click on “<strong>Add files</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2FsK6UNZU6RAgS_gHQ_BQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4NJa_Dmj34AxJ_x-mZHJQ.png" /></figure><p>11. Click on “<strong>Upload</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SzqrMg4SabPYCor3DLC6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pb0KznaruMki2k2ngFe3iQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzolcKsaNpny0s11GCQdLw.png" /></figure><p>12. Click on file uploaded in the bucket. Copy “<strong>Object URL</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_2jrfkJqAfxZ3Yj4pjxAQ.png" /></figure><p>13. Paste the copied URL in new tab and run it. “<strong>Access denied</strong>” error will come.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gd5QZBU1mfBFbNoTIp0xwQ.png" /></figure><h3>What is Bucket Policies?</h3><p>Bucket policies in AWS S3 are a set of rules that define access permissions for an S3 bucket. These policies allow you to control who can access your S3 bucket and what they can do with the objects stored in it.</p><p>Bucket policies are based on the JSON syntax and allow you to define permissions for different AWS accounts, IAM users, or even anonymous users. You can specify permissions to allow or deny actions such as reading, writing, or deleting objects in the bucket.</p><h3><strong>In order to resolve this, we need to add bucket policy as our object is not public.</strong></h3><ol><li>Go to your bucket. Open it and click on your file. Go to “Permissions” tab.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQ26EXD12TuDk7KgM0fN-A.png" /></figure><p>2. Go to “<strong>Bucket policy</strong>” and click on “<strong>Edit</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DqdaJZbbTGHkbmY-2nph5g.png" /></figure><p>3. Click on “<strong>Policy generator</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kvs-E6WSN7IZ1tjGtX0Ikw.png" /></figure><p>4. Select “<strong>Select Type of Policy</strong>” as “<strong>S3 Bucket Policy</strong>”, enter “<strong>Principal</strong>” as “<strong>*</strong>”, “<strong>Actions</strong>” as “<strong>GetObject</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eb24WZlx13KHPyyeKtuz7Q.png" /></figure><p>5. For ARN, copy it from Edit Bucket Policy screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4vKpcLwg2_RXxs3xIoJLQ.png" /><figcaption>‘</figcaption></figure><p>6. Paste the ARN in the required box and add “<strong>/*</strong>” in the end of ARN. Click on “<strong>Add Statement</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foCG-BRAWqdr0sVzNUgJ3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8fgRxfc-dG8LjDD609y0A.png" /></figure><p>7. Click on “<strong>Generate Policy</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0290jSM22eUCWdEkl_sGQ.png" /></figure><p>8. Come back to Edit bucket screen and paste the policy there and click on “<strong>Save Changes</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J68KNpzJzAMraltH06PMNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Z19Ly0i6HKn-be9eo2SAw.png" /></figure><p>9. Now refresh the webpage which was throwing “<strong>Access Denied</strong>” error. The object will now be visible publicly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MSZ1ZcrVMVCP5Bw_AWW_w.png" /></figure><p>Stay tuned for more blogs on S3🔥.</p><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2023c4644ff6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 59: Ansible Project ]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-59-ansible-project-564dd9f8b730?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/564dd9f8b730</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 22:38:18 GMT</pubDate>
            <atom:updated>2023-03-12T22:38:18.873Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible playbooks are amazing, as you learned yesterday. What if you deploy a simple web app using ansible, sounds like a good project, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MaOy2bvUHf2o6R9c.png" /></figure><h3>Task-01</h3><ul><li>Install Ansible in host server.</li></ul><ol><li>Launch an EC2 instance. Enter desired name, make a new key pair.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ex2byTexl6b7y39T.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4Mu87_xu-Cw2smrm.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*G58gmJ4L1vMVDf0i.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9MNwGZNgLo78NCFZ.png" /></figure><p>2. Your instance will be created. Connect to your newly made instance via EC2 connect or SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HwKBgkfxBpxJflwq.png" /></figure><p>3. Fire the command “<strong>sudo apt-add-repository ppa:ansible/ansible</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kJLjTbIWr96N3I0q.png" /></figure><p>4. Run the command “<strong>sudo apt update</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*aUbJB_YJ4zUiri2y.png" /></figure><p>5. Run the command “<strong>sudo apt install ansible</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HeHt2ZO_JTmDXIrP.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*o87OSFgVkK8A7fYL.png" /></figure><p>6. Run “<strong>cat /etc/ansible/hosts</strong>” to check whether ansible is installed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*S1DwAjmcXELxHs4R.png" /></figure><ul><li>Create 3 EC2 instances . make sure all three are created with same key pair</li><li>Copy the private key from local to Host server (Ansible_host) at (/home/ubuntu/.ssh).</li></ul><ol><li>Launch 3 more instances. <strong>Use the key-pair which was made earlier for Ansible Master instance</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GWIzwI_FGfYysMQj.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0Z8uc9voznXqAHg5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EGyNOL_REyKVg3Mm.png" /></figure><p>2. Your instances will be launched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ak9fflMjPz7uLlb0.png" /></figure><ul><li>Copy the private key to master server where Ansible is setup.</li></ul><ol><li>Fire command “<strong>sudo vim /etc/ansible/hosts</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qQVe6xD988WEqDri.png" /></figure><p>2. Add IP of the servers which you have created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xESCKCESl4_G8Q0v.png" /></figure><p>3. Fire the command “<strong>ansible servers -m ping</strong>” to connect to servers. Here “<strong>servers</strong>” is the group name which you have given in <strong>/etc/ansible/hosts</strong> file. Error will come because you have not given public key to connect to servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Lbzg7bXxtfYIZpBJ.png" /></figure><p>4. Run command “<strong>cd .ssh</strong>” and then “<strong>pwd</strong>”. Copy the path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*edYjrc-qxhb3m3fD.png" /></figure><p>5. Connect to ansible master instance via Powershell via SSH. Fire the command “<strong>scp ssh -i “Ansible-Master-New.pem” Ansible-Master-New.pem ubuntu@ec2–3–237–179–91.compute-1.amazonaws.com:&lt;path of .ssh directory&gt;</strong>”</p><p>Note:- <strong>Ansible-Master-New.pem </strong>is to be given 2 times here as above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-dkH1M63mTW2TtVB.png" /></figure><p>6. Go back and do “<strong>ls</strong>”. Your key will be visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vwAjrLi9s8xatTz7.png" /></figure><p>7. Again fire command “<strong>sudo vim /etc/ansible/hosts</strong>” and add the given below configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*S9_vUXS8S8bILlnE.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ghRymQk4iXBJKITO.png" /></figure><p>8. Do “<strong>cd .ssh</strong>” and run command “<strong>chmod 600 &lt;key_name&gt;</strong>” to give permissions to your key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ze1P-nGDMHMBJSQe.png" /></figure><ul><li>Try a ping command using ansible to the Nodes.</li></ul><p>Fire command “<strong>ansible servers -m ping</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*bNBkv9HoVPQTWxMZ.png" /></figure><ul><li>Access the inventory file using sudo vim /etc/ansible/hosts.</li></ul><p>Fire command “<strong>sudo vim /etc/ansible/hosts</strong>” and add the given below configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*S9_vUXS8S8bILlnE.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ghRymQk4iXBJKITO.png" /></figure><ul><li>Create a playbook to install Nginx.</li></ul><ol><li>Fire the command “<strong>vim install_nginx.yml</strong>” and add given below configurations in it for creating a new file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*RpO_aVn4jIK62y1YP_I4wQ.png" /></figure><p>2. Run the command “<strong>ansible-playbook &lt;file_name.yml&gt;</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bEB2MdjKP_D5YHR-rdoBA.png" /></figure><p>3. Go to your servers to check whether file has been created or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QI4FFMyjm8ne3jifnm5uKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ce8LbnzlMC7OVZhmw8MJQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcXel2x-Omf9Bah8sWJSUg.png" /></figure><ul><li>Deploy a sample webpage using the ansible playbook.</li></ul><ol><li>Make a file by using command “vim index.html” which will contain source code of the webpage to be hosted.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euNXqMJkrJGP3VyaFoMMEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DE-boyvr_ZtpEpmLZ-VCrg.png" /></figure><p>2. Fire the command “<strong>vim webpage.yml</strong>” and add given below configurations in it for creating a new file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abPbWNRpY5YYCyPCos5Spg.png" /></figure><p>3. Run the command “<strong>ansible-playbook &lt;file_name.yml&gt;</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6oAcI8fwUqyCSMwWN6DVwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KgaBEj6fIz4jxLJfe6UKrQ.png" /></figure><p>4. Go to your servers to check whether webpage has been hosted or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUp9ZmCy3F8KQZKw-qsx-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ct2PpWrruCku7AOWORShJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEa337YYYKiYUDIg5S6Vww.png" /></figure><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=564dd9f8b730" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 58: Ansible Playbooks]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-58-ansible-playbooks-55866aa76fcf?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/55866aa76fcf</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 21:20:21 GMT</pubDate>
            <atom:updated>2023-03-12T21:20:21.153Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible playbooks run multiple tasks, assign roles, and define configurations, deployment steps, and variables. If you’re using multiple servers, Ansible playbooks organize the steps between the assembled machines or servers and get them organized and running in the way the users need them to. Consider playbooks as the equivalent of instruction manuals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iIjTMlNCA404Ovhs.png" /></figure><h3>Task-01</h3><ul><li>Write an ansible playbook to create a file on a different server.</li></ul><ol><li>Fire the command “<strong>vim create_file.yml</strong>” and add given below configurations in it for creating a new file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*g576r6uvtPCIGfEJVNOe9w.png" /></figure><p>2. Run the command “<strong>ansible-playbook &lt;file_name.yml&gt;</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YPML1vOq8rckwU_zxdN88w.png" /></figure><p>3. Go to your servers to check whether file has been created or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CvnL7YrRvK5Gn0xhnaLdDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pv8ekUNWi0fwLCHKeIg2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1q6VymnMxUvS83eUL0jQQ.png" /></figure><ul><li>Write an ansible playbook to create a new user.</li></ul><ol><li>Fire the command “<strong>vim create_user.yml</strong>” and add given below configurations in it for creating a new file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*XVTz3AomucnsyKeEFcTtrw.png" /></figure><p>2. Run the command “<strong>ansible-playbook &lt;file_name.yml&gt;</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qY_RRkJhHVXFO8MBqUXWqA.png" /></figure><p>3. Go to your servers to check whether file has been created or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QnT6EbWKl1-9Nb1Kt-1Rdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5jk03Hwq-lw7jH1CHGnsg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*emQTFbb9oLLgnbRsPG1JzQ.png" /></figure><ul><li>Write an ansible playbook to install docker on a group of servers.</li></ul><ol><li>Fire the command “<strong>vim install_docker.yml</strong>” and add given below configurations in it for creating a new file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1iw1jn9kV_k5PJMn7VUxiw.png" /></figure><p>2. Run the command “<strong>ansible-playbook &lt;file_name.yml&gt;</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMpyb2XqFqTWmwveDSYV2A.png" /></figure><p>3. Go to your servers to check whether file has been created or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2L8-x2ajyNmKd_5SCClAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PP6bfdddMiaoVH0bg4dklA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ou1sgmV-8yo5A3C89kzMIQ.png" /></figure><h3>Task-02</h3><ul><li>Write a blog about writing ansible playbooks with the best practices.</li></ul><p>Ansible is a potent automation tool that enables you to handle infrastructure as code configuration and deployment. With Ansible, you can automate routine chores, lessen human error, and increase the predictability and scalability of your infrastructure. Writing Ansible playbooks can be difficult, though, particularly when it comes to uniformity, readability, and maintainability. In this article, we’ll talk about some guidelines for creating Ansible playbooks that can make your code more effective and readable.</p><p><strong>Best Practices:</strong></p><ol><li><strong>Maintain modularity in your playbooks:</strong> Maintaining modularity in your playbooks is crucial for maintaining readability and maintainability in your code. Your playbooks can be divided into more manageable, reusable modules that can be merged to create bigger playbooks. Additionally, by using this strategy, you can reuse code across numerous tasks, saving you time and effort.</li><li><strong>Use names that are clear and consistent:</strong> Clear names for your variables, tasks, and playbooks make it simpler for you to grasp what the code does and for others to do the same. You can maintain consistency and make your code easier to understand by using naming conventions like CamelCase or snake case.</li><li><strong>Use roles to structure your code:</strong> Roles are a fantastic tool for structuring Ansible code. You can organise tasks and variables into groups using them, which makes it simpler to handle and reuse your code across various playbooks. Roles can be shared with others and help you keep your code flexible.</li><li><strong>Use conditionals sparingly:</strong> Although Ansible’s conditionals are a powerful tool, using them excessively can make your code more difficult to read and manage. Utilize variables and templates instead of conditionals to manage your configuration whenever feasible.</li><li><strong>Reduce repetition in your code by using loops:</strong> Loops are a great method to lessen repetition in your code. They enable you to carry out the same operations on various hosts or data collections. You can streamline your code and increase its efficiency by using loops.</li><li><strong>Use comments to clarify your code:</strong> By using comments to clarify your code, you can help other people comprehend what you’re trying to accomplish. When you revisit the code later, comments can also help you remember what you were attempting to accomplish.</li><li><strong>Manage sensitive data with Ansible Vault:</strong> Ansible Vault is a tool that lets you encrypt sensitive data, like API keys and passwords. Your private data will be safe and accessible to authorised users only if you use Ansible Vault.</li></ol><p><strong>Conclusion:</strong> Writing Ansible playbooks can be difficult, but if you adhere to these best practices, your code will be effective and easy to manage. You can make your Ansible code simple to comprehend, maintain, and scale by keeping your code modular, using descriptive and consistent names, organizing it with roles, using conditionals sparingly, using loops to cut down on repetition, using comments to explain your code, and using Ansible Vault to manage sensitive data.</p><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55866aa76fcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 57: Ansible Hands-on with video]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-57-ansible-hands-on-with-video-4f0ecd11ecef?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f0ecd11ecef</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 22:39:41 GMT</pubDate>
            <atom:updated>2023-03-11T22:39:41.141Z</atom:updated>
            <content:encoded><![CDATA[<p>Write a Blog explanation for the <a href="https://youtu.be/SGB7EdiP39E">ansible video</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FZhjq46MxblVwtkL.png" /></figure><ul><li>Installation of Ansible on AWS EC2 (Master Node) sudo apt-add-repository ppa:ansible/ansible sudo apt update sudo apt install ansible</li></ul><ol><li>Launch an EC2 instance. Enter desired name, make a new key pair.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*T36IGBJsQx6eadZ4.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AapfjMTgrxVXJZ_a.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8d_TgNfmyKYwDzSw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*P1kkV6ciC62DZS6o.png" /></figure><p>2. Your instance will be created. Connect to your newly made instance via EC2 connect or SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ph391ZzbL5Qj8hvz.png" /></figure><p>3. Fire the command “<strong>sudo apt-add-repository ppa:ansible/ansible</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xThGurxfP6ji6DZk.png" /></figure><p>4. Run the command “<strong>sudo apt update</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PMjbQZzm5TfYLcFO.png" /></figure><p>5. Run the command “<strong>sudo apt install ansible</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uQ7kbXhxtuHB_9FA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*iXWn9XtA9YeBwA0e.png" /></figure><p>6. Run “<strong>cat /etc/ansible/hosts</strong>” to check whether ansible is installed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AvyCKMUqIeZJ2FpF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OncQkPrY_rjtksda.png" /></figure><ul><li>Read more about Hosts file sudo vim /etc/ansible/hosts ansible-inventory --list -y</li></ul><p>The Ansible hosts file is a configuration file that contains a list of hosts or servers that Ansible can manage. The hosts file is located at <strong>/etc/ansible/hosts</strong> on the Ansible control node, and it is used to define the inventory of hosts that Ansible can manage.</p><p>To edit the hosts file, you can use any text editor of your choice.</p><pre>sudo vim /etc/ansible/hosts</pre><p>Once the file is open, you can add the IP addresses or hostnames of the servers you want to manage. The format for adding hosts is as follows:</p><pre>[group_name] <br>host1 <br>host2 <br>host3</pre><p>In this illustration, host1, host2, and host3 are the IP addresses or hostnames of the servers, and group name is a user-defined name for the group of hosts. In the hosts file, you can specify a number of groups of hosts, each with a unique list of hosts.</p><p>Using the ansible-inventory command with the — list and -y options, you can confirm the inventory of hosts that Ansible can handle after adding the hosts to the file:</p><pre>ansible-inventory --list -y</pre><p>This command will show a list of hosts along with all of their characteristics, such as hostnames, IP addresses, and any other specified variables or group memberships, in YAML format.</p><ul><li>Setup 2 more EC2 instances with same Private keys as the previous instance (Node).</li></ul><ol><li>Launch 3 more instances. <strong>Use the key-pair which was made earlier for Ansible Master instance</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*x9U88N0XXgKpWr08.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GfI_aNJUqLJQquZm.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3mRAKbCq1cap_82P.png" /></figure><p>2. Your instances will be launched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*A6tboN2IsFt_8yyu.png" /></figure><ul><li>Copy the private key to master server where Ansible is setup.</li></ul><ol><li>Fire command “<strong>sudo vim /etc/ansible/hosts</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Qd-raLfSu2IJ5Y6W.png" /></figure><p>2. Add IP of the servers which you have created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*BlyQuKxTbsM1ckJe.png" /></figure><p>3. Fire the command “<strong>ansible servers -m ping</strong>” to connect to servers. Here “<strong>servers</strong>” is the group name which you have given in <strong>/etc/ansible/hosts</strong> file. Error will come because you have not given public key to connect to servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*48MjA_gDgY6Xu7ze.png" /></figure><p>4. Run command “<strong>cd .ssh</strong>” and then “<strong>pwd</strong>”. Copy the path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*1isTAVj-E49jwKnE.png" /></figure><p>5. Connect to ansible master instance via Powershell via SSH. Fire the command “<strong>scp ssh -i “Ansible-Master-New.pem” Ansible-Master-New.pem ubuntu@ec2–3–237–179–91.compute-1.amazonaws.com:&lt;path of .ssh directory&gt;</strong>”</p><p>Note:- <strong>Ansible-Master-New.pem </strong>is to be given 2 times here as above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SDRmgBC_2Z3iUhVL.png" /></figure><p>6. Go back and do “<strong>ls</strong>”. Your key will be visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*1Jv5HVD8v5F6BLd4.png" /></figure><p>7. Again fire command “<strong>sudo vim /etc/ansible/hosts</strong>” and add the given below configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gbG_gh0Yx6gT3RgS.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VTHdQIQvA0liNDp9.png" /></figure><p>8. Do “<strong>cd .ssh</strong>” and run command “<strong>chmod 600 &lt;key_name&gt;</strong>” to give permissions to your key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*wQVOKQOdldtfIDLC.png" /></figure><p>Fire command “<strong>ansible servers -m ping</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LaeRgexngkgr04Sz.png" /></figure><p><strong>Ansible command to check the free memory/ memory usage of hosts:</strong></p><p><strong>ansible servers -a “free -m”:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CZtgSa4t2VhGTYfcfJq6GA.png" /></figure><p><strong>Ansible command to check uptime:</strong></p><p><strong>ansible servers -a “uptime”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*7c1Ml-D1w-yYLe5uCc0hbw.png" /></figure><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f0ecd11ecef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 55: Understanding Configuration Management with Ansible]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-55-understanding-configuration-management-with-ansible-1c89bb7348c?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c89bb7348c</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 22:09:49 GMT</pubDate>
            <atom:updated>2023-03-13T05:21:20.413Z</atom:updated>
            <content:encoded><![CDATA[<h3>What’s this Ansible?</h3><p>Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration, and provisioning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TSzN43NxY-V9HXdT.png" /></figure><h3>Task-01</h3><ul><li>Installation of Ansible on AWS EC2 (Master Node) sudo apt-add-repository ppa:ansible/ansible sudo apt update sudo apt install ansible</li></ul><ol><li>Launch an EC2 instance. Enter desired name, make a new key pair.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgjFYoqM8imhvjgTAxvxmw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NF5xjn2OCeE9sSJ80t4E3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1jX6qOGtAe3SJjeZfhcIdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdPyHhEE8tpPMAZM-bc5Qw.png" /></figure><p>2. Your instance will be created. Connect to your newly made instance via EC2 connect or SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_730HyOXovYobU9-ZG6PcQ.png" /></figure><p>3. Fire the command “<strong>sudo apt-add-repository ppa:ansible/ansible</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quaSUl5BtWKMz7POTWC15w.png" /></figure><p>4. Run the command “<strong>sudo apt update</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*gSz7sxOQP-JKlh8Zgi2ilg.png" /></figure><p>5. Run the command “<strong>sudo apt install ansible</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0Xp6Zi94i6btQfwxAUNBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUpyenuk77xVeJTXB6FDYA.png" /></figure><p>6. Run “<strong>cat /etc/ansible/hosts</strong>” to check whether ansible is installed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rvbLgQ-5GhCgXHzrfhNqFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Wy8t6N2iJJwYToJE2VEZA.png" /></figure><h3>Task-02</h3><ul><li>Read more about Hosts file sudo vim /etc/ansible/hosts ansible-inventory --list -y</li></ul><p>The Ansible hosts file is a configuration file that contains a list of hosts or servers that Ansible can manage. The hosts file is located at <strong>/etc/ansible/hosts</strong> on the Ansible control node, and it is used to define the inventory of hosts that Ansible can manage.</p><p>To edit the hosts file, you can use any text editor of your choice.</p><pre>sudo vim /etc/ansible/hosts</pre><p>Once the file is open, you can add the IP addresses or hostnames of the servers you want to manage. The format for adding hosts is as follows:</p><pre>[group_name] <br>host1 <br>host2 <br>host3</pre><p>In this illustration, host1, host2, and host3 are the IP addresses or hostnames of the servers, and group name is a user-defined name for the group of hosts. In the hosts file, you can specify a number of groups of hosts, each with a unique list of hosts.</p><p>Using the ansible-inventory command with the — list and -y options, you can confirm the inventory of hosts that Ansible can handle after adding the hosts to the file:</p><pre>ansible-inventory --list -y</pre><p>This command will show a list of hosts along with all of their characteristics, such as hostnames, IP addresses, and any other specified variables or group memberships, in YAML format.</p><h3>Task-03</h3><ul><li>Setup 3 more EC2 instances with same Private keys as the previous instance (Node).</li></ul><ol><li>Launch 3 more instances. <strong>Use the key-pair which was made earlier for Ansible Master instance</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E8jrRcAXZLgWfL9vjLVSww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jItFV5MKOhrZV1sg2J6H-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r72TO8iZYn3hOS35VC7zFw.png" /></figure><p>2. Your instances will be launched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81g-eEWpXC-6JTp6YLy7uQ.png" /></figure><ul><li>Copy the private key to master server where Ansible is setup.</li></ul><ol><li>Fire command “<strong>sudo vim /etc/ansible/hosts</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZmNrFnCV9u0k0nezri_8Q.png" /></figure><p>2. Add IP of the servers which you have created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MR0cEwlVAzg-NPO9vYhzhA.png" /></figure><p>3. Fire the command “<strong>ansible servers -m ping</strong>” to connect to servers. Here “<strong>servers</strong>” is the group name which you have given in <strong>/etc/ansible/hosts</strong> file. Error will come because you have not given public key to connect to servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEfwEva8s-4_wNTZtbhCjg.png" /></figure><p>4. Run command “<strong>cd .ssh</strong>” and then “<strong>pwd</strong>”. Copy the path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*tbJUcwbnH-vEHrJcM4sMAA.png" /></figure><p>5. Connect to ansible master instance via Powershell via SSH. Fire the command “<strong>scp ssh -i “Ansible-Master-New.pem” Ansible-Master-New.pem ubuntu@ec2–3–237–179–91.compute-1.amazonaws.com:&lt;path of .ssh directory&gt;</strong>”</p><p>Note:- <strong>Ansible-Master-New.pem </strong>is to be given 2 times here as above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xQ8goJHtDiQbhdFZdjThg.png" /></figure><p>6. Go back and do “<strong>ls</strong>”. Your key will be visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*3zMGYgSOAE_05CB1fwDTaQ.png" /></figure><p>7. Again fire command “<strong>sudo vim /etc/ansible/hosts</strong>” and add the given below configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*bmM1DFBz6JFm_b70pBgacw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*HFxIadd_Vkfri-2Npayslw.png" /></figure><p>8. Do “<strong>cd .ssh</strong>” and run command “<strong>chmod 600 &lt;key_name&gt;</strong>” to give permissions to your key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*RfmYVBdtu3IrRggJ_mloYw.png" /></figure><ul><li>Try a ping command using ansible to the Nodes.</li></ul><p>Fire command “<strong>ansible servers -m ping</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bA5mjwiXnYzhGb9eaeQKkQ.png" /></figure><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c89bb7348c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete CI/CD Project using AWS Services]]></title>
            <link>https://medium.com/@vaibhavkhullar55/complete-ci-cd-project-using-aws-services-2464dda6ac34?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2464dda6ac34</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Fri, 10 Mar 2023 19:54:22 GMT</pubDate>
            <atom:updated>2023-03-10T19:54:22.974Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>This project will cover the following AWS services:-</strong></p><ol><li>EC2</li><li>S3</li><li>Code-Commit</li><li>Code-Build</li><li>Code-Deploy</li><li>Code-Pipeline</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ANP5G9udLJX3z5Rr.png" /></figure><h3>What is CodeCommit ?</h3><ul><li>CodeCommit is a managed source control service by AWS that allows users to store, manage, and version their source code and artifacts securely and at scale just like GitHub. It supports Git, integrates with other AWS services, enables collaboration through branch and merge workflows, and provides audit logs and compliance reports to meet regulatory requirements and track changes. Overall, CodeCommit provides developers with a reliable and efficient way to manage their codebase and set up a CI/CD pipeline for their software development projects.</li></ul><h3>What is CodeBuild ?</h3><ul><li>AWS CodeBuild is a fully managed build service in the cloud. CodeBuild compiles your source code, runs unit tests, and produces artifacts that are ready to deploy. CodeBuild eliminates the need to provision, manage, and scale your own build servers.</li></ul><h3>What is CodeDeploy ?</h3><ul><li>AWS CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services.</li></ul><p>CodeDeploy can deploy application content that runs on a server and is stored in Amazon S3 buckets, GitHub repositories, or Bitbucket repositories. CodeDeploy can also deploy a serverless Lambda function. You do not need to make changes to your existing code before you can use CodeDeploy.</p><h3>What is CodePipeline ?</h3><ul><li>CodePipeline builds, tests, and deploys your code every time there is a code change, based on the release process models you define. Think of it as a CI/CD Pipeline service.</li></ul><p><strong>Steps:-</strong></p><ul><li><strong>Set up a code repository on CodeCommit and clone it on your local.</strong></li></ul><ol><li>Login to aws account by using valid credentials. Search “<strong>CodeCommit</strong>” from search box and click on it. Click on “<strong>Create repository</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*IXth1sK1p5U1KZzT.png" /></figure><p>2. Enter mandatory details like “<strong>Repository name</strong>”. Click on “<strong>Create</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6E9dya5CFhoGZwvm.png" /></figure><p>3. Repository will be created and visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Vmgj9A-x8QfAZ_fY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Aiu_H0CwKzzWYpn3.png" /></figure><ul><li><strong>You need to setup GitCredentials in your AWS IAM.</strong></li></ul><ol><li>Open visual studio code and open a new terminal. Give command “<strong>git status</strong>”. Error will come.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3E-9mRBlH5eNxGTV.png" /></figure><p>2. Go to search box in aws console. Search for “<strong>IAM</strong>”. Click on “<strong>Users</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5P-RC_vnZZtikBli.png" /></figure><p>3. Your user will be visible. Click on the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7pMXXfAlIgwQuXL_.png" /></figure><p>4. After clicking on user, navigate to “<strong>Security credentials</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*g9E1jkIsMWADQ3vp.png" /></figure><p>5. Under security credentials, scroll down and come to “<strong>HTTPS Git credentials for AWS CodeCommit</strong>”. Click on “<strong>Generate credentials</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PFJ7hfmCixTQjh9v.png" /></figure><p>6. Download your credentials in your system for further usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uf23JwwDO_kaZpO7.png" /></figure><ul><li>Use those credentials in your local and then clone the repository from CodeCommit.</li></ul><p>1. Click on third icon from left in VS Code. On top 3 dots will appear. Click on three dots. “<strong>Remote</strong>” option will come. Under that “<strong>Add Remote</strong>” will be visible and click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Gn_NO5E5AtZYlQXB.png" /></figure><p>2. Enter cloned repository URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VJU1bylyO7Zp_rjx.png" /></figure><p>3. Enter username from the file which you downloaded earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eNZRUoopNPil8zt8.png" /></figure><p>4. Enter password from the file which you downloaded earlier. Click on “<strong>Enter</strong>” button from your keyboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*WhvqZuyqnrCGzqiW.png" /></figure><p>5. Click on “<strong>Add permissions</strong>” dropdown and click on “<strong>Add permissions</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eoN1RcYdEa81xfde.png" /></figure><p>6. Click on “<strong>Next</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3E7ANUSz5_4C5TpB.png" /></figure><p>7. Click on “<strong>Add permissions</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SFBmk5il4XQtc8bY.png" /></figure><p>8. Your policy will be created and added to your user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pLLxE0U2FEGlVMsQ.png" /></figure><ul><li><strong>Add a new file from local and commit to your local branch.</strong></li></ul><ol><li>Go to your VS Code. Clone your repository from CodeCommit using command “<strong>git clone &lt;repository_url&gt;</strong>”. Make a new file “<strong>index.html</strong>” and write desired code in it as given below in the screenshot.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FFLaEoZpuf_6aw3_.png" /></figure><p>2. Fire the command “<strong>git status</strong>”, “<strong>git add .</strong>”, “<strong>git comit -m “&lt;any_message&gt;”</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*svPyDhdxNghndrPm.png" /></figure><ul><li>Push the local changes to CodeCommit repository.</li></ul><ol><li>Fire the command “<strong>git push origin master</strong>” to push newly made file in local to CodeCommit repository.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xHnKAmBP18-XWu3R.png" /></figure><p>2. Open CodeCommit. Go to your repository and click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6nz03AfpUevDLP1S.png" /></figure><p>3. You will be able to see “<strong>index.html</strong>” file in your repositoory.</p><ul><li>create a simple index.html file in CodeCommit Repository</li></ul><ol><li>Login to aws account by using valid credentials. Search “<strong>CodeCommit</strong>” from search box and click on it. Click on “<strong>Create repository</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_meWpiZpwuPgfjaY.png" /></figure><p>2. Enter mandatory details like “<strong>Repository name</strong>”. Click on “<strong>Create</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*IudxuDqGnectvZbb.png" /></figure><p>3. Repository will be created and visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*o_5wpQnPtE9Uh3ij.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gvMi8kivwgiSb8jR.png" /></figure><p>4. Open visual studio code and open a new terminal. Give command “<strong>git status</strong>”. Error will come.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*RlYfvwCfNscSqxLi.png" /></figure><p>5. Go to search box in aws console. Search for “<strong>IAM</strong>”. Click on “<strong>Users</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*yfCjbMvUJgXPzLQF.png" /></figure><p>6. Your user will be visible. Click on the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dWBk1uxRk6nICgT4.png" /></figure><p>7. After clicking on user, navigate to “<strong>Security credentials</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EELUOpGWLXRe4JWl.png" /></figure><p>8. Under security credentials, scroll down and come to “<strong>HTTPS Git credentials for AWS CodeCommit</strong>”. Click on “<strong>Generate credentials</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jXSjPP4xxU6SXpDW.png" /></figure><p>9. Download your credentials in your system for further usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4xXvgru8FGmF-fpw.png" /></figure><p>10. Click on third icon from left in VS Code. On top 3 dots will appear. Click on three dots. “<strong>Remote</strong>” option will come. Under that “<strong>Add Remote</strong>” will be visible and click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6GZu0mHuRCYpkQT0.png" /></figure><p>11. Enter cloned repository URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6S9gvVTH4om-YHH4.png" /></figure><p>12. Enter username from the file which you downloaded earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*33qr1i9gN8MIqunb.png" /></figure><p>13. Enter password from the file which you downloaded earlier. Click on “<strong>Enter</strong>” button from your keyboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*g0b3QMcv2tY9NWrt.png" /></figure><p>14. Click on “<strong>Add permissions</strong>” dropdown and click on “<strong>Add permissions</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cqoOyy6gBjE2fFEI.png" /></figure><p>15. Click on “<strong>Next</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*WqQ8RO2KOE1VF0UA.png" /></figure><p>16. Click on “<strong>Add permissions</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dHEpH1-jhUCkl4eD.png" /></figure><p>17. Your policy will be created and added to your user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9uXl4R35oRdODkPI.png" /></figure><p>18. Go to your VS Code. Clone your repository from CodeCommit using command “<strong>git clone &lt;repository_url&gt;</strong>”. Make a new file “<strong>index.html</strong>” and write desired code in it as given below in the screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*WgxyQ1JMvniRZRou.png" /></figure><p>19. Fire the command “<strong>git status</strong>”, “<strong>git add .</strong>”, “<strong>git comit -m “&lt;any_message&gt;”</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PcdjcPXGnA4TYnpO.png" /></figure><p>20. Fire the command “<strong>git push origin master</strong>” to push newly made file in local to CodeCommit repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*nWxRqvrHokfSAZkE.png" /></figure><p>21. Open CodeCommit. Go to your repository and click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Mw1CBjmrq687XhEP.png" /></figure><p>22. You will be able to see “<strong>index.html</strong>” file in your repositoory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MnFFZbI581f31_NH.png" /></figure><ul><li><strong>You have to build the index.html using nginx server.</strong></li></ul><ol><li>Go to CodeBuild in aws.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*QO8nYIpjBkiWNfyS.png" /></figure><p>2. Enter mandatory details like Project name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*c28CgTSdGJZdqif9.png" /></figure><p>3. Choose “<strong>AWS CodeCommit</strong>” from “<strong>Source provider</strong>” dropdown box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Db3xYxWPWwgkjhzH.png" /></figure><p>4. Choose the repository which you had already created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EjNUtAZvek0982Vm.png" /></figure><p>5. Chose <strong>Branch</strong> as “<strong>master</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*O4SypFpbAWo0_T8g.png" /></figure><p>6. Choose <strong>Operating system</strong> as “<strong>Ubuntu</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cZoPPwqk9l_0SEsO.png" /></figure><p>7. Choose Image as the latest one available from “<strong>Image</strong>” dropdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_yasngPO_msO_ZJp.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*n1uFobbfSpW1VsGG.png" /></figure><ul><li><strong>Add buildspec.yaml file to CodeCommit Repository and complete the build process.</strong></li></ul><ol><li>Go to your VS Code. Make a file with name “<strong>buildspec.yml</strong>”. Add configurations to install nginx as given below in the screenshot and save the file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dGUEacb8_hcFMcCD.png" /></figure><p>2. Fire commands: “<strong>git add buildspec.yml</strong>”, “<strong>git commit -m &lt;”any_message”&gt;</strong>” and “<strong>git push origin master</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*U9t88Dl4ZpEyPh0E.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5VUfLW9dQ2AZnGaj.png" /></figure><p>3. The buildspec.yml file will be visible in CodeCommit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*DILt5Epo5zx8Djwa.png" /></figure><p>4. Go back to CodeBuild where you left the <strong>Task 1</strong>. Scroll down and click on “<strong>Create build project</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*t-b3LQt1F9NN-DNe.png" /></figure><p>5. Your project will be created successfully. Click on “<strong>Start build</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5v5kqNaYbTkQxDT6.png" /></figure><p>6. Project will start building.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rmmLUNGDTwpxCP6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4FYahGELZjgZ-MWV.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*h1LLUqLJ4v9Uqg8m.png" /></figure><p>7. After sometime, project will be build successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VGsUSFM7fFPUSpM-.png" /></figure><p><strong>Create a CodeDeploy application:</strong></p><p>You need to create a CodeDeploy application to deploy your index.html file. You can do this in the AWS Management Console.</p><ol><li>In CodeDeploy, go to Applications and click on ‘Create application’.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MPCar7ckQIEJahSQ.png" /></figure><p>2. Select compute platform ‘EC2/on premises’ and click on ‘Create application’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SIRLzbj5DUaHplSK.png" /></figure><p>3. Application is successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*mf-m6hAlxc8k3bLM.png" /></figure><p>4. Create ‘service role’ for enabling communication between code deploy and other aws services.</p><p>Go to IAM service and create ‘code-deploy-service-role’ with below permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ymek0OvsEm9AW-JM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*X9jJ8xYiXzKu9JND.png" /></figure><p>5. Set up an EC2 instance:</p><p>You will need to create an EC2 instance on which you want to deploy the index.html file.</p><p>Create a ubuntu EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*50OZHKxB6mFbwv8X.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9DNLFx3XCNBnA8fO.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uIBlIfy_DkqNOHgf.png" /></figure><p>6. Create a deployment group:</p><p>Once you have created a CodeDeploy application, you need to create a deployment group. A deployment group is a set of EC2 instances where you want to deploy your application.</p><p>Add deployment group name and choose ‘Service role’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6RQvZzfhUjkLme03.png" /></figure><p>7. Add instance name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*j3NFE1eFDFXtslrF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fLtggSpqrF70zrw1.png" /></figure><p>8. Click on ‘Create deployment group’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gROkDgeUTgHqY6Th.png" /></figure><p>9. Deployment group is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*19CtJFi5SdDaxHEx.png" /></figure><h3>You have to setup a CodeDeploy agent in order to deploy code on EC2.</h3><p>Install the CodeDeploy agent:</p><p>You need to install the CodeDeploy agent on your Ubuntu EC2 instance. The CodeDeploy agent is a software package that runs on your instance and interacts with CodeDeploy to deploy your application. You can install the CodeDeploy agent by running the following script on your EC2 instance:</p><p>10. Run the script using command “<strong>vim install.sh</strong>” and paste configuration as given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*NQrdEehz5reFem8Q.png" /></figure><p>11. Run command “<strong>bash install.sh</strong>” to run your bash file which is created in previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8spY0yTmCX-5e9oL.png" /></figure><p>12. Check whether code agent is running by firing command “<strong>sudo service code-deploy agent status</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*S4e6aT2dSIbGDot2.png" /></figure><p>13. Create an index.html file:</p><p>You need to create an index.html file that you want to deploy. You can create a simple HTML file using any text editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*j-czQwKZGV8e5u-6.png" /></figure><h3><strong>Add appspec.yaml file to CodeCommit Repository and complete the deployment process.</strong></h3><ol><li>Create an appspec.yaml file:</li></ol><p>You need to create an appspec.yaml file that tells CodeDeploy what to do with your application. Here is an appspec.yaml file that deploys the index.html file on nginx. also create 2 scripts for installing nginx and starting nginx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7H4yY0qSHAfCoSS2.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*itAoJDID7ztEtDW8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*F4V5cxNvzzZHtrVw.png" /></figure><p>2. Push all the files to code commit using ‘git add’ and ‘git commit’ commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jW17Gz0-cnuahm6v.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*obQyJcEaWQgYGVxr.png" /></figure><p>3. All the files updated in code commit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PSBzUVl18MtHbiUU.png" /></figure><p>4. Add changes to buildspec.yml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*x56mVhjdLY5cpyZM.png" /></figure><p>5. In build projects, Edit and choose ‘Artifacts’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kjBPSYh3HGWHJDRB.png" /></figure><p>6. First create ‘S3 bucket’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8woKwvNESHEYrUg5.png" /></figure><p>7. In Artifacts, select artifact type as Amazon S3 and choose bucket name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*unVQOPPyYaGhTPOO.png" /></figure><p>8. Click on ‘Update artifacts’.</p><p>9. Artifact upload location successfully added. Click on ‘Start build’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vAZay2XCQNThLiIu.png" /></figure><p>10. Build is Succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*18Z06SBh6f0nDZTN.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AtltfajFiyE6tQqG.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rh44xTHwyi11VEgO.png" /></figure><p>11. After build completion, go to S3 bucket and copy S3 url of code_output zip file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*BfywD-80wTMcNRWz.png" /></figure><p>12. Create deployment:</p><p>In Application, Go to Deployments and click on ‘Create deployment’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PgIQkMG4kEwMjNhT.png" /></figure><p>13. In revision type, select amazon S3 and paste above copied S3 url to revision location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_9JYBhIwCe8X3ZC5.png" /></figure><p>14. Click on ‘Create deployment’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0LqoBo-56mr9HlKm.png" /></figure><p>15. Deployment is created. but events are in pending state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ULshHz0afrIIZrU9.png" /></figure><p>16. EC2 doesn’t have any role policy to retrieve the data from S3 to CodeDeploy.</p><p>So create a new service role for enabling communication between EC2 and S3, code deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*spwJKbXAQT1rCf0j.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AISXxv3-zY2tdpkG.png" /></figure><p>17. Attach that service role to EC2 instance.</p><p>Select EC2 instance, In actions, go to security and click on ‘Modify IAM role’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*K4WRXJ0cqeAJC70r.png" /></figure><p>18. Select service role that we created in above steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rJ3eW5wmS9DEZG77.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FWPAAoQm_6jKZxz9.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*McUPkHmXyqavBRv4.png" /></figure><p>19. After updating IAM role, restart code-deploy agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*yMLpg2ulVEqihLB4.png" /></figure><p>20. Deployment status is Succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*e7BljTiaDdZlQYTE.png" /></figure><p>All events Succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dOgebmsNrjFjtMJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*17Y13vp7h2YU-s_B.png" /></figure><p>21. Browse instance public IP address, it will show output of index.html file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4t_k_Lgt-pKCe9WQ.png" /></figure><h3>Create a Deployment group of EC2 Instance.</h3><p>You need to create a CodeDeploy application to deploy your index.html file. You can do this in the AWS Management Console.</p><ol><li>In CodeDeploy, go to Applications and click on ‘Create application’.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*O0GCCItnT13TCF6A.png" /></figure><p>2. Select compute platform ‘EC2/on premises’ and click on ‘Create application’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*zO5DEhBLbSTO5C-n.png" /></figure><p>3. Application is successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*1q13FyRigfgw64_D.png" /></figure><p>4. Create ‘service role’ for enabling communication between code deploy and other aws services.</p><p>Go to IAM service and create ‘code-deploy-service-role’ with below permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Cj-KTF3jZgCBUcCn.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0L8OrMapY0FGH__a.png" /></figure><p>5. Set up an EC2 instance:</p><p>You will need to create an EC2 instance on which you want to deploy the index.html file.</p><p>Create a ubuntu EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*DxLNU5spG4xbAO7n.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*togTZupzuJSZXqdP.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-zmDoHO_Hiv9F4mr.png" /></figure><p>6. Create a deployment group:</p><p>Once you have created a CodeDeploy application, you need to create a deployment group. A deployment group is a set of EC2 instances where you want to deploy your application.</p><p>Add deployment group name and choose ‘Service role’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ySsGOkdhO6Z3VYTW.png" /></figure><p>7. Add instance name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*nMsQiWIa4u0z_WHL.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*BdxSFIC3rgbGYFVG.png" /></figure><p>8. Click on ‘Create deployment group’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*j8zTM1b17twg6MfQ.png" /></figure><p>9. Deployment group is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-DVpqCbNk7cT3kwG.png" /></figure><h3>You have to setup a CodeDeploy agent in order to deploy code on EC2.</h3><p>Install the CodeDeploy agent:</p><p>You need to install the CodeDeploy agent on your Ubuntu EC2 instance. The CodeDeploy agent is a software package that runs on your instance and interacts with CodeDeploy to deploy your application. You can install the CodeDeploy agent by running the following script on your EC2 instance:</p><p>10. Run the script using command “<strong>vim install.sh</strong>” and paste configuration as given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*82IMYBYbAWz_1miE.png" /></figure><p>11. Run command “<strong>bash install.sh</strong>” to run your bash file which is created in previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_OEPAAyUgNCSIFlM.png" /></figure><p>12. Check whether code agent is running by firing command “<strong>sudo service code-deploy agent status</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MntHGucjQCSHRtGS.png" /></figure><h3>Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild and deploys it to a Deployment Group.</h3><ol><li>Go to the CodePipeline console. Click “<strong>Create pipeline</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ry8NB3VtgBB6wLR3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kbLVUAkXmhBGdiCL.png" /></figure><p>2. Enter a name for your pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0CcUYoN4tNzE4uLq.png" /></figure><p>3. Under “<strong>Source provider</strong>,” choose “<strong>AWS CodeCommit</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uyQFnlT4aOu6Oo5W.png" /></figure><p>4. Select the repository and branch you want to deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*B0F2lD1NJ5jF-Hhe.png" /></figure><p>5. Click “<strong>Next</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*68Rc0XBItaDPakZB.png" /></figure><p>6. Under “<strong>Build provider</strong>,” choose “<strong>AWS CodeBuild</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*lpCVLxTj-QexmzOg.png" /></figure><p>7. Select “<strong>build project name</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dEr82iR7QUjFepM8.png" /></figure><p>8. Click “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tp2LvtjFCMLtDEIm.png" /></figure><p>9. Under “Deploy provider,” choose “AWS CodeDeploy.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*NVcPqbCUCxJU_DzS.png" /></figure><p>10. Select the deployment group you created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*q2q4jPh2dtjdmOwW.png" /></figure><p>11. Click “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Pbt3sfld_RuQ-ojk.png" /></figure><p>12. Review the pipeline settings and click “<strong>Create pipeline</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9Kf81WSbdaz9tgWM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qnfpUWd1WtN_wz2F.png" /></figure><p>13. The pipeline will automatically trigger a build and deploy the new code to the EC2 instance.</p><p>Successfully created a CodePipeline that automates the deployment process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*nSU4JhVkr8HenHsR.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Oi1L1rtulQr70Aug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*nNYeNAMsbuyMc6GU.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0tGXYdAxHfeDoo9J.png" /></figure><p>14. Browse your instance public-ip address, you can see final output of index.html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gmz2UyN8jEGmInvN.png" /></figure><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2464dda6ac34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 53: Your CI/CD pipeline on AWS — Part 4  ☁]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-53-your-ci-cd-pipeline-on-aws-part-4-45219dad1ee2?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/45219dad1ee2</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 22:19:33 GMT</pubDate>
            <atom:updated>2023-03-09T22:19:33.846Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 53: Your CI/CD pipeline on AWS — Part 4 🚀 ☁</h3><h3>What is CodePipeline ?</h3><ul><li>CodePipeline builds, tests, and deploys your code every time there is a code change, based on the release process models you define. Think of it as a CI/CD Pipeline service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*8zKIYm4XzdGf6zvA.png" /></figure><h3>Task-01 :</h3><h3>1. Create a Deployment group of EC2 Instance.</h3><p>You need to create a CodeDeploy application to deploy your index.html file. You can do this in the AWS Management Console.</p><ol><li>In CodeDeploy, go to Applications and click on ‘Create application’.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HYzwvebRW_GttbRd.png" /></figure><p>2. Select compute platform ‘EC2/on premises’ and click on ‘Create application’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vUtlk0GWQJQrMs4F.png" /></figure><p>3. Application is successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*weMCntELh6WmbxMA.png" /></figure><p>4. Create ‘service role’ for enabling communication between code deploy and other aws services.</p><p>Go to IAM service and create ‘code-deploy-service-role’ with below permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Awrjn_siqiQcrWxL.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Wm5KyFrTnG7eN4dt.png" /></figure><p>5. Set up an EC2 instance:</p><p>You will need to create an EC2 instance on which you want to deploy the index.html file.</p><p>Create a ubuntu EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*leCxgEBUhTWs3G3v.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*KY5OAbfg8giCp1zM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VWN_byAqGMTMVJYP.png" /></figure><p>6. Create a deployment group:</p><p>Once you have created a CodeDeploy application, you need to create a deployment group. A deployment group is a set of EC2 instances where you want to deploy your application.</p><p>Add deployment group name and choose ‘Service role’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gnz3LhnnPWDjAw-y.png" /></figure><p>7. Add instance name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8HAq65hWa_2KZeB-.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-P16th2xlj-MZQhH.png" /></figure><p>8. Click on ‘Create deployment group’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*YwAtFz-JWpN3hAL0.png" /></figure><p>9. Deployment group is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Y_35mHKQyxtyYgOe.png" /></figure><h3>You have to setup a CodeDeploy agent in order to deploy code on EC2.</h3><p>Install the CodeDeploy agent:</p><p>You need to install the CodeDeploy agent on your Ubuntu EC2 instance. The CodeDeploy agent is a software package that runs on your instance and interacts with CodeDeploy to deploy your application. You can install the CodeDeploy agent by running the following script on your EC2 instance:</p><p>10. Run the script using command “<strong>vim install.sh</strong>” and paste configuration as given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JgLGFiXnM5zB7lX9.png" /></figure><p>11. Run command “<strong>bash install.sh</strong>” to run your bash file which is created in previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*S0HZMXVKFQml9OHW.png" /></figure><p>12. Check whether code agent is running by firing command “<strong>sudo service code-deploy agent status</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cO95jDXiuEw4WU_N.png" /></figure><h3>2. Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild and deploys it to a Deployment Group.</h3><ol><li>Go to the CodePipeline console. Click “<strong>Create pipeline</strong>”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQTfuwUGzpL05GTEt4Biug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3f1JSrkXMgGVN1atsd0ujw.png" /></figure><p>2. Enter a name for your pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1q1E6RFjxYshq-DASauQRg.png" /></figure><p>3. Under “<strong>Source provider</strong>,” choose “<strong>AWS CodeCommit</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sK9k32rvotUfiFOE3_qNBA.png" /></figure><p>4. Select the repository and branch you want to deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0YDjassTVCMX-jUeDaa5-Q.png" /></figure><p>5. Click “<strong>Next</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3a2QJb1oZ28FHTuqdyNTQ.png" /></figure><p>6. Under “<strong>Build provider</strong>,” choose “<strong>AWS CodeBuild</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPZ-myTq0uoiqW19yNN72g.png" /></figure><p>7. Select “<strong>build project name</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPZ-myTq0uoiqW19yNN72g.png" /></figure><p>8. Click “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPZ-myTq0uoiqW19yNN72g.png" /></figure><p>9. Under “Deploy provider,” choose “AWS CodeDeploy.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wO-ZfUog9JwRlPVUMkSkmw.png" /></figure><p>10. Select the deployment group you created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEPGNBBN-kNfRcDj14WdLA.png" /></figure><p>11. Click “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEPGNBBN-kNfRcDj14WdLA.png" /></figure><p>12. Review the pipeline settings and click “<strong>Create pipeline</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOJCzJI6ZcMYHg6Vzi35Mw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_o-I8dhqxJnxsIho-LJrw.png" /></figure><p>13. The pipeline will automatically trigger a build and deploy the new code to the EC2 instance.</p><p>Successfully created a CodePipeline that automates the deployment process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QKLDoRNC4dML8q3kIR7NKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhH-qYMtbcylrXnHEOPuoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njQWfEg5vW7TL5HF-ob7gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N4TcHs92rkQ4JUpfCUfXMg.png" /></figure><p>14. Browse your instance public-ip address, you can see final output of index.html</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JB_w-8ibBAFUCqzXWj69lw.png" /></figure><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45219dad1ee2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 52: Your CI/CD pipeline on AWS — Part 3  ☁]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-52-your-ci-cd-pipeline-on-aws-part-3-16306b9c377?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/16306b9c377</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 21:44:37 GMT</pubDate>
            <atom:updated>2023-03-09T21:44:37.551Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 52: Your CI/CD pipeline on AWS — Part 3 🚀 ☁</h3><p>Next few days you’ll learn these tools/services:</p><ul><li>CodeDeploy</li><li>CodePipeline</li><li>S3</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*II29QxhkgYuQRUN0.png" /></figure><h3>What is CodeDeploy ?</h3><ul><li>AWS CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services.</li></ul><p>CodeDeploy can deploy application content that runs on a server and is stored in Amazon S3 buckets, GitHub repositories, or Bitbucket repositories. CodeDeploy can also deploy a serverless Lambda function. You do not need to make changes to your existing code before you can use CodeDeploy.</p><h3>Task-01 :</h3><ul><li>Read about Appspec.yaml file for CodeDeploy.</li></ul><p>The AppSpec (short for Application Specification) file is a YAML-formatted file used by AWS CodeDeploy to define the deployment configuration and instructions for deploying an application to a target environment.</p><p>The AppSpec file contains several sections that define different aspects of the deployment process:</p><ol><li><strong>Version:</strong> This section specifies the version of the AppSpec file format being used.</li><li><strong>Resources:</strong> This section defines the source code and other resources to be deployed. This includes the location of the application files, any pre- or post-deployment scripts, and any dependencies required by the application.</li><li><strong>Hooks:</strong> This section contains the deployment lifecycle event hooks, which are scripts or executables that are run at specific stages of the deployment process. For example, you might use a hook to run database migrations or to restart a web server after deployment.</li><li><strong>Permissions:</strong> This section defines the AWS Identity and Access Management (IAM) permissions required by the deployment process to access AWS resources, such as Amazon S3 buckets or AWS Lambda functions.</li><li><strong>Variables:</strong> This section defines environment variables that are used by the application during deployment. You can use variables to provide configuration information, such as database connection strings or API keys.</li></ol><p>The AppSpec file must be located in the root directory of the application source code and must be named “appspec.yml” or “appspec.yaml”. When you create a deployment group in CodeDeploy, you can specify the location of the AppSpec file in the deployment configuration.</p><p>Overall, the AppSpec file is a powerful tool for defining the deployment process for your applications and ensuring consistency and repeatability in your deployment process.</p><h3>Deploy index.html file on EC2 machine using nginx</h3><p>For code commit and code build steps, please follow my Day 51 task article.</p><p><strong>Create a CodeDeploy application:</strong></p><p>You need to create a CodeDeploy application to deploy your index.html file. You can do this in the AWS Management Console.</p><ol><li>In CodeDeploy, go to Applications and click on ‘Create application’.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6zdVFxFt0iffxa63ba1xQ.png" /></figure><p>2. Select compute platform ‘EC2/on premises’ and click on ‘Create application’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ioqR9gANCtl9R-1v8VHk0A.png" /></figure><p>3. Application is successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNTb-5B65ugQ1Fti5EGyZw.png" /></figure><p>4. Create ‘service role’ for enabling communication between code deploy and other aws services.</p><p>Go to IAM service and create ‘code-deploy-service-role’ with below permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cOPupJqI-_A4TWXbwYG0Jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fdc0bKEQGIqtyK6hgvQ2Uw.png" /></figure><p>5. Set up an EC2 instance:</p><p>You will need to create an EC2 instance on which you want to deploy the index.html file.</p><p>Create a ubuntu EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOS092C1nReEBjMZjACFyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XOHbhCC9_xR3HigX2myfwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKONLxDqsYX98ksGNhzGOQ.png" /></figure><p>6. Create a deployment group:</p><p>Once you have created a CodeDeploy application, you need to create a deployment group. A deployment group is a set of EC2 instances where you want to deploy your application.</p><p>Add deployment group name and choose ‘Service role’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wz-OrPOaiA7s_BXKWYfDGA.png" /></figure><p>7. Add instance name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plbjhAx7VSzX3Q4Tyx38ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-IuqdpsxVReAFEgNI5n3A.png" /></figure><p>8. Click on ‘Create deployment group’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vu6autBn6v_am0rctRyS0g.png" /></figure><p>9. Deployment group is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*la_v9tSubHpk9LAkueVDjg.png" /></figure><h3>You have to setup a CodeDeploy agent in order to deploy code on EC2.</h3><p>Install the CodeDeploy agent:</p><p>You need to install the CodeDeploy agent on your Ubuntu EC2 instance. The CodeDeploy agent is a software package that runs on your instance and interacts with CodeDeploy to deploy your application. You can install the CodeDeploy agent by running the following script on your EC2 instance:</p><p>10. Run the script using command “<strong>vim install.sh</strong>” and paste configuration as given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHocHtAIxRtUAwtJ1eAuxg.png" /></figure><p>11. Run command “<strong>bash install.sh</strong>” to run your bash file which is created in previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IISU15Jzi-vM-KJIEuNJYg.png" /></figure><p>12. Check whether code agent is running by firing command “<strong>sudo service code-deploy agent status</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjvUELQSI-omEU7sg2X-Xw.png" /></figure><p>13. Create an index.html file:</p><p>You need to create an index.html file that you want to deploy. You can create a simple HTML file using any text editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RAAzDBICrHvdQmAohrDYYw.png" /></figure><h3>Task-02 :</h3><h3>Add appspec.yaml file to CodeCommit Repository and complete the deployment process.</h3><ol><li>Create an appspec.yaml file:</li></ol><p>You need to create an appspec.yaml file that tells CodeDeploy what to do with your application. Here is an appspec.yaml file that deploys the index.html file on nginx. also create 2 scripts for installing nginx and starting nginx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JAiAbA5tW5-eaQavTH_uLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BL2cgswUUlmp1Bzo1_51g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UgZTohOZY_Xov2snWrRXqQ.png" /></figure><p>2. Push all the files to code commit using ‘git add’ and ‘git commit’ commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3zzzVqES6XDazb3kG_jvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*C-Vwd-787YjPi0BdELYjtw.png" /></figure><p>3. All the files updated in code commit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IktKjZT-r54PNPsVKRGvCA.png" /></figure><p>4. Add changes to buildspec.yml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FwcJ83NQRbWcF9fBd_xtSg.png" /></figure><p>5. In build projects, Edit and choose ‘Artifacts’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A6tz8ZFPT6c0GHy3lDaA5w.png" /></figure><p>6. First create ‘S3 bucket’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wsGjuR-EMb_0dehVNBZOPA.png" /></figure><p>7. In Artifacts, select artifact type as Amazon S3 and choose bucket name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xa_N7oLgSkVNrnHQdZXLKA.png" /></figure><p>8. Click on ‘Update artifacts’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*henGmHZkIrjPPurPP5kUmQ.png" /></figure><p>9. Artifact upload location successfully added. Click on ‘Start build’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23Egx4_PmRZmLNVINuB92Q.png" /></figure><p>10. Build is Succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwNhUfpko5v_SLAJ-pU-lw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xc-MRZMPByDc5E6vuhs8rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGuVR84sdGrrYqrHfVwx5w.png" /></figure><p>11. After build completion, go to S3 bucket and copy S3 url of code_output zip file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vx0Ldq2aubYrCUebnhRaLA.png" /></figure><p>12. Create deployment:</p><p>In Application, Go to Deployments and click on ‘Create deployment’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEPQO6cvvkCnMi-4t0raOg.png" /></figure><p>13. In revision type, select amazon S3 and paste above copied S3 url to revision location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRTwmntHNwnEvpEi8kcUNw.png" /></figure><p>14. Click on ‘Create deployment’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ExPbWS4XsQEV-j-RFkrpog.png" /></figure><p>15. Deployment is created. but events are in pending state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kg2Nwzg6FWNzEPjlOyp7Sg.png" /></figure><p>16. EC2 doesn’t have any role policy to retrieve the data from S3 to CodeDeploy.</p><p>So create a new service role for enabling communication between EC2 and S3, code deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0b4c_V46f8HH-gxPTyu9gA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31joDJ7E1NgH54mWSKxyUw.png" /></figure><p>17. Attach that service role to EC2 instance.</p><p>Select EC2 instance, In actions, go to security and click on ‘Modify IAM role’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BAWTca8LW2b2HhsiWcl_Eg.png" /></figure><p>18. Select service role that we created in above steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VorfXCUHh2IsPniub_Pfiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aSU5pRZfD3NRgkKp06jg-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dl_4kQCHu-aRDpy8hja9dw.png" /></figure><p>19. After updating IAM role, restart code-deploy agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-f-TmmGR7SGNxJFBn5dhw.png" /></figure><p>20. Deployment status is Succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtz8BvD2eyQQv9lQYT6_RA.png" /></figure><p>All events Succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uzZeME2rnRoYRjcpJ8pYAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vi9llwGAg6jj8vxlUewF9w.png" /></figure><p>21. Browse instance public IP address, it will show output of index.html file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qV-fSU_aIZhBV8XSEDqlpQ.png" /></figure><p>Thanks for readingt the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16306b9c377" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 60 — Terraform]]></title>
            <link>https://medium.com/@vaibhavkhullar55/day-60-terraform-17a5ca43e9c?source=rss-7f35a5ef74e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/17a5ca43e9c</guid>
            <dc:creator><![CDATA[Vaibhav Khullar]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 19:34:38 GMT</pubDate>
            <atom:updated>2023-03-09T19:34:38.831Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 60 — Terraform🔥</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*O6ijOdJiNMlFu9Qp.png" /></figure><h3>What is Terraform?</h3><p>Terraform is an infrastructure as code (IaC) tool that allows you to create, manage, and update infrastructure resources such as virtual machines, networks, and storage in a repeatable, scalable, and automated way.</p><h3>Task 1:</h3><p>Install Terraform on your system.</p><ol><li>Make a new instance by giving desired name, key-pair etc.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QmfUD0iPLE_EQ6zyTRlQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YzJ9I0X4h9_0aqwjOPwDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*97PzdvVROcjm9AiwMN_L-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6bRCb8NfJFESCKTgnTJFNw.png" /></figure><p>2. Go to “<a href="https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli"><strong>https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli</strong></a>” . Navigate to install terraform and select “<strong>Linux</strong>”. Copy the command given below and run it in your newly made instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5RZNlS6I2xRfeXR3Zh9iA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OFD7923GX7_f7nKj7jIs7g.png" /></figure><p>3. Install the HashiCorp GPG key by copying given below command and pasting it in instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S51B6n_1Gnf020cXMwDTIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*rg6xhrkT56__7N0AR92XXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hS60sfriqxmWgWc_2fXkqA.png" /></figure><p>4. Verify the key’s fingerprint by copying given below command and pasting it in instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1K_vy-rB8xt8ays3mDwZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AOmJuLku48h3TIMXhhouEg.png" /></figure><p>5. Add the official HashiCorp repository to your system by copying given below command and pasting it in instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYOuaPVKx4E2FeDSiRrgHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*71DJlaC-9-dKjYl-xpX3YA.png" /></figure><p>6. Fire the command “<strong>sudo apt update</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-k_Qr9oI1jo_5E3uTYcqzw.png" /></figure><p>7. Run the command “<strong>sudo apt-get install terraform</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1mkIInSrp7UnYTsjPHO8YQ.png" /></figure><p>8. Fire the command “<strong>terraform — version</strong>” to check that terraform is successfully installed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*vpXWRKrehVxI_H6fUlaQpw.png" /></figure><h3>Task 2: Answer below questions</h3><ul><li>Why we use terraform?</li></ul><p>Terraform is a tool used for infrastructure automation and management. It allows users to define infrastructure as code, making it easy to provision and manage cloud resources across multiple providers. Terraform provides a simple and efficient way to create and manage infrastructure in a scalable and reproducible manner.</p><ul><li>What is Infrastructure as Code (IaC)?</li></ul><p>Infrastructure as Code (IaC) is an approach to infrastructure automation and management that involves defining infrastructure as code. This means that infrastructure is defined using code, rather than manual processes or graphical interfaces. IaC allows for automation of infrastructure provisioning, configuration, and management, resulting in faster and more efficient infrastructure management.</p><ul><li>What is Resource?</li></ul><p>In Terraform, a resource refers to any cloud infrastructure component that can be managed as code. Resources can include anything from virtual machines, storage accounts, network interfaces, and more.</p><ul><li>What is Provider?</li></ul><p>A provider in Terraform is a plugin that allows Terraform to interact with a specific cloud provider, such as Amazon Web Services, Google Cloud Platform, or Microsoft Azure. The provider defines the set of resources that can be created, modified, and deleted using Terraform.</p><ul><li>Whats is State file in terraform? What’s the importance of it ?</li></ul><p>The state file in Terraform is a JSON file that stores the current state of the infrastructure being managed by Terraform. The state file is important because it keeps track of the resources that have been created, their current configuration, and their dependencies. Terraform uses the state file to determine what changes need to be made to the infrastructure to reach the desired state.</p><ul><li>What is Desired and Current State?</li></ul><p>Desired state refers to the configuration of infrastructure that a user wants to achieve. This configuration is defined using Terraform code. Current state, on the other hand, refers to the current configuration of the infrastructure being managed by Terraform. Terraform uses the desired state and the current state to determine what changes need to be made to the infrastructure to reach the desired state.</p><p>Thanks for reading the blog. Hope it helps!</p><p>— Vaibhav Khullar</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17a5ca43e9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>