<?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 Helen Campbell on Medium]]></title>
        <description><![CDATA[Stories by Helen Campbell on Medium]]></description>
        <link>https://medium.com/@helenccampbell?source=rss-c602c819811------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DP2VaIl5_rs0Lp_wJ0MMFA.jpeg</url>
            <title>Stories by Helen Campbell on Medium</title>
            <link>https://medium.com/@helenccampbell?source=rss-c602c819811------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:26:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@helenccampbell/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[Creating a Custom Module for an EC2 Instance with Terraform]]></title>
            <link>https://helenccampbell.medium.com/creating-a-custom-module-for-an-ec2-instance-with-terraform-eb624776f3c9?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb624776f3c9</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Tue, 26 Jul 2022 20:45:38 GMT</pubDate>
            <atom:updated>2022-10-25T15:32:43.424Z</atom:updated>
            <content:encoded><![CDATA[<p>Task: your team needs you to create a custom module for an EC2 instance with an Amazon Linux 2 AMI ID. <em>Necessary Resources:</em> VSCode or an IDE of your choice, GitHub account, AWS account with CLI configured, Terraform CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YrEN765MMK63jhq5U-x1w.png" /></figure><h4><strong>What is a module in Terraform?</strong></h4><p>A <em>module</em> is a container for multiple resources that are used together. Modules can be used to create lightweight abstractions so that you can describe your infrastructure in terms of its architecture rather than directly in terms of physical objects. Modules are the primary way to package and reuse resource configurations with Terraform.</p><p>Three modules exist in Terraform, the <em>root </em>module, the <em>child </em>module, and the <em>published </em>module. Every Terraform configuration consists of a <em>root </em>module; this is where the resources are defined in .tf files in the working directory.</p><p>A Terraform module (usually the root module of a configuration) can <em>call</em> other modules to include their resources in the configuration. A module that another module has called is often referred to as a <em>child </em>module<em>. </em>In this project, we will create a <em>child </em>module to deploy an EC2 Instance in AWS.</p><p><strong>Step 1: Fork and clone this repo locally with the </strong><a href="http://ec2.tf/"><strong>ec2.tf</strong></a><strong> template as a starting point to create the EC2: </strong><a href="https://github.com/LevelUpInTech/terraformec2.git"><strong>https://github.com/LevelUpInTech/terraformec2.git</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*xk8EZk2UsjfYTfVH9M3Mig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*jL1wI73t5zvbQPTTpJh1oQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*NuxKNkHPR6VbRn-Li3SsQQ.png" /><figcaption>gh repo clone LevelUpInTech/terraformec2</figcaption></figure><p>If choosing to use GitHub CLI, it is essential to check that GitHub CLI is downloaded to your local environment. This can be done by using the below command found <a href="https://cli.github.com/">here</a>.</p><pre>brew install gh </pre><p>If downloading GitHub CLI for the first time, an authentication process is prompted to connect your GitHub account to your local environment. Follow the steps that the terminal provides until successful. Once confirmed that the account is connected, clone the repo in your terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*nKbS3KuvBWQtZRpX2lPOFA.png" /><figcaption>Successful Clone</figcaption></figure><p>Once the clone is successful, change to the new directory created in the local environment.</p><pre>cd terraformec2</pre><pre>#to check what is inside the terraformec2 file (ec2.tf)</pre><pre>ls</pre><p>When checking what is inside the new <strong>terraformec2</strong> directory, you will notice we have one Terraform file: <strong>ec2.tf</strong>.</p><p><strong>Step 2: Create a custom module for EC2 out of the resource block to be used as repeatable infrastructure (completed in VSCode)</strong></p><p>With the repo cloned, the module to create the EC2 Instance can be built out. In VSCode, open the new <strong>terraformec2</strong> directory we cloned in our local environment. Once opened, you will see an <strong>ec2.tf</strong> file, open it up and look at the module provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*gdTnk8jG6PSp4LEeUT9dMw.png" /><figcaption>Feel Free to Change the Name of the EC2 Instance</figcaption></figure><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 3.27&quot;<br>    }<br>  }<br><br>  required_version = &quot;&gt;= 0.14.9&quot;<br>}<br><br>provider &quot;aws&quot; {<br>  profile = &quot;default&quot;<br>  region  = &quot;us-west-2&quot;<br>}<br><br>resource &quot;aws_instance&quot; &quot;app_server&quot; {<br>  ami           = &quot;ami-830c94e3&quot;<br>  instance_type = &quot;t2.micro&quot;<br><br>  tags = {<br>    Name = &quot;ExampleAppServerInstance&quot;<br>  }<br>}</pre><p>When working in Terraform, it is important to create four starting files to build a project: <strong>providers.tf</strong>,<strong> main.tf</strong>,<strong> variables.tf </strong>and <strong>outputs.tf</strong> . Create these four files within a new folder called <strong>ec2</strong>. We will take blocks of code from the <strong>ec2.tf</strong> file into four separate files to configure our <strong>.tf</strong> files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*tL7dj5EfZHQpnLlarYWevQ.png" /><figcaption>An environment with .tf files</figcaption></figure><p>In the <strong>providers.tf </strong>file, insert the below code into the file (found in the original <strong>ec2.tf</strong> file):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*MQQhUxvLcuNpnm5Mi1KoqQ.png" /><figcaption>providers.tf File Configuration</figcaption></figure><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 3.0&quot;<br>    }<br>  }<br>}<br><br># Configure the AWS Provider<br>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}</pre><p>Note: I have changed my AWS Region to be us-east-1, which, therefore, will change my AMI type as well. Please be cautious in matching your AMI to the correct AWS Region.</p><p>From the same <strong>ec2.tf</strong> file, copy and paste the below code into the <strong>main.tf</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*zcofPsVkW6z9IV6XrnxZbw.png" /><figcaption>main.tf File Configuration</figcaption></figure><pre>resource &quot;aws_instance&quot; &quot;app_server&quot; {<br>  ami           = &quot;ami-0cff7528ff583bf9a&quot;<br>  instance_type = &quot;t2.micro&quot;<br><br>  tags = {<br>    Name = &quot;ProjectServerInstance&quot;<br>  }<br>}</pre><p>In the original <strong>ec2.tf</strong> file cloned earlier, delete the contents and replace it with the below code. This is the start of our EC2 module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*CFqVlMtKQTX7bZrcJ14Hgw.png" /></figure><pre>module &quot;ec2&quot; {<br>  source         = &quot;./ec2&quot;<br>}</pre><p>Now with these tasks finished, save the new files and begin the terraform steps taken to get to terraform apply in the terminal: terraform init, terraform fmt, terraform validate, terraform plan, and terraform apply. Be sure to type “yes” when prompted during the terraform apply process.</p><p>If you run across a security token error when trying to terraform plan or apply, be sure that you configured your AWS account in the CLI with the aws configure command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*t2RqPZa0XKFZe5IHg58cfw.png" /><figcaption>Apply Complete!</figcaption></figure><p>There are two ways to check the creation of the new instance: the AWS Console and the CLI. Remember where your instance is created; mine is in us-east-1; adjust your AWS console region accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zI8U0LYBLyy4E8SVb2w2ow.png" /><figcaption>Console Proof of Created Instance</figcaption></figure><p>To view in CLI, run:</p><p>aws ec2 describe-instances</p><p>If your CLI only outputs instances created in us-east-1 or a different region than what your instance was created in, run the following command:</p><p>aws ec2 describe-instances — region [region]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*JbNE0C956RR1FxSNDbFHuQ.png" /><figcaption>CLI Proof of Created Instance</figcaption></figure><p>Now that the instance was successfully created, run a terraform destroy. Type “yes” to continue the destroying process.</p><p><strong>Step 3: Create a reusable infrastructure</strong></p><p>In the <strong>variables.tf</strong> file, list the resources of <strong>ami_id </strong>and <strong>instance</strong> found in the <strong>main.tf </strong>file and add the variable <strong>instance_count</strong>; this will specify the number of instances we want to be created. Be sure to save your edits as you go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*0bMoOeKpTPiOi_2z_m8qow.png" /><figcaption>variables.tf Configuration</figcaption></figure><pre>variable &quot;ami_id&quot; {<br>  type    = string<br>  default = &quot;ami-0cff7528ff583bf9a&quot;<br>}<br><br>variable &quot;instance&quot; {<br>  type    = string<br>  default = &quot;t2.micro&quot;<br>}<br><br>variable &quot;instance_count&quot; {<br>  type    = number<br>  default = 1<br>}</pre><p>In the <strong>main.tf</strong> file, we will now reference the variables we created in the <strong>variables.tf </strong>file. Replace the original values for our resources with the variables we created by using <strong>var.[variable name here]</strong>. We will also add a count meta argument to our tag block so that Terraform makes the number of instances of our resource (an EC2 Instance). A +1 is added because count.index count begins at 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*EHyDNq1BNeQEqs0Crm71RQ.png" /><figcaption>main.tf Re-Configuration</figcaption></figure><pre>resource &quot;aws_instance&quot; &quot;app_server&quot; {<br>  ami           = var.ami_id<br>  instance_type = var.instance<br>  count         = var.instance_count<br><br>  tags = {<br>    Name = &quot;ProjectServerInstance ${count.index + 1}&quot;<br>  }<br>}</pre><p>In our <strong>ec2.tf</strong> file, create a line of code to reference our new “instance_count” variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*HOvCfQM1-OOpUTREH64Nsg.png" /></figure><pre>module &quot;ec2&quot; {<br>  source         = &quot;./ec2&quot;<br>  instance_count = 1<br>}</pre><p>Now run a terraform init, terraform fmt -recursive, terraform validate, terraform plan, and terraform apply. Type “yes” when prompted during the terraform apply process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*0ikLviEBbK6gwH03TZ2NSA.png" /><figcaption>Terminal Result of Instance Creation after Terraform Apply</figcaption></figure><p>Once again, check the AWS Console or CLI to confirm that the instance has been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LLOL97Wo74yFM5MnoGLIGg.png" /><figcaption>Console Proof of Instance Creation</figcaption></figure><p>aws ec2 describe-instances or aws ec2 describe-instances — region [region]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*SXFUwefmSrbLiYlppHIVeQ.png" /><figcaption>CLI Proof of Instance Creation</figcaption></figure><p>Lastly, add code to the outputs.tf file to have AWS Console information appear in the terminal after running a terraform apply.</p><p>In the <strong>outputs.tf </strong>file, insert the below code, and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*Mg8cmH6_EPplKki7iBV9kQ.png" /><figcaption>outputs.tf Configuration</figcaption></figure><pre>output &quot;ec2_public_ip&quot; {<br>    value = aws_instance.app_server[*].public_ip<br>}<br><br>output &quot;ec2_tags&quot; {<br>    value = aws_instance.app_server[*].tags_all<br>}</pre><p>For the module to process <strong>outputs.tf </strong>properly, another <strong>outputs.tf </strong>file needs to be created in the root module (<strong>terraformec2</strong>). The below code belongs to the root modules <strong>output.tf </strong>file. Save when finished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*X69-dX7tr5jYqA9Y03UXRw.png" /></figure><pre>output &quot;instace_ip&quot; {<br>    value = module.ec2.ec2_public_ip<br>}<br><br>output &quot;instance_tags&quot; {<br>    value = module.ec2.ec2_tags<br>}</pre><p>Run a terraform apply and receive the below output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*ZDyWdC0zXciDdyYzIt38BA.png" /></figure><p>Run a terraform destroy now that we have completed this task.</p><p><strong>Step 4: Push the newly created module and the </strong><a href="http://ec2.tf/"><strong>ec2.tf</strong></a><strong> file to your repo!</strong></p><p>Pushing our newly created module is the final step, but first, a <a href="https://github.com/hvccampbell/terraformec2/blob/main/.gitignore">.<strong>gitignore</strong></a> file needs to be placed into our root module (<strong>terraformec2</strong>). Doing so will prevent any unwanted files from getting pushed to GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*vNrGZq1zWrIUOKl5_ptnDg.png" /><figcaption>View of Side Menu after Added Files</figcaption></figure><p>In the .gitignore file, add the following and save:</p><pre># Local .terraform directories<br>**/.terraform/*</pre><pre># .tfstate files<br>*.tfstate<br>*.tfstate.*</pre><pre># Crash log files<br>crash.log</pre><pre># Exclude all .tfvars files, which are likely to contain sensitive data, such as<br># password, private keys, and other secrets. These should not be part of version <br># control as they are data points that are potentially sensitive and subject <br># to change depending on the environment.<br>#<br>*.tfvars</pre><pre># Ignore override files as they are usually used to override resources locally, so<br># are not checked in override.tf<br>override.tf.json<br>*_override.tf<br>*_override.tf.json</pre><pre># Include override files you do wish to add to version control using negated pattern<br>#<br># !example_override.tf<br># Include tfplan files to ignore the planned output of the command: terraform plan -out=tfplan<br># example: *tfplan*</pre><pre># Ignore CLI configuration files<br>.terraformrc<br>terraform.rc</pre><p>Now run the commands to push the .gitignore file</p><pre><a href="https://github.com/git-guides/git-status">git status</a> <br><a href="https://github.com/git-guides/git-add">git add ec2.tf .gitignore ec2/ outputs.tf</a><br><a href="https://github.com/git-guides/git-commit">git commit -m “initial commit”</a><br><a href="https://github.com/git-guides/git-push">git push origin</a></pre><p>Once these commands have been run, check your GitHub account to see that the new module created in this project has been pushed to your repository!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cwTwME2OJfbMoHqRYM5GXQ.png" /></figure><p>Thanks for following along! Find me at linkedin.com/in/helenccampbell</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb624776f3c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating New AWS IAM Users in Terraform Cloud]]></title>
            <link>https://aws.plainenglish.io/creating-new-aws-iam-users-in-terraform-cloud-ca9276f54f1e?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca9276f54f1e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Tue, 22 Jun 2021 18:41:37 GMT</pubDate>
            <atom:updated>2022-10-25T15:31:33.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*SjsJ5n0GrvL2g9Nde4dNUQ.png" /></figure><p>Resources needed: 1. Terraform Cloud Account 2. GitHub Account 3. <a href="https://github.com/hvccampbell/TFIAM-bmw">This GitHub Repo Forked</a> 4. AWS Account Configured</p><p>Deploying code using Terraform Cloud as a CI/CD will help check the created build.</p><p>Step 1: Choose your setup workflow: “Start from scratch”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uzaGMsZaI1uaTLBDe_G6cw.png" /></figure><p>Step 2: Create a new organization</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmrar-cSrKH6KDRmyeXf1g.png" /></figure><p>Step 3: Create a new workspace: “Version control workflow”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2PBgtU0tz78MWY_CTMEgA.png" /></figure><p>Step 4: Connect to VCS: “GitHub”</p><p>You may need to go through the login process to establish a connection between Terraform Cloud and GitHub. It is a step-by-step process that is easy to follow. Once complete, continue to step 5 of this process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q5irgd4huWK9wnYMBLbqZA.png" /></figure><p>Step 5: Choose a repository: “TFIAM-bmw”</p><p>As stated in the resources section of this document, you will need to have forked “TFIAM-bmw” for this project. This is the repo we will select for our task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPlvsV4ZctrpqL3Fa8DBHA.png" /></figure><p>Step 6: Configure settings</p><p>You may change the workspace name to your liking and add a simple description of what we are creating in this step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VOhgFkzF_Ik4ST_3uywlvg.png" /></figure><p>A crucial step in this process is configuring variables in Terraform Cloud. Configure your access key, secret access key, and region environment variables of your AWS account. Be sure to know where these are located in your local environment (try ~/.aws/credentials if unsure).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*lnrHmLHLgWDIXEszbBC8YA.png" /></figure><p>Step 1: Add Environment Variables: Access key, secret access key, region, and confirm destroy</p><p>Configure these keys from an IAM user that has admin privileges. The variable screen is first blank. Selecting “+ Add variable,” you can insert the keys and their corresponding values. Below is the format of the names of the variables and how they look once marked sensitive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BlD7yXxoY41Z8d8MJWoDGA.png" /></figure><p><strong>Default Region: </strong>prevents us from having to create a configuration file</p><p><strong>Confirm Destroy: </strong>allows us to destroy our infrastructure that will apply to the AWS environment</p><p>Step 2: Queue plan</p><p>In the “Runs” tab, select “Queue plan.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m1cs_FXR5YbKRoC68akrkw.png" /></figure><p>There will be a notification that confirmation is needed. At the bottom of this page, find and select the “Confirm &amp; Apply” button. Feel free to leave a comment in the supplied box if you wish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3iITbMIIW4ivyTlqJ6mnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eyd4YVQKc-4OUYak8CZV_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtKPAecoBJQcPxc1ZtWIZw.png" /><figcaption>Successful Run</figcaption></figure><p>Log into the AWS Console to see the IAM users that have just been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gF9oc2hlsdMmXvYUUYSAKQ.png" /></figure><p>Now that the task is complete, you have five new IAM users ready to work hard for you!!</p><p>Destruction and Deletion will be the last step in this task until these employees become real! Under the “Settings” tab, select “Destruction and Deletion” on that page, select “Queue destroy plan.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XA-waEl4AULRXP8WUiujXg.png" /></figure><p>You will need to enter the workspace name to confirm the deletion. Once the run begins, you will need to confirm by selecting “confirm and apply” at the bottom of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-BBTpA1ffThFRm_LxCIDg.png" /><figcaption>Successful Destroy</figcaption></figure><p>Thanks for following along! Find me at linkedin.com/in/helenccampbell</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca9276f54f1e" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/creating-new-aws-iam-users-in-terraform-cloud-ca9276f54f1e">Creating New AWS IAM Users in Terraform Cloud</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a 3-Tier AWS VPC Architecture Using Terraform]]></title>
            <link>https://medium.com/geekculture/deploying-a-3-tier-aws-vpc-architecture-using-terraform-4c08f5e412db?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c08f5e412db</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[terraform-modules]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[subnet]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Wed, 26 May 2021 21:13:23 GMT</pubDate>
            <atom:updated>2022-10-25T15:29:25.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*agsOGPqYPw8_NKrDguw3JA.png" /></figure><p>Prerequisites: Terraform locally installed, AWS account with AWS CLI configured, IDE (VSCode, Atom, etc.) with Terraform installed.</p><p>This project was completed in Visual Studio Code. Using an IDE, you may find it easier to format properly and have the language preset to Terraform (along with auto-completion, etc.).</p><p>Step 1: Deploy a VPC with CIDR 10.0.0.0/16 with two public subnets and one private subnet. The public subnets have CIDR 10.0.1.0/24 and 10.0.2.0/24. The private subnet has a CIDR of 10.0.3.0/24.</p><p>Step 2: Create an RDS MySQL Instance (t3.micro).</p><p>Step 3: Create a Load Balancer that directs traffic to the public subnets.</p><h3><strong>What is a 3-tier architecture? What is it used for?</strong></h3><p>A three-tier architecture comprises three logical and physical computing tiers: the presentation tier (client tier), the application tier (logic tier), and the data tier. It is a viable choice for software projects to be started quickly.</p><h4><strong>What is a Virtual Private Cloud (VPC)? What is it used for?</strong></h4><p>A VPC is a private sub-section of AWS that you control, where you can place AWS resources (such as EC2 instances and databases). You have FULL control over who has access to the AWS resources you put inside your VPC.</p><p>VPCs provide security, can perform at scale, customize the environment, and allow the user to add virtual segmentation (for example) later down the road. Flexibility and customization enable developers to be more agile and save money.</p><h3><strong>Let’s begin our project:</strong></h3><p>Create a working folder in Visual Studio Code (or your preferred IDE) with three .tf files inside: <strong>main.tf</strong>,<strong> outputs.tf</strong>, and <strong>versions.tf. </strong>In saving the files as .tf files, VSC will understand that we will be writing Terraform code.</p><h4><strong>Step 1: Deploy VPC with CIDR 10.0.0.0/16</strong></h4><p>In <strong>main.tf</strong>, state the provider in the first block, then create a module block for the VPC.</p><p>The provider block lets us declare we are working with AWS and which region we want our VPC to be deployed in. There are many options in AWS for which region to choose; therefore, you may prefer choosing “us-east-1” or “eu-west-2” over “us-west-1”.</p><p>The module block consists of the source, name, and CIDR. The source is “terraform-aws-modules/vpc/aws”, supplied by the Terraform Registry. You may name the VPC any name that will individualize it amongst other VPCs that may already exist in your AWS environment (such as your default VPC that AWS has assigned to your account). The CIDR block must be specified from private IPv4 address ranges.</p><pre><strong>provider</strong> &quot;aws&quot; {<br>region = &quot;us-west-1&quot;<br>}</pre><pre><strong>module</strong> &quot;vpc&quot; {<br>source = &quot;terraform-aws-modules/vpc/aws&quot;<br>name = &quot;17vpc&quot;<br>cidr = &quot;10.0.0.0/16&quot;</pre><h4><strong>Step 2: Declare Availability Zones, add two public subnets with CIDR’s 10.0.1.0/24 and 10.0.2.0/24, and a private subnet with CIDR 10.0.3.0/24.</strong></h4><p>Availability zones are multiple, isolated locations within each Region. Multiple availability zones are vital for building a highly available, fault-tolerant application in AWS. Depending on what region your VPC is created in, your availability zones may differ from those below.</p><p>If wanting to run a public-facing web application while maintaining back-end servers that aren’t publicly accessible, provide public and private subnets in your VPC. Web servers may exist in the public subnet, while database servers exist in a private subnet. The private subnet can also access the internet by using a NAT gateway that resides in the public subnet.</p><pre>azs             = [&quot;us-west-1a&quot;, &quot;us-west-1b&quot;]<br>public_subnets  = [&quot;10.0.1.0/24&quot;, &quot;10.0.2.0/24&quot;]<br>private_subnets = [&quot;10.0.3.0/24&quot;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*iDzdE_hBg7mmaIOySwVhaA.png" /><figcaption>This is what the main.tf file should look like with all the above commands put together.</figcaption></figure><p>Complete the module block with the below code and run a <strong>terraform init</strong>, <strong>terraform fmt</strong>, <strong>terraform plan</strong>, and <strong>terraform apply</strong>.</p><p>Here enable_nat_gateway = false is the default, but if you want to provision NAT Gateways for each of your private networks, it should be true. Additionally, single_nat_gateway = true because we want to provision a single shared NAT Gateway across all private networks. The tags used below are to help with identification purposes in the VPC.</p><pre>enable_ipv6 = true</pre><pre>enable_nat_gateway = false<br>single_nat_gateway = true</pre><pre>public_subnet_tags = {<br>Name = &quot;Public-Subnets&quot;<br>}</pre><pre>tags = {<br>Owner       = &quot;user&quot;<br>Environment = &quot;dev&quot;<br>}</pre><pre>vpc_tags = {<br>Name = &quot;W17VPC&quot;</pre><pre>}</pre><pre>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*da8Ox46WJb2u9A5aWWXgbQ.png" /><figcaption>Final module block.</figcaption></figure><h4><strong>Step 3: Create a Relational Database Service (RDS) MySQL Instance with t3.micro</strong></h4><p>Amazon Relational Database Service (Amazon RDS) allows for easy setup, operation, and scalability of a relational database in the cloud. Creating an RDS will enable us to focus on our applications as it automates time-consuming admin tasks. <a href="https://aws.amazon.com/rds/mysql/">MySQL</a> is an open-source relational database where scalable servers can be quickly deployed.</p><p>allocated_storage = x (where x is a number) is our database server&#39;s allocated storage in gibibytes. Since this is a small project, we do not need many gibibytes, but future projects may require more. To set up Storage Autoscaling, max_allocated_store = y (where y is a number higher than x) would be used below our allocated_storage line.</p><p>engine = &quot;mysql&quot; declares which database engine to use, while engine_version = &quot;8.0.20&quot; declares we are using MySQL’s engine version of 8.0.20. These will differ based on what engine/version you are using for your database server.</p><p>Finally, use instance_class = &quot;db.t3.micro&quot; to declare the instance type of the RDS instance and name your database.</p><pre><em># Create a database server</em></pre><pre><strong>resource</strong> &quot;aws_db_instance&quot; &quot;default&quot; {<br>allocated_storage = 5<br>engine         = &quot;mysql&quot;<br>engine_version = &quot;8.0.20&quot;<br>instance_class = &quot;db.t3.micro&quot;<br>name           = &quot;initial_db&quot;<br>username       = &quot;&lt;your-aws-username&gt;&quot;<br>password       = &quot;&lt;your-aws-password&gt;&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*rYRU4YhUVbrJILvW4GlhSw.png" /><figcaption>MySQL Database Block</figcaption></figure><h4><strong>Step 4: Create a load balancer that will direct traffic to the public subnets</strong></h4><p>A load balancer serves as the single point of contact for clients and distributes incoming traffic across multiple targets. By using a load balancer, our application availability is increased. There are four different types of <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/load-balancer-types.html">Load Balancers</a>: Application Load Balancers (ALB, Layer 7), Network Load Balancers (NLB, Layer 4), Classic Load Balancers (CLB, Layer 4), and Gateway Load Balancers (GLB, Layer 3).</p><p>Below, a Network Load Balancer (NLB) is used in our resource block. The load_balancer_type = &quot;network&quot; line is where we declare which Load Balancer we use. I chose a Network Load Balancer because it operates at the connection level, routing connections to targets within my VPC. NLBs also handle millions of requests per second while maintaining ultra-low latencies.</p><pre><em># Create a Network Load Balancer</em></pre><pre><strong>resource</strong> &quot;aws_lb&quot; &quot;NLB17&quot; {<br>name = &quot;NLB17&quot;<br>internal = false<br>load_balancer_type = &quot;network&quot;<br>subnets = [&quot;&lt;your-public-subnet-here&gt;&quot;, &quot;&lt;your-public-subnet-here&gt;&quot;]<br>enable_deletion_protection = false #true if you are not planning on destroying your load balancer<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEb8Shq8A2dkpH6N25UqRg.png" /><figcaption>Network Load Balancer Block</figcaption></figure><p>Creating an <strong>outputs.tf </strong>file makes information about the infrastructure available on the command line and can expose information for other Terraform configurations. In the <strong>outputs.tf </strong>file, insert the below code:</p><pre><em># VPC</em></pre><pre><strong>output</strong> &quot;vpc_id&quot; {<br>description = &quot;The ID of the VPC&quot;<br>value       = module.vpc.vpc_id<br>}</pre><pre><em># CIDR blocks</em></pre><pre><strong>output</strong> &quot;vpc_cidr_block&quot; {<br>description = &quot;The CIDR block of the VPC&quot;<br>value       = module.vpc.vpc_cidr_block<br>}</pre><pre><em># Subnets</em></pre><pre><strong>output</strong> &quot;private_subnets&quot; {<br>description = &quot;List of IDs of private subnets&quot;<br>value       = module.vpc.private_subnets<br>}</pre><pre><strong>output</strong> &quot;public_subnets&quot; {<br>description = &quot;List of IDs of public subnets&quot;<br>value       = module.vpc.public_subnets<br>}</pre><pre><em># NAT gateways</em></pre><pre><strong>output</strong> &quot;nat_public_ips&quot; {<br>description = &quot;List of public Elastic IPs created for AWS NAT Gateway&quot;<br>value       = module.vpc.nat_public_ips<br>}</pre><pre><em># AZs</em></pre><pre><strong>output</strong> &quot;azs&quot; {<br>description = &quot;A list of availability zones specified as argument to this module&quot;<br>value       = module.vpc.azs<br>}</pre><p>When running Terraform, declaring the version we are using for both Terraform and our provider (AWS) allows us to have control of our Terraform projects. In the<strong> versions.tf</strong> file, input the below code:</p><pre><strong>terraform</strong> {</pre><pre>required_version = &quot;&gt;= 0.12.26&quot;</pre><pre><strong>required_providers</strong> {<br>aws = {<br>source  = &quot;hashicorp/aws&quot;<br>version = &quot;&gt;= 3.15&quot;<br>}<br>}<br>}</pre><p>Now run a terraform init, terraform fmt, terraform plan, and finally a terraform apply. The apply may take several minutes, so be patient with the process!</p><p><strong>Let’s check to see how our AWS Account looks after our </strong><strong>terraform apply</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-kXbsUorLkxkqftHGQ4GQ.png" /><figcaption>VPC created with correct CIDR!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7S9g9zAUEjhcHFbBVqYTw.png" /><figcaption>Two public and one private subnet were created with the correct CIDRs!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q7iBgI944npzA9Nehw9uJg.png" /><figcaption>MySQL RDS Database created!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6f-_KNdsWLytbaAgTOWPOA.png" /><figcaption>Load Balancer created!</figcaption></figure><p>Now that the tasks are completed it is time to destroy our module and double check that our AWS account is clean and free from future charges. In the VSCode terminal, perform a<strong> </strong><strong>terraform destroy</strong>(may take several minutes to complete). After the destroy is complete, the newly created VPC should no longer be seen in your AWS account.</p><p>Great work! Thanks for following along with me in deploying a three-tier AWS VPC architecture using Terraform. Be sure to connect with me on LinkedIn — linkedin.com/in/helenccampbell</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c08f5e412db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/deploying-a-3-tier-aws-vpc-architecture-using-terraform-4c08f5e412db">Deploying a 3-Tier AWS VPC Architecture Using Terraform</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Static Website in a Docker Container using NGINX]]></title>
            <link>https://towardsaws.com/deploying-a-static-website-in-a-docker-container-using-nginx-a651893b88ee?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/a651893b88ee</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Mon, 24 May 2021 22:17:15 GMT</pubDate>
            <atom:updated>2022-10-25T15:24:03.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*LZ1cWOqlf3atWSRNjw2D8Q.png" /></figure><p>We are tasked with deploying a custom image and writing a script in a file. Prerequisites to complete this project: Docker Account (free), Docker running locally, IDE or text editor (VSCode, Atom, etc.), and an AWS account with AWS CLI configured.</p><p><strong>Steps:</strong></p><p>1. Create your image using NGINX and add a file that will tell you the time of day the container has been deployed</p><p>2. Deploy your container with port 8000 open</p><p>3. Save your container data in an S3 bucket</p><p><strong>What is Docker?</strong></p><p>Docker is a software platform that simplifies the process of building, running, managing, and distributing applications. It does this by virtualizing the operating system of the computer on which it is installed and running.</p><p><strong>What is NGINX?</strong></p><p>Since its initial success as a web server, Nginx is an open-source web server that is now also used as a reverse proxy, HTTP cache, and load balancer.</p><p><strong>What is an AWS S3 Bucket?</strong></p><p>An Amazon S3 bucket is a public cloud storage resource available in Amazon Web Services (AWS) Simple Storage Service (S3), an object storage offering. Amazon S3 buckets, similar to file folders, store objects consisting of data and its descriptive metadata.</p><p><strong>Step 1: Create your image using NGINX and add a file that will tell you the time of day the container has been deployed</strong></p><p><strong>Pull the latest NGINX image</strong></p><pre>docker pull nginx:latest</pre><p><strong>Create a new folder for your NGINX image files</strong></p><pre>mkdir nginx-html<br>cd nginx-html</pre><pre>#Create an index.html file<br>touch index.html</pre><p><strong>Add a file that tells the time of day the container has been deployed</strong></p><p>Head over to your IDE (I use vscode), and inside your index.html file, insert the code below. Setting the language to HTML will significantly help in formatting and auto-completion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkoxcnkkkIauR5KbwMKX9w.png" /></figure><p><strong>Step 2: Deploy your container with port 8000 open</strong></p><p><strong>Run container with flags:</strong></p><ul><li>-d specifies the container runs in detached mode</li><li>-p tells Docker to map the ports exposed in the container by the NGINX image to the specified port on the Docker host.</li></ul><pre>docker run -d -p 8000:80 -v ~/nginx-html:/usr/share/nginx/html --name &lt;your-nginx-name-here&gt; nginx </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5GJ0YLeGRWV5oH6T8ZM7A.png" /></figure><p>The line of characters returned is the long form of the container ID that has been created.</p><p><strong>Verify container creation by running the command below:</strong></p><pre>docker ps </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdkStoq9NxZkcnA-AiAk0Q.png" /></figure><p><strong>Go to your browser and visit your port on the local host to view the static page that was created (http://localhost:8000):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*39bA2S7w6ydR_xm47Travg.png" /></figure><p><strong>Step 3: Save container data in an S3 bucket</strong></p><p>Be sure to have your account configured through AWS CLI for this part!</p><p><strong>Make a new S3 bucket</strong></p><pre>aws s3 mb s3://&lt;insert-unique-name-here&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*Ai5rHwjKY5G7MY7X_bDJMw.png" /></figure><p>Have the path to your index.html file handy for this next part!</p><pre>aws s3 cp &quot;&lt;file-path-here&gt; (example: /Users/user1/nginx-html/index.html&quot; s3://&lt;insert-created-bucket-here&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCucQRcF6xCzUdKgSDnvQw.png" /></figure><p>Head over to your AWS Console to ensure that the new bucket file created allows public access to all, then copy and paste the URL of the bucket file into your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d8wFD2-4bvlUAQA7j6Qs5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GtGprtvxFObP_cKAqqQ3Cw.png" /></figure><p>You should see your index.html page in your browser after copying it and searching for it. After this step, you are finished! Be sure to clean your environment as needed.</p><p>Thanks for checking this out! I hope it helps! Find me on LinkedIn — linkedin.com/in/helenccampbell</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a651893b88ee" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/deploying-a-static-website-in-a-docker-container-using-nginx-a651893b88ee">Deploying a Static Website in a Docker Container using NGINX</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Python 3 Environment on an EC2 Instance with AWS CLI]]></title>
            <link>https://helenccampbell.medium.com/creating-a-python-3-environment-on-an-ec2-instance-with-aws-cli-e48d2f19979b?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/e48d2f19979b</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[vim]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Tue, 11 May 2021 05:23:04 GMT</pubDate>
            <atom:updated>2022-10-25T15:21:22.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5fcGtBo_ei1FfPJtF3nRYQ.jpeg" /></figure><p>In this project, we will be bootstrapping an EC2 Instance where a Python3 Environment is configured to run a simple application.</p><p>An AWS account is needed, along with AWS CLI downloaded on your local system. Provided is a link to guide you through the download process for AWS CLI for different operating systems: <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html">https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html</a></p><p>Once you have downloaded and logged into your AWS CLI through your terminal, clear the terminal to create a new space to work on to complete this project.</p><p><strong>Step 1:</strong> Create an Ubuntu 20.04 EC2 Instance (t2.micro) |<strong> Step 2:</strong> Connect and login to the instance using your key-pair | <strong>Step 3:</strong> Refresh updates and upgrade all packages on the instance | <strong>Step 4:</strong> Create an “environment” directory and a virtual Python environment in “environment” directory | <strong>Step 5:</strong> Activate virtual environment and confirm environment is up | <strong>Step 6:</strong> Create a program with a .py file | <strong>Step 7:</strong> Print your message in that file | <strong>Step 8:</strong> Exit vim and run the program!</p><h4><strong>Step 1: Create an Ubuntu 20.04 EC2 Instance (t2.micro)</strong></h4><p>In Terminal, change the Key Pair Name and Security Group IDs to match your account details using the code below.</p><p>This step requires a key pair to exist in your AWS account. It can only be downloaded once to your local environment, so be sure to know where it has been downloaded.</p><p>The image ID for an Ubuntu Server 20.04 EC2 is ami-01f87c43e618bf8f0 . The key pair name will be the one you created in your AWS account. The security group can also be found through our VPC dashboard in AWS; I will be using the default security group of my default VPC for this project.</p><p>aws ec2 describe-vpcs : this line of command outputs the AWS VPCs in your AWS environment</p><p>aws ec2 describe-subnets : this line of command outputs the AWS subnets correlated to your environment. The subnets must match the security group in this project.</p><p>aws ec2 describe-security-groups : this line of command outputs the security groups connected to the above VPC. Be sure to match the correct security group to the VPC being worked with.</p><p>aws ec2 describe-key-pairs : this line of command outputs the key pairs in your AWS EC2 environment.</p><pre>aws ec2 run-instances --image-id ami-09e67e426f25ce0d7 --count 1 --instance-type t2.micro --key-name &lt;KEY_PAIR_NAME&gt; --security-group-ids &lt;DEFAULT_SG_ID_NAME&gt; </pre><p>You will know your creation has succeeded when the output is a created JSON script. This JSON script validates the creation of the Ubuntu 20.04 EC2 Instance (t2.micro) in your AWS environment. I had to spend about 5 minutes discovering the correct security group to use in my line of code because I have more than a default VPC in my AWS environment. A friendly reminder that there is power in being patient.</p><p>Check in the CLI that the creation has been successful using the following code:</p><pre>aws ec2 describe-instances --filters &quot;Name=instance-type,Values=t2.micro&quot; --query &quot;Reservations[].Instances[].InstanceId&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khlfg2XvIbC2Op9a3Zx4qQ.png" /><figcaption>Proof of newly created EC2</figcaption></figure><p>The AWS console is another resource to check the success of the created EC2 Instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DI6S5Vs0Q99WwjO0yJoOsQ.png" /></figure><h4><strong>Step 2: Connect and log in to the Instance using your Key Pair</strong></h4><p>In the console, select the instance to start a connection. Select the “Connect” button, seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RRhe7TQqqMvg_TGGwsMocQ.png" /></figure><p>Follow the steps below to SSH into your EC2 Instance through Terminal.</p><p>Do not forget to cd downloads (or cd into wherever your private key file was saved). Failing to do so will lead to frustration/confusion because you will get an error about your key pair.</p><p>Also, be sure to open port 22 on your security group. If this is not done, you will not be able to connect to your EC2 Instance through CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLEISEtzOdUjGjawZ5nJxg.png" /></figure><p>Be sure that the inbound security group settings have Port 22 open, which is essential when attempting to SSH into the EC2 Instance through the Terminal.</p><pre>cd Downloads<br>chmod 400 &lt;KEY_PAIR_NAME&gt;.pem <br>ssh -I &quot;&lt;KEY_PAIR_NAME&gt;.pem&quot; ubuntu@ec2-&lt;EC2_IP&gt;.compute-<br>1.amazonaws.com</pre><p>Success will look like the photo below. You will always be asked yes or no when connecting to the instance, be sure to say yes. Once successfully connected, we turn green and can continue to perform our task in our new instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOVwOx_go0yjkkVzP3C8JA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*5nsDb8mZzM2g8yeKuvpzHg.png" /></figure><h4><strong>Step 3: Refresh Updates and Upgrade All Packages on the Instance</strong></h4><p>To update, use the command below:</p><pre>sudo apt-get update</pre><p>To upgrade all packages, use the command below:</p><pre>sudo apt-get upgrade</pre><p>These updates and upgrades may take longer than expected, be patient as these happen.</p><h4><strong>Step 4: Create an “environment” Directory and a Virtual Python Environment in the “environment” Directory</strong></h4><pre>mkdir environment <br>cd environment <br>sudo apt install python3-venv<br>python3 -m venv env</pre><h4><strong>Step 5: Activate Virtual Environment and Confirm Environment is Up</strong></h4><pre>source env/bin/activate<br>which python</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*XpL-uJOd3D7wEvDeC-xLmw.png" /></figure><h4><strong>Step 6: Create a program called hello.py</strong></h4><p>You can create whatever program you’d like; it doesn’t have to be limited to hello.py; feel free to get creative!</p><pre>vim hello.py</pre><h4><strong>Step 7: Print “What’s Up, World!” in that File</strong></h4><p>Remember, apostrophes need to be handled appropriately when using Python. Escape characters can be used, or the text can be wrapped with double quotes to use the apostrophe. To start your text, remember to use the “i” key on your keyboard; this enters INSERT mode.</p><pre>#!/bin/bash </pre><pre>print(&#39;What\&#39;s Up, World!&#39;) #example of using escape character<br>print(&quot;What&#39;s Up, World!&quot;) #example of wrapping with double quotes</pre><h4><strong>Step 8: Exit vim and Run the Program!</strong></h4><pre>python3 hello.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*cepn0V7I-50w8zrvgUIdjA.png" /></figure><p>Both scripted lines above came out the same, exemplifying how the different handling of apostrophes can create the same output. It all depends on what the user is comfortable doing.</p><h4>Now that the task is completed, the following steps are to clean up/destroy what we have created.</h4><p>By typing “exit” on the command line, the connection between the EC2 Instance will be broken. Once that happens, clean up the environment to avoid any unnecessary charges by AWS! This can be done by terminating (through CLI or console) the EC2 Instance created during this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*GjAZMj3GvA_-S676zfWZ6Q.png" /></figure><pre>aws ec2 terminate-instances --instance-ids &lt;ID_HERE&gt;</pre><p>One more run of aws ec2 describe-instances can provide you with another check to see that the instance has been terminated. It is always an option to manually check if the instance has been terminated using the AWS Console.</p><p>Thanks for trying this exercise with me! I hope you learned something new along the way and enjoyed experimenting with Python scripting. Find me on LinkedIn — linkedin.com/in/helenccampbell</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e48d2f19979b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up an Auto Scaling Group with AWS CLI]]></title>
            <link>https://helenccampbell.medium.com/setting-up-an-auto-scaling-group-with-aws-cli-215c2ec06e71?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/215c2ec06e71</guid>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[aws-cli]]></category>
            <category><![CDATA[auto-scaling-groups]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[launch-template]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Fri, 07 May 2021 00:52:37 GMT</pubDate>
            <atom:updated>2022-10-25T15:16:09.229Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*XBcZEbDswfaTf3Kjeu-svg.png" /></figure><p>Like my last project, we are setting up an Auto Scaling group, but this time through our terminal. An AWS account is needed for this project, along with the AWS CLI downloaded to your terminal. This was performed on a macOS, so the download process may slightly differ on other operating systems.</p><p>For all other OS environments, follow this link to download AWS CLI correctly to your environment: <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html">https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html</a></p><p><strong>Download AWS CLI to your terminal</strong></p><pre>curl &quot;<a href="https://awscli.amazonaws.com/AWSCLIV2.pkg">https://awscli.amazonaws.com/AWSCLIV2.pkg</a>&quot; -o &quot;AWSCLIV2.pkg&quot;<br>sudo installer -pkg AWSCLIV2.pkg -target /</pre><p>Run the code below to verify that the AWS CLI can be found.</p><pre>which aws<br>aws --version</pre><p>These steps will allow you to locate where the AWS CLI is on your computer and which version you have downloaded.</p><p><strong>Create a user and give them programmatic and console access</strong></p><pre>aws iam create-user --user-name &lt;NEW_USER-NAME&gt;</pre><p>You will be returned code in JSON format indicating your user name, user ID, ARN (Amazon Resource Name), and the user&#39;s creation date. Note: you will see your AWS account ID in the ARN output information.</p><p>I already have an Admin group created in my AWS account; therefore giving programmatic and console access to my new user is simply writing code and adding them to my Admin group.</p><pre>aws iam add-user-to-group --user-name &lt;USER-NAME&gt; --group-name &lt;GROUP-NAME&gt;</pre><p>The code below will verify that your new user was successfully placed in your group.</p><pre>aws iam get-group --group-name &lt;GROUP-NAME&gt; </pre><p><strong>Download the Access Key and Secret Access Key in a safe place</strong></p><pre>aws iam create-access-key --user-name &lt;USER-NAME&gt;</pre><p>Your information is returned in JSON format. It consists of your user name, access key ID, status, secret access key, and the creation date. Saving your access and secret access key is highly important.</p><pre>vim ~/.aws/credentials</pre><p>The above code opens a file for you to input the new user’s access key and secret access key. Copy and paste the two keys into this vim file from the returned information in the JSON format above. You will see that the default user is also there. Knowing how to do this is essential when handling multiple credentials in further projects you may be given.</p><p><strong>Create an EC2 Instance (t3.nano, Amazon 2 AMI)</strong></p><p>In this step, the default settings are used for the security group and subnet ID that may have previously been set up in our AWS account. We are asked to use Amazon 2 AMI in this project, which is pasted below in the code, along with our instance type.</p><pre>aws ec2 run-instances --image-id ami-0742b4e673072066f --count 1 --instance-type t3.nano --key-name &lt;EXISTING_KEY_NAME&gt; --security-group-ids sg--&lt;YOUR_SG_ID&gt; subnet-id subnet-&lt;DEFAULT_SUBNET_ID&gt;</pre><p><strong>List the Instance to ensure creation</strong></p><pre>aws ec2 describe-instances --filters &quot;Name=instance-type,Values=t3.nano&quot; --query &quot;Reservations[].Instances[].InstanceId&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MeG1b_Mc5wAYSQ3nQDNxA.png" /></figure><p>The output above in our terminal proves that our Instance has been successfully created, and we can go into the AWS Console to double-check that success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7L9WY225OO5q_sHE9pZ5Tg.png" /></figure><p><strong>Create an Auto Scaling group with a minimum of 2 and a maximum of 5</strong></p><pre>aws autoscaling create-auto-scaling-group --auto-scaling-group-name &lt;ASG_NAME&gt; --launch-template LaunchTemplateId=&lt;LT_ID&gt; --min-size 2 --max-size 5 --vpc-zone-identifier &quot;&lt;SUBNET&gt;, &lt;SUBNET&gt;, &lt;SUBNET&gt;&quot;</pre><p>The code above will create instances you can check in your console, as seen below. In sticking with the CLI, the code below will provide you with your Auto Scaling group with the given name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H3kD2iFXHNONG8wZZJfweg.png" /></figure><pre>aws autoscaling describe-auto-scaling-groups</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*auoKhH6tNV-DxfX9eXPrIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TGCQ_8Vt-yOUerxkG5CwDw.png" /><figcaption>Double-checking the Auto Scaling group on the Console.</figcaption></figure><p><strong>Clean up environment</strong></p><p>Now that we have successfully completed our task, it is time to undo everything by following these two steps:</p><ol><li>Delete launch template</li></ol><pre>aws ec2 delete-launch-template --launch-template-id &lt;lt-0abcd290751193123&gt;</pre><p>2. Delete group while terminating any unwanted EC2 Instances</p><pre>aws autoscaling terminate-instance-in-auto-scaling-group --instance-id &lt;i-056a54b876bb83220&gt; --no-should-decrement-desired-capacity</pre><p>Again, double checking that your environment has been cleaned up never hurts, and may help you avoid unnecessary costs garnered while attempting this project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=215c2ec06e71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Test Downtime of Highly Available Servers in AWS]]></title>
            <link>https://aws.plainenglish.io/testing-downtime-of-highly-available-servers-in-aws-aa17524e2d2?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa17524e2d2</guid>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[aws-auto-scaling]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Mon, 19 Apr 2021 00:54:08 GMT</pubDate>
            <atom:updated>2022-10-25T15:13:24.364Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*e0yKwyEpqrWW1_ELRxrAwg.png" /></figure><p>We are tasked with testing our highly available servers to ensure we have 0% downtime. To perform this task, an AWS account is required.</p><p><strong>Create a launch configuration with t3 nano instances—bootstrap instances with an apache web server. Add scripts in the user data section.</strong></p><p>Select and save an AMI instance ID to your clipboard from the instance creation page by going to the EC2 service page and selecting “Launch instances.” Copy and save “ami-0533f2ba8a1995cf9” to your clipboard and exit the instance launch page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqT94dTuO9U6s5Pa7SiAgw.png" /></figure><p>Still, in EC2 Dashboard, locate and select the “Launch Configurations” button under the Auto Scaling menu on the left-hand side. Once there, select “Create launch configuration.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*c6cXdBNmuD8yi5NsWxI0zg.png" /></figure><p>Insert a name, paste the saved AMI instance ID from above in the AMI section, and click “Choose instance type.” Type “t3.nano” into the search bar, and select and save it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHaf1wsCw0lrp8uX-PC23Q.png" /></figure><p>In the “Additional configuration — <em>optional</em>” section, select “Advanced details.” Underneath the “User data” section is where the bootstrap script found below is placed.</p><pre>#! /bin/bash<br>sudo yum update -y<br>sudo yum install httpd -y<br>sudo systemctl enable httpd &amp;&amp; sudo systemctl restart httpd</pre><p>Create a new security group, matching the security group name and description. For the rules, SSH will have a source type of “Custom IP,” which will be your IP, followed by /32, which specifies all 32 bits of your IP address, e.g., xxx.xxx.xx.xx/32. If you do not know your IP, use Google to find out. Add another rule, select HTTP, and have the source type be your IP. If you want others to have access, select “Anywhere” as the source type. A new key pair will need to be created and downloaded to a location you can easily access. Once that is downloaded, select “Create launch configuration.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aI3WykPme-Ut8Eb9GCnhkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiB-OqR6DGh2d5pHlkIjSA.png" /></figure><p><strong>Create an autoscaling group with a min of 2 and a max of 5 instances running.</strong></p><p>On the left-hand menu, select “Auto Scaling Groups.” Once there, select “Create Auto Scaling group.” Name the Auto Scaling group and select “Switch to launch configuration.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oMzXZIqVWM3fr265-seqRw.png" /></figure><p>Select the newly created launch configuration. You are met with information about your launch configuration; ensure it is accurate and select “Next.”</p><p>On the “Configure settings” page, select the default VPC and two subnets and select “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_17zOWq4KWC9TQb2xrGyQ.png" /></figure><p>For this project’s sake, select “No load balancer” since there is no plan to receive lots of incoming traffic. Select “Next.”</p><p>We are setting up our auto-scaling group with a minimum of 2 and a maximum of 5 instances. Insert these numbers on the size and scaling policies page, and set the desired capacity to 3. Leave the defaults as is and select “Next.” Continue to the review page and create the auto-scaling group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MJOBGm65Ey1b2PBAIm6e1Q.png" /></figure><p><strong>Add a policy where if 80% of the CPU is used on any instance, it will scale out and add.</strong></p><p>Find yourself on the Auto Scaling Group page and select the checkbox next to our created ASG. Below, select the “Automatic scaling” tab, and select “Add policy.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C5Swkw8rh0k5HcfGNWNw-g.png" /></figure><p>Select “Step scaling” and name your scaling policy; choose “Billing Alarm” in the CloudWatch alarm section. If you do not have a billing alarm set up in your AWS account, there is a link to do so. Setting up a billing alarm is essential to notify you when you exceed your set price limit in your AWS account. Select “Add” in the “Take the action” box, insert “80” in the first numbers box, select “Percent of group” in the following box, and leave the last box as default, insert “300” under the “Instances need” subsection and click “Create.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QuUW4CRS81xzXwcOFkbIhg.png" /></figure><p><strong>Add a policy where if 40% of the CPU is used on any instance, it will scale in and subtract.</strong></p><p>Follow the same steps as above, rename the policy name, select “Remove” for “Take the action,” and insert “40” for the percentage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNy_t4H6lhEKVYZ4E0c24w.png" /></figure><p><strong>Test your scaling policy by stopping an instance to see if your auto-scaling policy works to scale out.</strong></p><p>Return to the EC2 Instances page. Select and stop all three instances using the “Instance State” menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vJ-0UJlekelye-RyX0A4YA.png" /></figure><p>Once 300 seconds pass, three new instances will be created to replace the stopped instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwhNdfz1ItV6Qoud8mv8ZQ.png" /></figure><p>A log is provided of this activity on the “Auto Scaling Groups” section on the EC2 landing page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwhNdfz1ItV6Qoud8mv8ZQ.png" /></figure><p>We have now completed our task. Be sure to clean up your AWS Environment to avoid being unnecessarily charged. First, delete the Auto Scaling Group since we have created them in a way where they will continue to replace stopped instances. Second, delete the Launch Configuration that was made. Finally, double-check to see that the EC2 Instances are terminated.</p><p>Though simple, this project shows the importance of Auto Scaling and what it does for our Load Balancers when experiencing an increase or decrease in demand.</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa17524e2d2" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/testing-downtime-of-highly-available-servers-in-aws-aa17524e2d2">How to Test Downtime of Highly Available Servers in AWS</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting to a Private Instance through a Bastion Host]]></title>
            <link>https://helenccampbell.medium.com/connecting-to-a-private-instance-through-a-bastion-host-5b78fceadb3a?source=rss-c602c819811------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b78fceadb3a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-vpc]]></category>
            <category><![CDATA[bastion-host]]></category>
            <category><![CDATA[subnet]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <dc:creator><![CDATA[Helen Campbell]]></dc:creator>
            <pubDate>Mon, 15 Mar 2021 02:38:52 GMT</pubDate>
            <atom:updated>2022-10-25T15:05:09.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*vKL4ZwuW9tfxFUFKFaZB9Q.png" /></figure><p>Task: we are setting up architecture for our team to have a private instance in a private subnet for only our team to access. We will need to configure our architecture so our team can access the private instance.</p><p>Let’s head over to the AWS Console.</p><p><strong>Step 1: Build a Custom VPC with a CIDR of 10.0.0.0/16</strong></p><p>Locate and select VPC on the AWS Services Page under Networking &amp; Content Delivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*WzDh9fn-759YL8CMgKuIIw.png" /></figure><p>On the VPC page, click “Create VPC.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P9uWkZTHXi3W9gHYu5_2dw.png" /></figure><p>Next, enter a name in the name tag box; I chose “p1vpc”. We will insert our CIDR into the IPv4 CIDR block box as 10.0.0.0/16. Leave the defaults as they are given and click “Create VPC.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTNNv6t-R--oCsFa2COUqg.png" /></figure><p><strong>Step 2: Create a Public Subnet with a CIDR of 10.0.1.0/24</strong></p><p>To create a subnet, find Subnets on the VPC drop-down menu on the left-hand side. Once there, click “Create subnet.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEAacC40BlLjNpElqm5ALg.png" /></figure><p>We are asked to choose the VPC ID. Select the VPC that you have created (not the default option). The VPC ID is on the top row, with the CIDR value on the bottom (10.0.0.0/16). Click “Create subnet.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPT7xL9r4LOHKd6dAmfNPA.png" /></figure><p>In the subnet settings, enter a name and an IPv4 CIDR block. In this instance, “public-sn” works. Enter 10.0.1.0/24 in the IPv4 CIDR block box, leave the key and value as they are, and click “Create Subnet.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lx-KNyvelgzZgzkfsoGg-w.png" /></figure><p><strong>Step 3: Create a Private Subnet with a CIDR of 10.0.2.0/24</strong></p><p>Repeat the process above, changing the subnet name to “private-sn” and the IPv4 CIDR block to 10.0.2.0/24. Leave the key and value as is and click “Create subnet.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K98dsZU949XxapxhQpTwkA.png" /></figure><p>Our subnet page should now list our two subnets named public-sn and private-sn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ed5gb8ihrtOMJbbcSb2PZQ.png" /></figure><p><strong>The following steps are crucial to the success of this project!</strong></p><p><strong>Step 1: Create and Attach the Internet Gateway</strong></p><p>On the left-hand side of our screen, locate internet gateway on our VPC drop-down menu. Click “Create internet gateway.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ea8Uuq6N-t9litMneRIV_w.png" /></figure><p>In the name tag box, enter a name for the internet gateway, such as “myIGW.” Click “Create internet gateway.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tc_7ObxH6ZPnEtAj205g4A.png" /></figure><p>You are met with a page about your new internet gateway that has been created. Select the actions box and “Attach to VPC.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ESzQn8DC-XlO_i3TbWRGnQ.png" /></figure><p>A drop-down menu is given where we select our created VPC. Select “Attach internet gateway.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUvIwZO2ecwiCu8Xn3PdMw.png" /></figure><p><strong>Step 2: Create a NAT Gateway</strong></p><p>Find NAT Gateways under the VPC drop-down menu on the left-hand side. Select “Create NAT gateway.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ZxNa2onXJ5OMCbnMKAw5A.png" /></figure><p>We are creating a NAT gateway in our public subnet. On the creation page, enter a name such as “myGW.” Select the public subnet from the subnet menu and allocate an elastic IP. Select “Create NAT gateway.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwhotuug130dbnJUZMGbuA.png" /></figure><p><strong>Step 3: Create and Connect the Route Tables</strong></p><p>On the left-hand side, click “Route Tables.” Once on the page, select “Create route table.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9FRyK8j9qa-2x046m0gSA.png" /></figure><p>On the “Create route table” page, we will create a public route table and a private route table. The steps are the same for both. In the photo below, I show the creation of the public route table; please note that you NEED TO create a public AND private route table. Enter the names (public-rt and private-rt), select our VPC and click the “Create” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQl68lzVzGhbUvkVSe7PMg.png" /></figure><p>We now need to edit our routes for the public-rt and private-rt to connect to their respective Internet/NAT Gateway. Below are the steps for the public-rt. Select our public-rt box, click the routes tab found below, hit “Edit routes.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7Ra49XegczLIFEoDiGHwA.png" /></figure><p>Add a route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v4NM9cPVyGUg2EHdtzJhLA.png" /></figure><p>Type in 0.0.0.0/0 for our destination, select the Internet Gateway (myIGW) we created for the target, and save routes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EwP6YCWnzBmjKtYuyC7IuQ.png" /></figure><p>Follow the same steps with our private subnet selected, but this time we want to target the NAT gateway that we created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nz6UIZM9_W5DJ1J13C20w.png" /></figure><p><strong>Step 4: Subnet Associations</strong></p><p>For the route tables, we will edit the subnet associations. Public to public, private to private. The photos below show the steps for the private route table. Repeat the process with the public route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lm8xQqJQDb4O4tRXMlzdWw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_CHgwnST5xvrQ6dvFwMMw.png" /></figure><p>We now need to locate the EC2 page under Compute on the AWS Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*-FnK1VSdTXcr20AIIV5yiA.png" /></figure><p><strong>Step 4: Create a Bastion Host in the Public Subnet with a Public IP Address</strong></p><p>On the EC2 Resources page, click “Instances (running).”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fdTUJk_jjg3tpLy49zhvrg.png" /></figure><p>Click “Launch Instances.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NIYPEK3Tda4U24boSpGlpQ.png" /></figure><p>Select which AMI to work with. Since we are working with the free tier of AWS, the first AMI option works (Amazon Linux 2 AMI (HVM), SSD Volume Type).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-diGqmXJkFcpJ1ryT_VThQ.png" /></figure><p>Then choose the Instance Type t2.micro and hit “Next: Configure Instance Details.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4W2bM3JZr3900w9koKA63A.png" /></figure><p>We are concerned with Network, Subnet, and Assign Public IP on the Configure Instance Details page. For Network, select the VPC ID (p1vpc) we set up earlier. Select the public subnet and select enable for Auto-assign Public IP. Click “Next: Add Storage.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kCsoo87lF60-evIFnvy5UQ.png" /></figure><p>We will leave storage as default, and click “Next: Add Tags.” Add “Name” for the key and “BastionHost” as the Value. Click “Next: Configure Security Group.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Nj_3RAr5IvgPhfivWD6Rg.png" /></figure><p>Create a new security group named and described as BastionHost. Change the source to “My IP” and click “Review and Launch.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UvxhakGwEOhIQjbeLREmdg.png" /></figure><p>Create a new key pair named BastionHostKP for this project, and download the key pair. It is essential to know where this key pair is downloaded into your computer so you can use it in the future. Remember, we can only download a key pair once. Click “Launch Instances.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tz1Ic8Q24SiJ9sGYQhgHGg.png" /></figure><p><strong>Step 5: Launch an EC2 t2 or t3 Nano Instance in the Private Subnet with only a Private IP Address</strong></p><p>Follow the steps in creating a new instance as mentioned above. For Network, select our created VPC, choose private-sn for the Subnet, and select disable for Auto-assign Public IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxfOL8SMEkb7mMu_3Gq4Hw.png" /></figure><p>Leave storage as default and click “Next: Add Tags.” Add “Name” for the key and “PrivLayer” as the Value. Click “Next: Configure Security Group.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPUkrYGpQslFnpZlKLsB_Q.png" /></figure><p>Click “Create a new security group” and enter p1pSG for the security group name and description. Change the source of the IP to Custom and enter the Bastion Host IP; this can be found on your Bastion Host Instances detail page. Click “Review and Launch.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4SfJ5L9Nh-XECoubC6RhA.png" /><figcaption>Private IPv4 address for Bastion Host used in photo below</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAmXBSNywS_QYHiDo3LsfA.png" /></figure><p>Use the existing key pair that was created titled “BastionHostKP”. Acknowledge the message at the bottom and launch the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWl0VLsX_1KQBow9QntRyQ.png" /></figure><p><strong>Step 6: Connect “Successfully” to the Private Instance from the Bastion Host in your VPC!</strong></p><p>I use a Mac, so these next steps use Terminal.</p><p>Open Terminal and follow the steps found here: <a href="https://aws.amazon.com/blogs/security/securely-connect-to-linux-instances-running-in-a-private-amazon-vpc/">https://aws.amazon.com/blogs/security/securely-connect-to-linux-instances-running-in-a-private-amazon-vpc/</a>.</p><p>Ssh into your Bastion Host. Once you receive a success message, ssh into the “PrivLayer” instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_qEkSdQABqPWBAxmLGolg.png" /></figure><p>Once you have successfully connected into the Private Instance through the Bastion Host, you have completed your task.</p><p>Find me on LinkedIn — linkedin.com/in/helenccampbell</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b78fceadb3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>