This lab walks you through how to create a VPC using an AWS CloudFormation Stack. In this lab, we will launch an AWS CloudFormation template to create a two subnets initially. Later we update to four-subnet Amazon VPC that spans two Availability Zones.
Duration: 55 minutes
AWS Region: US East (N. Virginia) us-east-1
A VPC is similar to a computer network that we can create in an on-premises data center. In the same way, as we create dedicated and private networks within an organization, where computers in a network share network devices such as routers, switches, and so on, we can create a VPC when we create a new account in AWS.
VPC makes it possible to shape similar network infrastructure as we can shape it in our own data center. The difference is, it is a virtual environment within a public cloud wherein the virtual network is logically isolated from other similar networks within the public cloud.
Subnet: Subnet is short for the subnetwork. As we saw at the beginning of this chapter, a network is subdivided into multiple logical parts for controlling access to individual logical subparts of the network.
CloudFormation is a service provided by AWS for designing our own infrastructure using code i.e infrastructure as code.
Currently, CloudFormation supports two languages JSON and YAML. You can write your code with one of the languages.
CloudFormation comes with great features being able to update your infrastructure whenever you want and also have the ability to delete the stack in case you don’t need it.
A fascinating feature of cloud formation is that it saves more time in building infrastructure and helps in focusing on development.
It is also possible to replicate our infrastructure in a short amount of time.
It eliminates human error and works according to the code you have written. It consists of two main components, Stack and Templates.
It consists of various sections like
AWS Template Format Version
Resources (Required Field)
It is not mandatory that the template requires all the above-mentioned sections. By using only the Resources section, we will be able to create a template.
The resources section plays an important role in the template creation.
For example, to create an EC2 instance, a template shall consist of various parameters such as key name, image id, instance type.
It is also possible to create two resources in the same template and refer to one from another i.e. attaching an elastic IP with an EC2 instance.
A stack consists of a collection of resources.
In other words, the stack consists of one or more templates.
The advantage of the stack is that it is easy to create, delete or update the collection of resources.
The advanced stacks have a nested stack which holds a collection of stacks.
Log into the AWS Management Console.
Create Subnets using the VPC_Template cloud formation stack
Create Subnets using the VPC_II_Template cloud formation stack
Deep dive into the VPC_Template and VPC_II_Template
Validation of the lab.