Difference between revisions of "Create New VPC Environment in AWS"

From Gejoreuy
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
This VPC make all instances must use public ip (elastic ip) to get access to internet and to be able to be accessed from internet.
 
This VPC make all instances must use public ip (elastic ip) to get access to internet and to be able to be accessed from internet.
  
[[File:20191005 aws vpc with single public subnet.jpg]]
+
[[File:20191113_aws_vpc_with_single_public_subnet.jpg]]
  
 
'''Step by step :'''
 
'''Step by step :'''
  
 
# Create VPC with CIDR (ex : 172.31.0.0/16)
 
# Create VPC with CIDR (ex : 172.31.0.0/16)
# Create subnet (ex : 172.31.156.0/24)
+
# Create subnet (ex : 172.31.1.0/24)
 
# Create internet gateway (attach to the VPC)
 
# Create internet gateway (attach to the VPC)
 
# Edit route tables (which already attached to the VPC automatically)
 
# Edit route tables (which already attached to the VPC automatically)
Line 22: Line 22:
 
'''Note :''' In this VPC, we don't need to create new route tables. Just need to edit.
 
'''Note :''' In this VPC, we don't need to create new route tables. Just need to edit.
  
== Create AWS VPC with Public & Private Subnet (with NAT) ==
+
== Create AWS VPC with Public & Private Subnet (with NAT Gateway) ==
  
 
This VPC must be created with two subnets.  
 
This VPC must be created with two subnets.  
Line 28: Line 28:
 
<br>The second one as private subnet, where all instance only use private ip. They can access internet through a NAT gateway. But they can not be accessed directy from internet.
 
<br>The second one as private subnet, where all instance only use private ip. They can access internet through a NAT gateway. But they can not be accessed directy from internet.
  
[[File:20191005_aws_vpc_with_nat.jpg]]
+
[[File:20191113_aws_vpc_with_nat.jpg]]
 +
 
  
 
'''Step by step :'''
 
'''Step by step :'''
  
 
# Create VPC with cidr (ex : 172.31.0.0/16)
 
# Create VPC with cidr (ex : 172.31.0.0/16)
# Create subnet 1 (ex : 172.31.156.0/24)
+
# Create subnet 1 (ex : 172.31.1.0/24)
# Create subnet 2 (ex : 172.31.157.0/24)
+
# Create subnet 2 (ex : 172.31.2.0/24)
 
# Create internet gateway (attach to the VPC)
 
# Create internet gateway (attach to the VPC)
# Create nat gateway (with public ip, attach to the VPC)
+
# Create nat gateway (with public ip, and with private ip in public subnet, attach to the VPC)
 
# Create route tables 1  (attach to the vpc)
 
# Create route tables 1  (attach to the vpc)
 
#: Route  
 
#: Route  
Line 42: Line 43:
 
#:: Destination : 0.0.0.0/0 ; target : internet gateway
 
#:: Destination : 0.0.0.0/0 ; target : internet gateway
 
#: Subnet Association
 
#: Subnet Association
#:: 172.31.156.0/24
+
#:: 172.31.1.0/24
 
# Create route tables 2 (attach to the VPC)
 
# Create route tables 2 (attach to the VPC)
 
#: Route  
 
#: Route  
Line 48: Line 49:
 
#:: Destination : 0.0.0.0/0 ; target : nat gateway
 
#:: Destination : 0.0.0.0/0 ; target : nat gateway
 
#: Subnet association
 
#: Subnet association
#:: 172.31.157.0/24
+
#:: 172.31.2.0/24
  
 
'''Note :''' In this VPC, just keep the existing route table and then we need to create new two route tables.
 
'''Note :''' In this VPC, just keep the existing route table and then we need to create new two route tables.

Latest revision as of 15:55, 13 November 2019

Purpose

Amazon Virtual Private Cloud (Amazon VPC) enables us to launch AWS resources into a virtual network that we've defined.
This virtual network closely resembles a traditional network that we'd operate in our own data center, with the benefits of using the scalable infrastructure of AWS.

Create AWS VPC with Public Subnet Only (Single Public Subnet)

This VPC make all instances must use public ip (elastic ip) to get access to internet and to be able to be accessed from internet.

20191113 aws vpc with single public subnet.jpg

Step by step :

  1. Create VPC with CIDR (ex : 172.31.0.0/16)
  2. Create subnet (ex : 172.31.1.0/24)
  3. Create internet gateway (attach to the VPC)
  4. Edit route tables (which already attached to the VPC automatically)
    Route
    Destination : 172.31.0.0/16 ; target : local
    Destination : 0.0.0.0/0 ; target : internet gateway

Note : In this VPC, we don't need to create new route tables. Just need to edit.

Create AWS VPC with Public & Private Subnet (with NAT Gateway)

This VPC must be created with two subnets.
One as public subnet, where all instances in this subnet must use public ip (elastic ip) to get access to internet and to be able to accessed from internet.
The second one as private subnet, where all instance only use private ip. They can access internet through a NAT gateway. But they can not be accessed directy from internet.

File:20191113 aws vpc with nat.jpg


Step by step :

  1. Create VPC with cidr (ex : 172.31.0.0/16)
  2. Create subnet 1 (ex : 172.31.1.0/24)
  3. Create subnet 2 (ex : 172.31.2.0/24)
  4. Create internet gateway (attach to the VPC)
  5. Create nat gateway (with public ip, and with private ip in public subnet, attach to the VPC)
  6. Create route tables 1 (attach to the vpc)
    Route
    Destination : 172.31.0.0/16 ; target : local
    Destination : 0.0.0.0/0 ; target : internet gateway
    Subnet Association
    172.31.1.0/24
  7. Create route tables 2 (attach to the VPC)
    Route
    Destination : 172.31.0.0/16 ; target : local
    Destination : 0.0.0.0/0 ; target : nat gateway
    Subnet association
    172.31.2.0/24

Note : In this VPC, just keep the existing route table and then we need to create new two route tables.