The VPC network itself is region scoped
VPC is used for almost everything that has a scope of AZ (Availabilty Zones)
First thing to setup is the CIDR address.
10.0.0.0/16
to it, any other CIDR ranges that you apply also need to start with 10. You cannot apply a 172.16.0.0
or a 192.168.0.0
A contiguous range of addresses within a VPC
They are AZ scoped and usually much smaller than the VPC size. However, they have the ability to be scoped at the local zone layer, which makes it possible to target data centers that are geographically closer to you.
Each subnet can be associated with a Route Table and a network ACL (Access Control List).
Since subnets are technically identical other than the CIDR range, we can differentiate their purpose by their accessibility.
A public subnet has a route table attached that has bi-directional access to the internet through IGWs.
A private subnet has outbound access but no direct inbound access, usually controlled by a NAT gateway.
Create a default VPC only
option.
Give IPv4 CIDR.
Enable DNS hostnames.
Create VPC
Now create subnets.
To optimize for reduced latency, cost optimization and simplified networking, locate subnets in the same AZ
Reduced Latency: Keeping subnets within the same Availability Zone minimizes the network latency between resources within the subnets. This can be beneficial for applications that require low-latency communication between components, such as a database server and an application server.
Simplified Networking: Placing subnets in the same Availability Zone simplifies network configuration and management. You don't have to deal with cross-Availability Zone routing or worry about configuring and maintaining VPC peering or VPN connections between subnets in different Availability Zones.
Cost Optimization: AWS does not charge for data transfer between resources within the same Availability Zone.
Apply names and CIDR range.
Example,
public - 10.100.1.0/24
private - 10.100.2.0/24
database - 10.100.3.0/24
Associated with one or more subnets to sepcify a network that is not the local subnet to provide a gateway.
Basic approach is to attach one route table per subnet instead of route table for all, to avoid confusing route table.
Attach to a VPC to provide public internet access to the AWS services.
You still require a route table entry in the public subnet.
Allowing outbound resource for private gateways.
It is AZ scoped resource and is deployed into the subnet.
One NAT Gatewayper AZ is recommended for higher resilience.
edit routes
0.0.0.0/0
with a target to igwedit subnet associations
on explicit subnetTip: Go to the public subnet and
edit subnet settings
, enable auto assign public IPv4. Then any resource that is created in this subnet will automatically be given a dynamic public IP.
NAT gateway is a resource that costs.
subnet
beacuse that's the one that has access to and from the internetAssociate with subnets along with the route table as a stateless firewall.
- It acts as a stateless firewall, which means you have to create rulse in both directions
- The rules are evaluated in specific order
Similar to route tables, it's better to attach one per subnet but for organization purposes, it is common to see combined NACL.
Rather than being associated with a subnet, it is associated with a network interface as a stateful firewall.
Security groups only require single rule in the direction of traffic and the return traffic is automatically allowed.
The default is to deny all inbound traffic, so with a brand-new security group, no inboud traffic is allowed.
Create one secruity group per application per tier.
Scenario: We would like to assume that we are going to deny all inbound traffic from the public subnet.
Type: All traffic
Source
as your public IP address, eg. 10.100.1.0/24
and select deny10.100.0.0/16
10.100.0.0/16
This implies that the public subnet will have the above restrictions applied
Scenario: We would like to deploy a load balancer into our public subnet that allows all inbound traffic on ports 80 and 443 from the entire world.
1. Type: HTTP
Source: IPv4, 0.0.0.0/0
2. Type: HTTPS
Source:IPv4, 0.0.0.0/0
Same-region resources only that's attached to the VPC for S3 and DynamoDB access
Gateway endpoints require a route table entry to be created in any subnet that you want to use this Gateway endpoint from.
FREE !! for S3 and DynamoDB
Associate with one subnet, one security group, one AWS service
NOT FREE
It acts as a direct proxy to the AWS service.
Use to connect to private endpoints in VPCs in other accounts.
Also used with a service called Private Link where you can expose endpoints that are in other VPCs, behind a network load balancer.
Senario 1. Push all S3 traffic from our VPC private subnet directly to the service, so that we are not utilizing the NAT Gateway and incurring the NAT Gateway throughput charges.
S3
in Services, Type: Gatewayresource based policies
Senario 2. Interface Endpoint that blocks all public access but allow access to CloudWatch for monitoring
monitoring
in ServicesThis summary is made possible by Oreilly's AWS, 3rd Edition - Chad Smith.
If the above post violates any copyright permissions, please let me know!