AWS S3 Bucket

aws s3

Amazon Simple Storage Service (S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.

S3 Bucket allows to scale your resources up and down to meet fluctuating demands. It is designed for 99.99999999999% (11 9’s) of data durability. Thus, the data are sotred as object aross multiple systems making it available when needed.

Creating a S3 Bucket with AWS console

To create a S3 bucket, we need to assign a globally-unique name. We also need to assign role and policy of Aamzon S3 Full Acesss to the user before creating S3 Bucket. This AWS managed policy AamazonS3FullAccess policy will allow the EC2 to access S3 Resources.

s3 bucket

We can launch a new EC2 instance by the desired Linux Os, storage, security groups, and tags.

Settting the permission on Key Pair

After creating a new EC2 instance, we can download the key pair. The key pair file has an extension of .pem. We need to locate the path to key pair and set the permission with chmod command.

chmod 400 <key pair>

However, in my experience I simply used the key pair to get access to AWS EC2 instance without any error.

Accessing the AWS EC2 instance using CLI

After launching the new EC2 isntance we can use SSH to gain access to the specific EC2 Instance. We should determine the path to key pair and locate the Ipv4 Address of the newly created EC2 instance.

We also need to verify the ingress and outgress traffic rules on the security group. Here, we will use ssh to gain access to the EC2 Instance.

sudo ssh -i <path to key pair> ec2-user@<ipv4 address of EC2 instance>

While doing ssh to the EC2 instance we need to identify the distribution of Linux OS. For example:

ubuntu: ubuntu@ Amazon Linux 2: ec2-user@ Debian: admin@ Centos: centos@

We need to make sure to allow inbound rule for SSH traffic from your desired IP address to your instance.

Installing AWS CLI

After gaining access to your EC2 Instance, we can install AWS CLI.

apt-get install awscli

Now based on the given policy and role, we can perform several aws commands on this EC2 instance.

Creating AWS S3 Bucket

Here, the following command will create a new S3 Bucket on us-west-1 region.

aws s3 mb s3://bucketLimbu --region us-west-1

Different commands to operate on S3 Bucket

  • cp - Copy files to S3 bucket
aws s3 cp test.txt s3://bucketLimbu/test.txt
  • ls- List all the S3 buckets
aws s3 ls