Accessing s3 bucket form Private Ec2 Instance

Project summary: In this step-by-step guide, we'll walk you through the process of creating a Virtual Private Cloud (VPC) on Amazon Web Services (AWS), configuring public and private subnets, and setting up a VPC endpoint to securely connect an EC2 instance from the private subnet to an S3 bucket.

Services being used: AWS EC2, VPC, VPC Endpoint and s3 bucket

Process flow:

  1. Creation of VPC

  2. Creation of Internet gateway and attaching to VPC

  3. Subnets creation (public and private subnet )

  4. NAT gateway creation

  5. Route table creation (public and private)

  6. Public route table associating with public subnet and should attach to internet gateway

  7. Private route table associating with private subnet and should attach to NAT gateway

  8. Deploying ec2 instances in public and private Make sure your private ec2 key should be in public ec2 instance

    1. chmod 400 <keypair name>

    2. ssh -i /path/to/private_key.pem ec2-user@private_ip_address

  9. Installing aws cli on private instance and configuring aws credentials

  10. Removing NAT gateway from private route-table

  11. Creation s3 bucket

  12. Creation of VPC endpoint associating with private route table

  13. Accessing s3 bucket from a private ec2 instance