avatarTeri Radichel

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

4381

Abstract

o “Name” and the value to whatever you want the name to be. the AWS console magically figures out that the Name tag is the name of your VPC and displays it accordingly.</p><p id="0ca9"><b>Add a “network” AWS CLI profile</b></p><p id="2bf5">Create the “network” AWS CLI profile. As a reminder we are simulating different teams with different responsibilities here.</p><p id="750f">We created a NetworkAdmins Group, Role and a NetworkAdmin user. Add MFA and credentials to your user and use those as described in the following post to create your profile, which is used by the scripts below.</p><div id="eef8" class="link-block"> <a href="https://readmedium.com/using-an-aws-cli-profile-with-mfa-a1ca79289031"> <div> <div> <h2>Using an AWS CLI Profile with MFA</h2> <div><h3>ACM.28 Testing our KMS Administrator Permissions with the AWS CLI</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*HV0AZEcJ-E1Sqxc0vmL1QQ.png)"></div> </div> </div> </a> </div><p id="d518"><b>Update the permissions for the network role</b></p><p id="dec6">We need to update the permissions for the Network Administrator role to allow it to deploy network resources. Most of our network resources will be in the EC2 service. Since networking can get complicated, I’m going to temporarily allow ec2.*. This is not generally recommended and definitely not for anyone you don’t want to allow to change your network resources.</p><p id="de20">It is unfortunate that networking is tied in with the permissions to create virtual machines in the cloud as it makes creating zero-trust policies challenging. We are going to run our templates and then go back and revise the policies to be zero trust policies using the method I showed you earlier in this post:</p><div id="5702" class="link-block"> <a href="https://readmedium.com/querying-cloudtrail-with-cloudtraillake-caf2e9e0561f"> <div> <div> <h2>Querying CloudTrail with CloudTrailLake</h2> <div><h3>ACM.37: Using CloudTrail Lake to query the actions needed to create zero-trust policies (Zero Trust Policies ~ Part 2)</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*Aznea7iQfPZaSJDnF45lvQ.png)"></div> </div> </div> </a> </div><p id="bc82">Return to the IAM folder. Alter the policy for network administrators and re-deploy it:</p><figure id="9af9"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*v1EqMXPqp5GevpD8SjSl4w.png"><figcaption></figcaption></figure><p id="dad2"><b>VPC</b></p><div id="3571" class="link-block"> <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html"> <div> <div> <h2>AWS::EC2::VPC</h2> <div><h3>Specifies a VPC with the specified IPv4 CIDR block. The smallest VPC you can create uses a /28 netmask (16 IPv4…</h3></div> <div><p>docs.aws.amazon.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div> </div> </div> </a> </div><p id="5890">Create a <b>Virtual Private Cloud </b>(VPC or your own network within the AWS Network). We’re going to keep it flexible by passing in the <b>CIDR</b> and <b>Name</b>. That way we can re-use this template later to create additional VPCs.</p><figure id="1c6f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Luyk5q-jMRFc_eusIl4AYg.png"><figcaption></figcaption></figure><p id="371f">The VPC resources is pretty simple:</p><figure id="13d7"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*OAjRUASeytvyxH2fQ9zM_w.png"><figcaption></figcaption></figure><p id="1e93">We will need to reference this VPC later so add outputs:</p><figure id="3f9c"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*jNJ4s0nT55EQS3cSo6cZlw.png"><figcaption></fig

Options

caption></figure><p id="3cef">Make sure the export name is unique because we can re-use this template to create multiple VPCs.</p><p id="9f9d"><b>Deploy script</b></p><p id="1c2c">I like to always test as I go so I’m going to jump over and create a deploy script and test what we have so far.</p><p id="91a5">Include the shared functions.</p><figure id="fe63"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*XMdTxoxZzuULDIfkgYowTg.png"><figcaption></figcaption></figure><p id="e898">We’ll allow our network profile to deploy these resources that we created earlier in the series.</p><figure id="c443"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*dM7hiUnbchn69oF5p4J4Kw.png"><figcaption></figcaption></figure><p id="6eb0">Pass in the appropriate parameters to deploy our stack using the shared function:</p><figure id="6f39"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*6bVI4JOFTcByQno8CaoOUA.png"><figcaption></figcaption></figure><p id="540a"><b>Create the deployment script</b></p><p id="dc16">Create a deploy.sh script in the root of the /network/stacks folder.</p><figure id="211e"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*ZilIPBIoHpsq2zF3wNP2XQ.png"><figcaption></figcaption></figure><p id="d72f"><b>Deploy and validate your VPC:</b></p><div id="8612"><pre>./deploy.sh</pre></div><p id="7eb3">Check to see that your VPC was created. Although VPC permissions fall under EC2, there’s a separate VPC dashboard and you should see your VPC there.</p><p id="9108"><b>Create a test script in the network directory</b></p><p id="4848">Just like with our other subfolders we want to create a test script so we can automate testing that all our scripts work correctly. Add a test script to the network directory and incorporate the test script into the root directory.</p><figure id="071c"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*360ljMUx9zIB3jG9O6tQKg.png"><figcaption></figcaption></figure><p id="9695">We’re not done with this template. In the next post we use a single template create a public or private VPC.</p><div id="eef6" class="link-block"> <a href="https://readmedium.com/public-and-private-vpcs-and-subnets-route-tables-73b0fd78caa7"> <div> <div> <h2>Public and Private VPCs and Subnets (Route Tables)</h2> <div><h3>ACM.61 Adding custom route tables with names to our AWS VPCs</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*RlM4H7lQdn1ZN71xQwALDw.png)"></div> </div> </div> </a> </div><p id="3b86">Follow for updates.</p><p id="4a3a">Teri Radichel | <i>© <a href="https://2ndsightlab.com/?source=post_page---------------------------">2nd Sight Lab</a> 2022</i></p><div id="8b5f"><pre><span class="hljs-section">About Teri Radichel:

⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab</pre></div><div id="caae"><pre><span class="hljs-section">Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation</pre></div><div id="5a42"><pre>Follow <span class="hljs-keyword">for</span> more stories like <span class="hljs-keyword">this</span>:

❤️ Sign Up my Medium Email List ❤️ Twitter: <span class="hljs-meta">@teriradichel</span> ❤️ LinkedIn: https:<span class="hljs-comment">//www.linkedin.com/in/teriradichel</span> ❤️ Mastodon: <span class="hljs-meta">@teriradichel</span><span class="hljs-meta">@infosec</span>.exchange ❤️ Facebook: 2nd Sight Lab ❤️ YouTube: @2ndsightlab</pre></div><figure id="faf5"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*H9Ew1KCl-29nZiPR.jpeg"><figcaption></figcaption></figure></article></body>

Automate Creation of a VPC

ACM.60 Creating an AWS VPC with a CloudFormation template

Part of my series on Automating Cybersecurity Metrics. Network Security. The Code.

Free Content on Jobs in Cybersecurity | Sign up for the Email List

We’ve been working on setting up a Lambda function. We looked at using AWS Lambda with Parameter Store and then in the last post, we added encryption to our Parameter using a KMS key.

Now let’s look at some of the other security controls we’ll need for our lambda function. I already wrote about Lambda networking options here:

We’re going to need some a VPC for some configuration changes I plan to make, along with some subnets and security groups. There’s also a VPC, subnet, and security group I should have created from the start but just getting around to it now.

Note that I am not going to cover all aspects of VPC creation, just what is relevant to our current architecture and maybe a bit about the connections for the developers who are building it, though the options might be different in a large enterprise.

CIDR Blocks and Network Ranges

This post is written for people who understand CIDRs and network ranges because any company concerned about security will hire someone either internally or as a contractor to design their networks that knows how to allocate IP addresses. However, I will provide the values you can pass in if you’re not a networking guru that should not cause problems if you are working in a test account that doesn’t have conflicting resources.

In this post I’m using the following for my VPC deployment. We’ll expand on this in upcoming posts.

VPC CIDR: 10.10.0.0/24

Directory Structure

Create a new directory: Network. Create the same subfolders as we did before: stacks > cfn.

We’ll create our CloudFormation templates in the cfn folder and a deploy script in the stacks folder. We’ll put a test script in the root folder.

I created the following templates in the cfn folder:

Resource Names and Tags

For some of the earlier resources on AWS they don’t have a “name” property. You create a name for the resource by defining a “tag” which is a key-value pair. Set the key to “Name” and the value to whatever you want the name to be. the AWS console magically figures out that the Name tag is the name of your VPC and displays it accordingly.

Add a “network” AWS CLI profile

Create the “network” AWS CLI profile. As a reminder we are simulating different teams with different responsibilities here.

We created a NetworkAdmins Group, Role and a NetworkAdmin user. Add MFA and credentials to your user and use those as described in the following post to create your profile, which is used by the scripts below.

Update the permissions for the network role

We need to update the permissions for the Network Administrator role to allow it to deploy network resources. Most of our network resources will be in the EC2 service. Since networking can get complicated, I’m going to temporarily allow ec2.*. This is not generally recommended and definitely not for anyone you don’t want to allow to change your network resources.

It is unfortunate that networking is tied in with the permissions to create virtual machines in the cloud as it makes creating zero-trust policies challenging. We are going to run our templates and then go back and revise the policies to be zero trust policies using the method I showed you earlier in this post:

Return to the IAM folder. Alter the policy for network administrators and re-deploy it:

VPC

Create a Virtual Private Cloud (VPC or your own network within the AWS Network). We’re going to keep it flexible by passing in the CIDR and Name. That way we can re-use this template later to create additional VPCs.

The VPC resources is pretty simple:

We will need to reference this VPC later so add outputs:

Make sure the export name is unique because we can re-use this template to create multiple VPCs.

Deploy script

I like to always test as I go so I’m going to jump over and create a deploy script and test what we have so far.

Include the shared functions.

We’ll allow our network profile to deploy these resources that we created earlier in the series.

Pass in the appropriate parameters to deploy our stack using the shared function:

Create the deployment script

Create a deploy.sh script in the root of the /network/stacks folder.

Deploy and validate your VPC:

./deploy.sh

Check to see that your VPC was created. Although VPC permissions fall under EC2, there’s a separate VPC dashboard and you should see your VPC there.

Create a test script in the network directory

Just like with our other subfolders we want to create a test script so we can automate testing that all our scripts work correctly. Add a test script to the network directory and incorporate the test script into the root directory.

We’re not done with this template. In the next post we use a single template create a public or private VPC.

Follow for updates.

Teri Radichel | © 2nd Sight Lab 2022

About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
Aws Vpc
Cloudformation
Automate
Cloudsecurity
Cybersecurity
Recommended from ReadMedium