DEV Community

Muhammad Awais
Muhammad Awais

Posted on

Building a Secure AWS Infrastructure

Building a Secure AWS Infrastructure with Two VPCs, EC2, IAM, and S3

Introduction

Cloud computing is an essential part of modern application development. In this project, I worked on an AWS infrastructure using two VPCs, public and private subnets, an EC2 instance, IAM-based authentication, and Amazon S3 for data storage.

The goal was to understand how AWS networking, computing, authentication, and storage services work together.

Architecture Overview

The infrastructure consists of two VPCs with separate subnet configurations and AWS services for application processing and data storage.

The main services used in this project are:

  • Amazon VPC: Provides isolated virtual networks.
  • Public and Private Subnets:** Organize network resources based on access requirements.
  • Amazon EC2: Runs the application server.
  • AWS IAM: Manages access permissions and authentication.
  • Amazon S3:Stores application data.
  1. Configuring Two VPCs

I created two Virtual Private Clouds (VPCs) to organize resources into separate virtual networks. Each VPC has its own IP address range and subnet configuration.

This helped me understand network isolation and the organization of cloud resources.

  1. Creating Public and Private Subnets

I used public and private subnets to separate resources according to their connectivity requirements.

  • Public Subnet:Supports resources requiring controlled internet access, with appropriate routing and security configurations.
  • Private Subnet: Provides a network environment for resources that should not be directly accessible from the public internet.

This separation improves network organization and helps apply security controls.

  1. Deploying an EC2 Instance

Amazon EC2 provided the computing environment for the application server.

The instance was responsible for processing requests and interacting with AWS storage services. Its connectivity depended on the subnet configuration, routing, and security rules.

  1. Integrating Amazon S3

Amazon S3 was used for storing application data and files.

The application server can upload or retrieve objects from an S3 bucket when it has the appropriate permissions. This separates application processing from data storage.

  1. Implementing IAM-Based Authentication

AWS Identity and Access Management (IAM) controls which AWS resources an application can access.

For an EC2 application accessing S3, an attached IAM role is generally recommended because it provides temporary credentials without requiring long-term access keys to be stored on the server.

The permissions should follow the principle of least privilege, allowing only the required S3 operations.

  1. AWS Infrastructure Architecture Diagram

Figure 1: AWS infrastructure showing two VPCs, public and private subnets, EC2, IAM-based authentication, and Amazon S3 data storage.

  1. Understanding the Data Flow

The main application workflow is:

  1. A client sends a request to the EC2 application server.
  2. The application processes the request.
  3. EC2 uses its IAM role to obtain authorized access to S3.
  4. The application uploads data to or retrieves data from the S3 bucket.
  5. The application returns the appropriate response to the client.

If the two VPCs communicate privately, the required connectivity must be configured. VPC Peering is one option, requiring appropriate routes and security rules.

Amazon S3 is a regional AWS service rather than a resource inside a VPC subnet. An S3 VPC endpoint can provide private connectivity to S3 when configured appropriately.

  1. Challenges and Learning Outcomes

This project helped me understand:

  • VPC and subnet configuration.
  • Public and private network access.
  • EC2 instance deployment.
  • IAM roles and permissions.
  • S3 storage integration.
  • Network connectivity and cloud security.

It also improved my understanding of how individual AWS services can work together in a cloud infrastructure.

Conclusion

Building this AWS infrastructure was a valuable learning experience. I gained practical knowledge of cloud networking, compute services, identity and access management, and object storage.

This project strengthened my understanding of how to design cloud infrastructure while considering connectivity, access control, and data security.

AWS #CloudComputing #AmazonWebServices #DevOps #CloudSecurity

Top comments (0)