You are on page 1of 5

AWS - AMAZON WEB SERVICES

TOPICS COVERED:

1. Amazon Account Creation


2. EC2 instance
3. S3 bucket
4. LAMBDA
5. DynamoDB
6. CloudWatch
7. Boto3
8. JSON
9. Python(File handling,upload file using boto3 in S3 bucket)

AMAZON ACCOUNT CREATION:

● Open the Amazon Web Services (AWS) home page


● Choose Create an AWS Account
● Enter your account information, and then choose Continue
● Choose Personal or Professional
● Enter your company or personal information
● Read and accept the AWS Customer Agreement
● Choose Create Account and Continue.

EC2 Instance:

● EC2 stands for Elastic Compute Cloud.


● EC2 allows users to use virtual machines of different configurations as per their
requirement.
● It allows various configuration options, mapping of individual server, various
pricing options, etc.

S3 Bucket:

● It is Simple Storage Service


● It is a scalable, high-speed, low-cost web-based service designed for
online backup and archiving of data and application programs.
● It allows you to upload, store, and download any type of files up to 5 TB in
size.
● This service allows the subscribers to access the same systems that
Amazon uses to run its own web sites.

S3 CONFIGURATION:

● Open AWS MANAGEMENT CONSOLE


● Click S3
● Click on CREATE BUCKET
● Give BUCKET NAME(bucket should not be repeated again)
● Give REGION
● Click on CREATE BUCKET

Bucket will be created.

LAMBDA

● AWS Lambda is a serverless compute service that runs your code in


response to events and automatically manages the underlying compute
resources.
● It automatically manages the compute resources across multiple
availability zones and scales them when new actions are triggered.

TO CREATE LAMBDA FUNCTION:

● Select Lambda from AWS services section.


● Select CREATE FUNCTION.
● Select Author From Scratch or Use a BluePrint or Container Image or
Browse Serverless app repository.
● Give FUNCTION NAME.
● Select RUNTIME.
● Select CREATE FUNCTION.

TRIGGER S3 USING LAMBDA:

● Select ADD TRIGGER inside the lambda function.


● Select S3 in Trigger configuration.
● Select the Specified BUCKET which needs to be triggered.

CLOUDWATCH:

● Amazon CloudWatch is a monitoring service for Amazon Web Services


cloud resources and the applications you run on Amazon Web Services.
● Amazon CloudWatch is a monitoring service for Amazon Web Services
cloud resources and the applications you run on Amazon Web Services.

JSON:

● JSON stands for JavaScript Object Notation.


● JSON is a text format for storing and transporting data.
● JSON is "self-describing" and easy to understand.

Example: '{"name":"John", "age":30, "car":null}'

BOTO3:

● The AWS SDK for Python provides a pair of methods to upload a file to an S3
bucket.
● The upload_file method accepts a file name, a bucket name, and an object
name. The method handles large files by splitting them into smaller chunks and
uploading each chunk in parallel.

Example: s3 = boto3.client('s3')
with open("FILE_NAME", "rb") as f:
s3.upload_fileobj(f, "BUCKET_NAME", "OBJECT_NAME")

FILE HANDLING:
● Python has several functions for creating, reading, updating, and deleting files.
● The open() function takes two parameters; filename, and mode.

SYNTAX:

"r" - Read - Default value. Opens a file for reading, error if the file does not exist
Eg:
file = open(“filename.txt”)
file = open(“filename.txt”, “r”)
print(file.read())

"a" - Append - Opens a file for appending, creates the file if it does not exist
Eg:
file = open(“filename.txt”, “a”)
file.write(“HELLO”)
File.close

"w" - Write - Opens a file for writing, creates the file if it does not exist
Eg:
file = open(“filename.txt”, “w”)
file.write(“HELLO”)
File.close

Delete a file:
To delete a file, you must import the OS module, and run its os.remove() function

Eg:
import os
os.remove("filename.txt")

Check if file exists:


Eg:
import os
if os.path.exists("filename.txt"):
os.remove("filename.txt")
else:
print("The file does not exist")

UPLOAD FILE IN S3 BUCKET USING PYTHON:


❖ Configure AWS Access Key ID,Access Secret Key and Region.
❖ Install boto3(Pip install boto3)

Eg:

Import boto3
s3 = boto3.client('s3')
s3.upload_file(“Filename.txt”, “Bucketname”, “bucket file name”)

You might also like