Introduction to AWS and Python
ENGR MUHAMMAD KHALID
Software Engineer |Testing | Architecture | Automation | Python | Scripting | Artificial Intelligence| DevOps | Containerization | CI/CD | Quality Assurance (QA) | Cybersecurity |Database | MongoDb |
Overview of AWS Services
Amazon Web Services (AWS) is a comprehensive cloud computing platform that offers a wide array of services such as computing power, storage options, and networking capabilities. AWS services are categorized into various domains including Compute, Storage, Database, Networking, and Machine Learning.
Introduction to Boto3
Boto3 is the AWS Software Development Kit (SDK) for Python. It allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2. Boto3 provides an easy-to-use interface to interact with AWS services programmatically.
Setting Up AWS Credentials
Before you start using Boto3, you need to set up your AWS credentials. This can be done by creating an AWS Identity and Access Management (IAM) user with the necessary permissions and configuring the AWS CLI.
aws configure
AWS Access Key ID [None]: YOUR_ACCESS_KEY
AWS Secret Access Key [None]: YOUR_SECRET_KEY
Default region name [None]: us-west-2
Default output format [None]: json
Example: Listing S3 Buckets
import boto3
# Create a Boto3 session
session = boto3.Session(
aws_access_key_id='YOUR_ACCESS_KEY',
aws_secret_access_key='YOUR_SECRET_KEY',
region_name='us-west-2'
)
# Use the session to create an S3 client
s3 = session.client('s3')
# List all S3 buckets
response = s3.list_buckets()
for bucket in response['Buckets']:
print(bucket['Name'])
This script creates a session with your AWS credentials and lists all the S3 buckets in your account.
Subscribe this AWS tutorial News letter for more updates.