Mod 2 Notes
Mod 2 Notes
4. Upload a file to the vault: Upload a file to the vault using the ‘aws glacier upload-
archive’ command:
1. aws glacier upload-archive --vault-name my-glacier-vault --description "My
backup file" --client-request-token $(uuidgen) --body my-file.txt
This command will upload the file my-file.txt to the my-glacier-vault and return a job ID. You
can use the job ID to check the status of the upload and retrieve the file later.
VPC (Virtual Private Cloud) is a service provided by AWS that allows you to create a virtual
network within the AWS cloud. This virtual network provides you with complete control over
your network environment, including the ability to define your own IP address range, create
subnets, and control security settings.
Key Components of a VPC
1. CIDR Blocks: A CIDR (Classless Inter-Domain Routing) block is a contiguous range
of IP addresses that you assign to your VPC. This range defines the entire IP address
space available within your VPC.
2. Subnets: Subnets are divisions of your VPC that are used to group instances. You can
create public subnets that have internet connectivity and private subnets that are isolated
from the public internet.
3. Elastic Network Interfaces (ENIs): ENIs are virtual network interfaces that are
attached to your instances. They provide the instances with connectivity to the VPC and
the internet.
4. Internet Gateways: Internet Gateways are used to provide your VPC with internet
connectivity. You can attach an internet gateway to a public subnet to enable instances
in that subnet to communicate with the internet.
5. Route Tables: Route tables are used to determine how network traffic is routed within
your VPC. Each subnet is associated with a route table, which contains rules that specify
where network traffic should be sent.
Example Scenario
Imagine you want to create a web application with a public-facing frontend and a private
backend database. You could create a VPC with two subnets:
• Public subnet: This subnet would be associated with an internet gateway and would
contain instances that run your web application.
• Private subnet: This subnet would not be associated with an internet gateway and
would contain instances that run your database.
You could then create a route table for the public subnet that includes a route to the internet
gateway, and a route table for the private subnet that includes a route to a NAT gateway (a
special type of instance that allows instances in a private subnet to access the internet). This
configuration would ensure that your web application can be accessed from the public internet,
while your database remains private.
Security Groups and Network Access Control Lists (NACLs)
Security groups and network access control lists (NACLs) are both used to control network
traffic in AWS VPCs, but they have different scopes and functionalities.
Security Groups
• Scope: Apply to individual EC2 instances and other resources within a VPC.
• Functionality: Control inbound and outbound traffic based on source and destination
IP addresses, ports, and protocols.
• Rules: Rules are stateful, meaning they track the state of connections and allow return
traffic from authorized sources.
• Priority: Rules are evaluated in order of priority, with higher-priority rules taking
precedence.
Example use case: Allow SSH traffic (port 22) from a specific IP address range to an EC2
instance.
Network Access Control Lists (NACLs)
• Scope: Apply to subnets within a VPC.
• Functionality: Control inbound and outbound traffic based on source and destination
IP addresses, ports, and protocols.
• Rules: Rules are stateless, meaning they do not track the state of connections.
• Priority: Rules are evaluated in order of priority, with higher-priority rules taking
precedence.
• Default rules: NACLs include default rules that allow all traffic from within the VPC
and deny all traffic from outside the VPC.
Example use case: Deny all traffic to a subnet except for a specific set of IP addresses.
Key differences:
• Scope: Security groups apply to individual resources, while NACLs apply to subnets.
• Statefulness: Security groups are stateful, while NACLs are stateless.
• Default rules: NACLs have default rules that allow or deny all traffic, while security
groups do not.
Best approach:
• Use both security groups and NACLs to create a layered security model.
• Apply security groups to individual resources to control access to specific applications
or services.
• Apply NACLs to subnets to control traffic at the subnet level.
• Use a combination of security groups and NACLs to create a firewall that is both
granular and effective.
• By understanding the differences between security groups and NACLs, you can
effectively control network traffic in your AWS VPCs and protect your resources from
unauthorized access.
Public IP Addresses, Elastic IP Addresses, NAT, and VPC Peering
Public IP Addresses
A public IP address is an IP address that is accessible from the internet. It allows you to
connect to resources within your AWS account from outside the AWS network. When you
launch an EC2 instance, it is assigned a public IP address by default.
Elastic IP Addresses
An Elastic IP address is a static IP address that you can associate with an EC2 instance or
network interface. This allows you to maintain a consistent public IP address for your
resources, even if the underlying EC2 instance changes.
Benefits of using Elastic IP addresses:
• Consistent public IP: Maintain a fixed IP address for your applications.
• DNS management: Use the Elastic IP address with your DNS records.
• Load balancing: Distribute traffic across multiple EC2 instances using a load balancer.
Network Address Translation (NAT)
NAT is a technique used to translate private IP addresses to public IP addresses. This allows
you to protect your internal network from direct internet access.
Benefits of using NAT:
• Security: Protect your internal network from unauthorized access.
• Cost savings: Reduce the number of public IP addresses required.
• Flexibility: Easily manage your network topology.
VPC Peering
VPC peering allows you to connect two VPCs within the same AWS region. This enables you
to securely communicate between resources in different VPCs, without exposing them to the
public internet.
Benefits of using VPC peering:
• Connectivity: Establish secure connections between VPCs.
• Isolation: Maintain isolation between different environments.
• Cost savings: Reduce the need for VPN connections.
Basically:
• Public IP addresses are used to access resources from the internet.
• Elastic IP addresses provide a consistent public IP for your resources.
• NAT translates private IP addresses to public IP addresses for security and cost savings.
• VPC peering allows you to connect VPCs securely and privately.