Hello everyone. So this article is all about the summarization of AMAZON S3 and I am going to show you about the basic operations like create bucket , upload object, copy object with AWS python SDK.

Introduction - What is AMAZON S3?

Amazon S3 is a web service provide by AWS(Amazon Web Service). It is an cloud object storage which allow user to store , retrieve , analyze the data anytime with any amount from anywhere.

Amazon S3 Benefit - Why we should use S3?

  1. Durability , Reliability & Scalability : Amazon S3 promise of 99.99% of durability because the data is distributed across a minimum of three physical facilities and we can store any amount of data on S3.
  2. Query in Place : We can analyze the data in place. No need to move data into another separate analytic system.
  3. Security : It's prevent DDoS Attack and we also can add an additional security layer to our data and more than that it has IAM which we can define individual user account with permission across AWS service. We also can monitoring and logging to see the API call who , where , whom is calling with the help of AWS CloudTrail.
  4. Flexible Management : Since objects can tagged with customizable metadata so we can see and control the storage consumption , cost for each workload.
  5. Easy Flexible Data Transfer : We can choose the widest range of options to transfer our data into or out of Amazon S3 and with S3 API, it is really easy to transfer data over the internet/
  6. Most Supported Platform : Beside AWS service there are more than 3500 software which we can integrate with Amazon S3.

Getting Start

First of all , we have to know all the basics thing within S3.
1. Bucket : Bucket is a container for objects store in Amazon S3.
2. Object : everything that we upload into S3 we consider it as object. It can be a text file , image ,video.
3. Key : Key is a unique identifier for an object within a bucket.Every objects in bucket must has exactly one key. It is use to identify the object.
4. IAM : With IAM(AWS Identify and Access Management)we can securely control access to AWS services and resources for our users. We can create and manage AWS users and groups and set permissions to allow and deny access to AWS resources.

Making Requests Using IAM User Credential - AWS SDK for python

AWS support many programming languages such as JAVA , dotNet , PHP , Ruby , Python ...etc but for this time we are going to use AWS SDK for python which is boto.

What is boto?

Boto is AWS SDK for python which allow python developer to write software that make use of Amazon service like S3 or EC2.

Let's start!

1. Installation

We are going to use boto3 with python 3.5

pip install boto3

2. Configuration

Before we can use boto3 we have to set up authentication credentials. We can find credentials for our AWS account in IAM console.

  • Then install AWS CLI by typing:
pip install awscli
  • Ok, so now we can configure the file by typing:
aws configure
  • Then input your information
aws access key id [None]: input your access key.
aws secret access key [None]: input your secret key.
default region name [None]: input your region.
output [ None]: you can type the output you need or just press the enter key.

3. Using boto3

To use boto3, first we have to import it and tell what service we are going to use.

import boto3
#telling boto3 that we are going to use amazon s3
s3 = boto3.resource('3')
  • Creating Bucket
import boto3
s3= boto3.resource('s3')
s3.create_bucket(Bucket='putyourbucketname',CreateBucketConfiguration={'LocationConstraint':'input your region'})
  • List all buckets in S3
import boto3
s3= boto3.resource('s3')
for bucket in s3.buckets.all():
   print(bucket.name)
  • Upload object to S3
import boto3
s3= boto3.resource('s3')
Bucket= s3.Bucket('bucketname')
Bucket.upload_file(file,key,ExtraArgs={'ACL':'public-read'}
  • Download object from S3
import boto3
s3= boto3.resource('s3')
s3.Bucket("bucketname").download_file("filenameins3","filenameyouwanttosaveinlocal")
  • Copy object in S3
import boto3
s3= boto3.resource('s3')
source={
'Bucket':'bucketname',
'Key':'key'}
s3.meta.client.copy(source,'otherbucket','otherkey')

Disadvantages of Amazon S3

Ok, so now let's talk about the drawback or disadvantages of Amazon S3. In my opinion I think the drawback of Amazon S3 are its capability and cost.

S3 Capability

You may wonder "What do you mean by capability"? Ok so like you all know , S3 is an object storage which we use to store object file such as image , video ,text file which has public URL so we can manipulate it to host a static site if we want to host dynamic site it is not possible.

Cost

If your static site is big , popular or has lots of traffics and your contents contain lots of big file like videos.The cost is going to be high. Here is how the cost is calculate on s3.
http://www.hostingadvice.com/how-to/aws-s3-pricing/.

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.