<?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 Ajay Pathak on Medium]]></title>
        <description><![CDATA[Stories by Ajay Pathak on Medium]]></description>
        <link>https://medium.com/@ajaypathak372?source=rss-2410adbaca93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OupDMW_Wy84Iu97aCSQiIQ@2x.jpeg</url>
            <title>Stories by Ajay Pathak on Medium</title>
            <link>https://medium.com/@ajaypathak372?source=rss-2410adbaca93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 05:39:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajaypathak372/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[GitOps: CI/CD using GitHub Actions and ArgoCD on Kubernetes]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/gitops-ci-cd-using-github-actions-and-argocd-on-kubernetes-909d85d37746?source=rss-2410adbaca93------2"><img src="https://cdn-images-1.medium.com/max/2600/1*uzsMOm_iHwlmgD0Rlka5tQ.jpeg" width="5575"></a></p><p class="medium-feed-snippet">Deploying Helm Charts on AWS EKS Cluster using ArgoCD and GitOps</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/gitops-ci-cd-using-github-actions-and-argocd-on-kubernetes-909d85d37746?source=rss-2410adbaca93------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/gitops-ci-cd-using-github-actions-and-argocd-on-kubernetes-909d85d37746?source=rss-2410adbaca93------2</link>
            <guid isPermaLink="false">https://medium.com/p/909d85d37746</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Ajay Pathak]]></dc:creator>
            <pubDate>Mon, 27 Dec 2021 11:51:04 GMT</pubDate>
            <atom:updated>2022-02-06T17:35:12.379Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Terraform: Serverless Kubernetes Cluster with AWS EKS]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/serverless-webhosting-with-aws-eks-on-fargate-using-terraform-fcd1d98170c1?source=rss-2410adbaca93------2"><img src="https://cdn-images-1.medium.com/max/2048/1*YieBnXu12EaoWnfIr66A3Q.jpeg" width="2048"></a></p><p class="medium-feed-snippet">Running Pods on Fargate with EKS and exposing them for the outside world using Terraform</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/serverless-webhosting-with-aws-eks-on-fargate-using-terraform-fcd1d98170c1?source=rss-2410adbaca93------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/serverless-webhosting-with-aws-eks-on-fargate-using-terraform-fcd1d98170c1?source=rss-2410adbaca93------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcd1d98170c1</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ajay Pathak]]></dc:creator>
            <pubDate>Tue, 02 Feb 2021 13:49:25 GMT</pubDate>
            <atom:updated>2021-02-03T06:03:22.032Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Automate Hadoop Cluster Deployment on top of AWS using Ansible]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.devgenius.io/automate-hadoop-cluster-deployment-on-top-of-aws-using-ansible-194b623b9103?source=rss-2410adbaca93------2"><img src="https://cdn-images-1.medium.com/max/879/1*d-S0uLimWA6ILqjyUvJZ5Q.png" width="879"></a></p><p class="medium-feed-snippet">This tutorial will walk you through the process of using Ansible to deploy Hadoop Cluster on AWS.</p><p class="medium-feed-link"><a href="https://blog.devgenius.io/automate-hadoop-cluster-deployment-on-top-of-aws-using-ansible-194b623b9103?source=rss-2410adbaca93------2">Continue reading on Dev Genius »</a></p></div>]]></description>
            <link>https://blog.devgenius.io/automate-hadoop-cluster-deployment-on-top-of-aws-using-ansible-194b623b9103?source=rss-2410adbaca93------2</link>
            <guid isPermaLink="false">https://medium.com/p/194b623b9103</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Ajay Pathak]]></dc:creator>
            <pubDate>Sat, 26 Dec 2020 09:10:37 GMT</pubDate>
            <atom:updated>2021-01-05T08:57:21.158Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Getting Started with AWS CLI : Part — 1]]></title>
            <link>https://ajaypathak372.medium.com/getting-started-with-aws-cli-part-1-3d57a23dd87f?source=rss-2410adbaca93------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d57a23dd87f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Ajay Pathak]]></dc:creator>
            <pubDate>Fri, 27 Nov 2020 11:15:44 GMT</pubDate>
            <atom:updated>2021-01-05T08:07:35.600Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting Started with AWS CLI : Part — 1</h3><h4>Beginner’s Guide To AWS CLI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*O5H_uWG53Ho784fLSWEq6Q.png" /></figure><p>Hey everyone,</p><p>In this article, I will gonna show you How you can manage AWS resources and services using <strong>AWS CLI</strong>. And for showing the working of AWS CLI, I will show you a simple practical in which we launch an EC2 instance and create an EBS volume and then attach the EBS volume with the instance.</p><p>Basically for using the services of any Cloud like AWS, GCP, Azure there are typically 3 ways that are</p><ul><li>Through the web portal of the cloud provider i.e., website (GUI)</li><li>Through CLI i.e., the command line tool provided by the cloud provider</li><li>Using SDK like by writing the code i.e., using some infrastructure as code tool like <strong>Terraform</strong>.</li></ul><p>To know more about Terraform, you can check my <a href="https://ajaypathak372.medium.com/launching-wordpress-with-mysql-in-a-vpc-with-public-and-private-subnets-on-aws-by-terraform-1cb6950a4af6?sk=cdcd243d99e1283b378a18e8bb977331">previous article</a>.</p><h3>What is AWS CLI ?</h3><p>The AWS Command Line Interface (AWS CLI) is an open-source tool that enables you to interact with AWS services using commands in your command-line shell. With minimal configuration, the AWS CLI enables you to start running commands that implement functionality equivalent to that provided by the browser-based AWS Management Console from the command prompt in your terminal program.</p><p>The AWS CLI provides direct access to the public APIs of AWS services. You can explore a service’s capabilities with the AWS CLI, and develop shell scripts to manage your resources. In addition to the low-level, API-equivalent commands, several AWS services provide customizations for the AWS CLI. Customizations can include higher-level commands that simplify using a service with a complex API.</p><p>For more information about AWS CLI, you can go <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html">here.</a></p><p>Let’s first start with the installation part of the AWS CLI.</p><p><strong>Installation of AWS CLI</strong></p><p>AWS CLI has 2 versions that are version 1 and version 2. And in this, we will use version 2.</p><p>We can install AWS CLI in Windows, Linux, and Mac but here we are installing it in windows. So first we have to download the AWS CLI installer which you can download from <a href="https://awscli.amazonaws.com/AWSCLIV2.msi">here</a>. And after downloading just run it, it will automatically install the CLI tool and also updates the environmental variables in windows.</p><p>Now to confirm whether it is installed or not open the <strong>windows command prompt </strong>or<strong> PowerShell </strong>and type the command below.</p><pre>aws --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*GQmd0kKWLEOpOdxGLPXfnw.png" /></figure><p><strong>Configure AWS CLI.</strong></p><p>For using the AWS CLI, we first have to configure our AWS account where we will launch the services and for this, we need an AWS IAM account although we can also configure our root AWS account but it is not good to configure root account as it has all the powers. So here we are configuring an AWS IAM account with some specific powers, you can give any power for the services you want to use or for all services give <strong>PowerUser Access</strong>.</p><p>To configure we need the secret key and access key of the IAM user. And for configuration, we have to use this command.</p><pre>aws configure</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66ZQHjxA8uZBccgY07kh6Q.png" /></figure><p>We can also configure multiple profiles by adding — -profileoption in the above command like this</p><pre>aws configure --profile (profile_name)</pre><p>Now we can easily use AWS services using AWS CLI.</p><p>So let we first launch an EC2 instance through CLI. Using the AWS CLI is very simple, we just need to know the right options and sub-options for the service we want to use. Like here we want to launch an EC2 instance then we need the option/command related to the EC2 service and we can see all the options available in the <strong>aws</strong> command using help like this</p><pre>aws help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yazDgGhU2OrcobyF_Q1PoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o71elWTSCObbwOTJyWop-w.png" /></figure><p>So we don&#39;t need to learn any aws command we can take help every time we want to use some service. And to see the additional options for some specific service we can again use help like this</p><pre>aws ec2 help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aCTTN-8q9ogdxM7hf3n-wg.png" /></figure><p>So in this way, we can use AWS CLI and write commands for any service of AWS.</p><pre>aws help                                                                                                                                                                                                           aws &lt;command&gt; help                                                                                                                                                                                                 aws &lt;command&gt; &lt;subcommand&gt; help</pre><p><strong>Launch EC2 Instance</strong></p><p>Now to launch an EC2 instance we can write the command like this</p><pre>aws ec2 run-instances --image-id ami-08f63db601b82ff5f --instance-type t2.micro --key-name taskoskey</pre><p>So it will launch an EC2 instance in the default VPC and also creates a security group for the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYiBX5_5e8eppymIDUpyjw.png" /></figure><p>In the above command, we can add more options like subnet id, security group, etc according to the need.</p><p><strong>Create EBS Volume</strong></p><p>Let’s create an EBS volume for our instance using the AWS CLI and the command for doing this is</p><pre>aws ec2 create-volume --availability-zone ap-south-1b --size 1</pre><p>The above command will create a volume of 1GB and we create the volume in the same <strong>availability zone</strong> in which our instance is running so that we can able to attach it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JdbcqjmYRIUBaKj-I90o9w.png" /></figure><p><strong>Attach EBS Volume with the EC2 Instance</strong></p><p>Now we have to attach the above created EBS volume with our EC2 instance launched above. And for doing this we just need to write this simple command</p><pre>aws ec2 attach-volume --volume-id vol-033d739deb2afbc44 --instance-id i-07b51884e6908f67c --device /dev/sdf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GpSRM0AbO33iS-vC6KVCFQ.png" /></figure><p>Now the EBS volume has been attached to the EC2 instance and we can also verify from the web console of AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lPtgmG4TQd0UE541AD9x2A.png" /></figure><p>The practical I have shown you is so easy, it’s not a big deal to do this. But here the important thing is how to do with CLI.</p><p><strong>So that&#39;s how we can use AWS CLI to do anything on AWS Cloud. CLI is a good way to implement automation but for Clouds, the best approach is to use some Infrastructure as Code (IAC) tool like Terraform.</strong></p><p>You can check my previous articles about <strong>Terraform </strong>on medium.</p><p><strong>Thanks for Reading !!!</strong></p><p>Connect with me on <a href="http://www.linkedin.com/in/ajay-pathak372">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d57a23dd87f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launching WordPress with MySQL in a VPC with Public and Private Subnets on AWS by Terraform.]]></title>
            <link>https://medium.com/swlh/launching-wordpress-with-mysql-in-a-vpc-with-public-and-private-subnets-on-aws-by-terraform-1cb6950a4af6?source=rss-2410adbaca93------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cb6950a4af6</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Ajay Pathak]]></dc:creator>
            <pubDate>Sat, 24 Oct 2020 10:56:58 GMT</pubDate>
            <atom:updated>2021-01-05T09:53:08.062Z</atom:updated>
            <content:encoded><![CDATA[<h3>Terraform to Set Up Multi-Tier Infrastructure on AWS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*i3hjfzMpf1CBBjVW6PdhUg.png" /></figure><p>Hey everyone,</p><p>In this article, We will gonna learn how to setup a VPC with Public and Private Subnets on <strong>AWS. </strong>And then we will setup a <strong>Multi-tier Infrastructure</strong> in which we will launch the <strong>WordPress</strong> site on the Public Subnet and <strong>MySQL</strong> Database in the Private Subnet. And we will do everything using <strong>Terraform</strong> only.</p><p>So Let me first tell you something about <strong>Terraform.</strong></p><h3>What is Terraform ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/0*eU0KaOAdRQiiA_vf.png" /></figure><p><strong>Terraform</strong> is an open-source infrastructure as code software tool created by HashiCorp. Users define and provision data center infrastructure using a declarative configuration language known as <strong>HashiCorp Configuration Language (HCL)</strong>, or optionally <a href="https://en.wikipedia.org/wiki/JSON">JSON</a>.</p><p>The key features of Terraform are:</p><ul><li><strong>Infrastructure as Code</strong>: Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.</li><li><strong>Execution Plans</strong>: Terraform has a “planning” step where it generates an <em>execution plan</em>. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.</li><li><strong>Resource Graph</strong>: Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.</li><li><strong>Change Automation</strong>: Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.</li></ul><p>In short, I can say we will write a Terraform code to setup or to manage our whole infrastructure, so basically, here we are implementing <strong>Infrastructure as Code (IaC). </strong>And due to this we just have to run this code to setup our complete infrastructure whenever we want or to do some changes in our infrastructure we just have to do changes in this code. So it saves our time and we can setup the whole infrastructure as many times we want and we don&#39;t have to manually create all the resources every time.</p><p>So now let us discuss what we actually gonna do to setup all these things.</p><p><strong>Resources we need to create</strong></p><ul><li>Create a VPC with 2 Subnets i.e., Public and Private</li><li>Create and attach an Internet Gateway to Public Subnet</li><li>Create Security groups for both WordPress and MySQL</li><li>Launch WordPress site in Public Subnet, so that anyone from the outside world can able to access our site</li><li>Launch MySQL Database in Private Subnet to make it secure from the outside world</li><li>Create a NAT Gateway in Public Subnet and attach it with Private Subnet so that we can able to access the internet in MySQL instance</li></ul><p><strong>Let’s write Terraform code to create all these things…</strong></p><p>Before doing anything we first need to install Terraform and then setup the AWS IAM account in the same system in which we have installed terraform. And then just write this terraform code to tell terraform about our AWS account.</p><pre>provider &quot;aws&quot; {<br>  region = &quot;ap-south-1&quot;<br>  profile = &quot;Ajay&quot;<br>}</pre><p>And then run this terraform command</p><pre>terraform init</pre><h4>Create a VPC</h4><p>In every cloud, we always need a <strong>VPC(Virtual Private Cloud)</strong> to launch any service so we first create a VPC, and to create VPC the terraform code is.</p><pre>resource &quot;aws_vpc&quot; &quot;vpc&quot; {<br>  cidr_block       = &quot;10.2.0.0/16&quot;<br>  instance_tenancy = &quot;default&quot;<br>  enable_dns_hostnames = true</pre><pre>  tags = {<br>    Name = &quot;vpc_task3&quot;<br>  }<br>}</pre><h4>Create Subnets</h4><p>It is the subnets in which we launch any service, so in every VPC we need to create subnets. And here we create 2 Subnets in the VPC created above.</p><p><strong>Public Subnet</strong></p><p>In this Subnet, we will gonna launch our WordPress site and it is public since we want that our site is accessible by the outside world so that&#39;s why we need to give public connectivity to this subnet and any instance or service we launch in this subnet will have some Public IP or URL. So the terraform code for creating subnet is</p><pre>resource &quot;aws_subnet&quot; &quot;pub_subnet&quot; {<br>  vpc_id     = aws_vpc.vpc.id<br>  cidr_block = &quot;10.2.1.0/24&quot;<br>  availability_zone = &quot;ap-south-1b&quot;</pre><pre>  tags = {<br>    Name = &quot;public-subnet&quot;<br>  }<br>}</pre><p><strong>Private Subnet</strong></p><p>In this subnet, we will launch our MySQL database instances and for every company, their databases are the most critical thing for them as the data is money for them and no one wants their databases to get hacked or breach. Everyone wants their database to be as secure as it can. So this Private Subnet would not have Public connectivity only the local connectivity within the VPC.</p><pre>resource &quot;aws_subnet&quot; &quot;priv_subnet&quot; {<br>  vpc_id     = aws_vpc.vpc.id<br>  cidr_block = &quot;10.2.2.0/24&quot;<br>  availability_zone = &quot;ap-south-1a&quot;</pre><pre>  tags = {<br>    Name = &quot;private-subnet&quot;<br>  }<br>}</pre><h4>Create Route Table</h4><p>when we create a VPC in AWS then it also creates a Route table i.e., the main route table but here we are creating separate <strong>Route Tables</strong> for the Subnets.</p><p><strong>Route Table for Public Subnet</strong></p><pre>resource &quot;aws_route_table&quot; &quot;public&quot; {<br>  vpc_id = aws_vpc.vpc.id<br>  tags = {<br>    Name = &quot;public-rt&quot;<br>  }<br>}</pre><pre>resource &quot;aws_route_table_association&quot; &quot;rt_pub_subnet&quot; {<br>  subnet_id      = aws_subnet.pub_subnet.id<br>  route_table_id = aws_route_table.public.id<br>}</pre><p><strong>Route Table for Private Subnet</strong></p><pre>resource &quot;aws_route_table&quot; &quot;private&quot; {<br>  vpc_id = aws_vpc.vpc.id<br>  tags = {<br>    Name = &quot;private-rt&quot;<br>  }<br>}</pre><pre>resource &quot;aws_route_table_association&quot; &quot;rt_priv_subnet&quot; {<br>  subnet_id      = aws_subnet.priv_subnet.id<br>  route_table_id = aws_route_table.private.id<br>}</pre><h4><strong>Create Internet Gateway</strong></h4><p>Now to make our Subnet Public we have to give Internet connectivity to it and for this, we have to attach an <strong>Internet Gateway</strong> with it. So for creating the internet gateway the terraform code is</p><pre>resource &quot;aws_internet_gateway&quot; &quot;ig&quot; {<br>  vpc_id = aws_vpc.vpc.id</pre><pre>  tags = {<br>    Name = &quot;task3-ig&quot;<br>  }<br>}</pre><p><strong>Terraform code to attach Internet Gateway with Public Subnet</strong></p><pre>resource &quot;aws_route&quot; &quot;route-ig&quot; {<br>  route_table_id            = aws_route_table.public.id<br>  destination_cidr_block    = &quot;0.0.0.0/0&quot;<br>  gateway_id                = aws_internet_gateway.ig.id<br>}</pre><h4>Create NAT Gateway</h4><p>In the Private Subnet, we haven&#39;t attached any internet gateway as we want to secure it from the outside world but when we launch some instance or any other service then we may need internet connectivity like to download something or upload. But if we attach an internet gateway to it then there is no meaning of private in this subnet.</p><p>So if we want to access the internet in a private manner then we can attach a <strong>NAT Gateway</strong> between the Public and Private Subnet, due to this we can able to go to the internet world from the Private Subnet and no one from the internet can able to connect with us. And we go to the internet through the internet gateway of the Public Subnet. So the terraform code to create and attach NAT Gateway is</p><pre>resource &quot;aws_nat_gateway&quot; &quot;nat&quot; {<br>  allocation_id = aws_eip.nat_eip.id<br>  subnet_id     = aws_subnet.pub_subnet.id</pre><pre>  tags = {<br>    Name = &quot;task3-NAT&quot;<br>  }<br>}</pre><pre>resource &quot;aws_route&quot; &quot;route-nat&quot; {<br>  route_table_id            = aws_route_table.private.id<br>  destination_cidr_block    = &quot;0.0.0.0/0&quot;<br>  nat_gateway_id            = aws_nat_gateway.nat.id<br>}</pre><p><strong>Now everything is ready and we just have to launch WordPress and MySQL instances.</strong></p><h4>Create a Key Pair</h4><p>We will attach this keypair with the WordPress and MySQL instances.</p><pre>resource &quot;tls_private_key&quot; &quot;task3_key&quot;  {<br>  algorithm = &quot;RSA&quot;<br>}</pre><pre>resource &quot;aws_key_pair&quot; &quot;keypair&quot; {<br>  key_name = var.key<br>  public_key = tls_private_key.task3_key.public_key_openssh<br>}</pre><pre>resource &quot;local_file&quot; &quot;download_key&quot; {<br>  content = tls_private_key.task3_key.private_key_pem<br>  filename = &quot;${var.key}.pem&quot;<br>}</pre><h4><strong>Create Security Groups</strong></h4><p><strong>For WordPress Instances</strong></p><p>Since we want that anyone from the outside world can access our WordPress site and WordPress runs on Port No 80 so we have to create an ingress rule for port 80 and also for port 22 so that we can do SSH into the WordPress instance. The terraform code for creating the security group is</p><pre>resource &quot;aws_security_group&quot; &quot;sg_wp&quot; {<br>  name        = &quot;wordpress-sg&quot;<br>  description = &quot;Allow HTTP and SSH inbound traffic&quot;<br>  vpc_id      = aws_vpc.vpc.id</pre><pre>  ingress {<br>    description = &quot;Allow SSH&quot;<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [ &quot;0.0.0.0/0&quot; ]<br>  }</pre><pre>  ingress {<br>    description = &quot;Allow HTTP&quot;<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [ &quot;0.0.0.0/0&quot; ]<br>  }</pre><pre>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  tags = {<br>    Name = &quot;allow_ssh_http&quot;<br>  }<br>}</pre><p><strong>For MySQL Instance</strong></p><p>For MySQL, we want that only WordPress instances can able to connect with it and MySQL runs on Port No 3306 so we have to create an ingress rule for Port 3306 that allows only WordPress instance to connect and also for Port 22 so that we can able to do SSH into this but here we can only do SSH from the instances in Public Subnet. So the terraform code for this is</p><pre>resource &quot;aws_security_group&quot; &quot;sg_mysql&quot; {<br>  name        = &quot;mysql-sg&quot;<br>  description = &quot;Allow MySQL inbound traffic&quot;<br>  vpc_id      = aws_vpc.vpc.id</pre><pre>  ingress {<br>    description = &quot;Allow MySQL&quot;<br>    from_port   = 3306<br>    to_port     = 3306<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [ &quot;${aws_instance.wordpress.private_ip}/32&quot; ]<br>  }</pre><pre>  ingress {<br>    description = &quot;Allow SSH&quot;<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [ &quot;0.0.0.0/0&quot; ]<br>  }</pre><pre>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  tags = {<br>    Name = &quot;allow_mysql_ssh&quot;<br>  }<br>}</pre><h4>Launch WordPress and MySQL Instances</h4><p>Now we have to launch WordPress and MySQL instances but in AWS we first have to launch a simple instance like amazon-linux, redhat, ubuntu etc and then in these instances we have to install and configure our WordPress and MySQL programs. And if we want to launch multiple instances for them then we have to install both the programs again.</p><p><em>So to solve this I have installed and setup WordPress and MySQL programs in some instances and created an </em><strong><em>AMI(Amazon Machine Image)</em></strong><em> from those instances. So next time we just have to launch the instances using these AMI’s and we can directly use WordPress and MySQL programs.</em></p><p><strong>Code for WordPress Instance</strong></p><pre>resource &quot;aws_instance&quot; &quot;wordpress&quot; {<br>  ami           = &quot;ami-049609235004b64bc&quot;<br>  instance_type = var.inst_type<br>  subnet_id = aws_subnet.pub_subnet.id<br>  associate_public_ip_address = true<br>  key_name = aws_key_pair.keypair.key_name<br>  security_groups = [ aws_security_group.sg_wp.id ]<br>  tags = {<br>    Name = &quot;Wordpress&quot;<br>  }<br>}</pre><p><strong>Code for MySQL Instance</strong></p><pre>resource &quot;aws_instance&quot; &quot;mysql&quot; {<br>  ami           =  &quot;ami-0df8aa28f5a7d2957&quot;<br>  instance_type = var.inst_type<br>  subnet_id = aws_subnet.priv_subnet.id<br>  associate_public_ip_address = false<br>  key_name = aws_key_pair.keypair.key_name<br>  security_groups = [ aws_security_group.sg_mysql.id ]<br>  tags = {<br>    Name = &quot;MySQL&quot;<br>  }<br>}</pre><p><em>In the MySQL instance code, you can see I have made the Public IP Address false because we don&#39;t want anyone from the outside world to connect with it.</em></p><p><strong>Note:- The AMI used for launching both the instances would not work as they are private so you have to create your own AMI or setup the WordPress and MySQL in any other way you know.</strong></p><p>To access the WordPress site we need the Public IP of the WordPress instance and we also need the Private IP of the MySQL instance to connect it with WordPress, so for this, we can write this code.</p><pre>output &quot;ip_wordpress&quot; {<br>  value = aws_instance.wordpress.public_ip<br>}</pre><pre>output &quot;ip_mysql&quot; {<br>  value = aws_instance.mysql.private_ip<br>}</pre><p>Now all the code is ready and to setup everything we need to run this Terraform code and to run the whole terraform code, we use this command.</p><pre>terraform apply <br>       or<br>terraform apply --auto-approve </pre><p>Here is the output of the above command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_YNp6DTiBS4210tfHdYlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4j8leV5AhFk8TjVUsml3w.png" /></figure><p>Now we can access our WordPress site from the browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qs_juPz6Ok7uzV8DQ_iYUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-vPNvM4yfC6oiX2vlFwiJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIpXdxIAZSc1SO2U8MPV1Q.png" /></figure><blockquote><strong>So now our WordPress site is ready and MySQL Database is also gets connected with it and the interesting thing is our MySQL Database is so secure that even having the internet access no one from the outside world can able to connect with it and also we can do SSH to it only through the instances in Public Subnet.</strong></blockquote><p><strong>Thanks for reading this….</strong></p><p>I have uploaded all the codes on my GitHub <a href="https://github.com/Ajaypathak372/cloud-task3">Repository</a>.</p><p>Connect with me on LinkedIn</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cb6950a4af6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/launching-wordpress-with-mysql-in-a-vpc-with-public-and-private-subnets-on-aws-by-terraform-1cb6950a4af6">Launching WordPress with MySQL in a VPC with Public and Private Subnets on AWS by Terraform.</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set Up Multi Cloud Infrastructure using Terraform (IaaC)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ajaypathak372.medium.com/set-up-multi-cloud-infrastructure-using-terraform-iaac-6e4f0e0618b7?source=rss-2410adbaca93------2"><img src="https://cdn-images-1.medium.com/max/1084/1*xTmRI0gI3IqCOjes1lc3CA.jpeg" width="1084"></a></p><p class="medium-feed-snippet">This is about how to set up Multi-Cloud Infrastructure using Terraform and since both are public clouds then how to secure our database.</p><p class="medium-feed-link"><a href="https://ajaypathak372.medium.com/set-up-multi-cloud-infrastructure-using-terraform-iaac-6e4f0e0618b7?source=rss-2410adbaca93------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://ajaypathak372.medium.com/set-up-multi-cloud-infrastructure-using-terraform-iaac-6e4f0e0618b7?source=rss-2410adbaca93------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e4f0e0618b7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Ajay Pathak]]></dc:creator>
            <pubDate>Sun, 13 Sep 2020 09:07:10 GMT</pubDate>
            <atom:updated>2021-01-05T09:19:34.112Z</atom:updated>
        </item>
    </channel>
</rss>