Essential AWS Services: A Complete Guide
Discover the essential AWS services, from infrastructure to data management.
I
InSkillCoach
· min
Essential AWS Services: A Complete Guide
Discover the most important AWS services and their common use cases.
1. Compute Services
Amazon EC2 (Elastic Compute Cloud)
# Example of creating an EC2 instance with boto3
import boto3
def create_ec2_instance():
ec2 = boto3.client('ec2')
response = ec2.run_instances(
ImageId='ami-0c55b159cbfafe1f0', # Amazon Linux 2 AMI
InstanceType='t2.micro',
MinCount=1,
MaxCount=1,
KeyName='ma-clé',
SecurityGroupIds=['sg-xxxxxxxx'],
TagSpecifications=[
{
'ResourceType': 'instance',
'Tags': [
{'Key': 'Name', 'Value': 'mon-instance'},
{'Key': 'Environnement', 'Value': 'Production'}
]
}
]
)
return response['Instances'][0]['InstanceId']
AWS Lambda
# Example of a Lambda function
import json
def lambda_handler(event, context):
try:
# Data processing
body = json.loads(event['body'])
result = process_data(body)
return {
'statusCode': 200,
'body': json.dumps({
'message': 'Succès',
'result': result
})
}
except Exception as e:
return {
'statusCode': 500,
'body': json.dumps({
'message': 'Erreur',
'error': str(e)
})
}
2. Storage Services
Amazon S3 (Simple Storage Service)
# Example of using S3
import boto3
def upload_to_s3(file_path, bucket_name, object_name):
s3 = boto3.client('s3')
try:
s3.upload_file(file_path, bucket_name, object_name)
return True
except Exception as e:
print(f"Erreur lors de l'upload: {e}")
return False
def download_from_s3(bucket_name, object_name, file_path):
s3 = boto3.client('s3')
try:
s3.download_file(bucket_name, object_name, file_path)
return True
except Exception as e:
print(f"Erreur lors du téléchargement: {e}")
return False
Amazon EBS (Elastic Block Store)
# Example of managing EBS volumes
import boto3
def create_ebs_volume(availability_zone, size_gb):
ec2 = boto3.client('ec2')
response = ec2.create_volume(
AvailabilityZone=availability_zone,
Size=size_gb,
VolumeType='gp3',
TagSpecifications=[
{
'ResourceType': 'volume',
'Tags': [
{'Key': 'Name', 'Value': 'mon-volume'},
{'Key': 'Type', 'Value': 'Données'}
]
}
]
)
return response['VolumeId']
3. Database Services
Amazon RDS (Relational Database Service)
# Example of connecting to RDS
import mysql.connector
def connect_to_rds():
try:
connection = mysql.connector.connect(
host='mon-instance.xxxxx.region.rds.amazonaws.com',
user='admin',
password='mon-mot-de-passe',
database='ma_base'
)
return connection
except Exception as e:
print(f"Erreur de connexion: {e}")
return None
Amazon DynamoDB
# Example of using DynamoDB
import boto3
def create_dynamodb_item(table_name, item):
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(table_name)
try:
response = table.put_item(Item=item)
return response
except Exception as e:
print(f"Erreur lors de la création: {e}")
return None
4. Networking Services
Amazon VPC (Virtual Private Cloud)
# Example of creating a VPC
import boto3
def create_vpc():
ec2 = boto3.client('ec2')
# VPC creation
vpc_response = ec2.create_vpc(
CidrBlock='10.0.0.0/16',
TagSpecifications=[
{
'ResourceType': 'vpc',
'Tags': [
{'Key': 'Name', 'Value': 'mon-vpc'},
{'Key': 'Environnement', 'Value': 'Production'}
]
}
]
)
# Creating a public subnet
subnet_response = ec2.create_subnet(
VpcId=vpc_response['Vpc']['VpcId'],
CidrBlock='10.0.1.0/24',
AvailabilityZone='eu-west-3a'
)
return {
'vpc_id': vpc_response['Vpc']['VpcId'],
'subnet_id': subnet_response['Subnet']['SubnetId']
}
Amazon Route 53
# Example of DNS management with Route 53
import boto3
def create_dns_record(zone_id, domain_name, record_type, value):
route53 = boto3.client('route53')
response = route53.change_resource_record_sets(
HostedZoneId=zone_id,
ChangeBatch={
'Changes': [
{
'Action': 'CREATE',
'ResourceRecordSet': {
'Name': domain_name,
'Type': record_type,
'TTL': 300,
'ResourceRecords': [
{'Value': value}
]
}
}
]
}
)
return response['ChangeInfo']['Id']
5. Security Services
AWS IAM (Identity and Access Management)
# Example of creating an IAM user
import boto3
def create_iam_user(username):
iam = boto3.client('iam')
try:
# User creation
user_response = iam.create_user(UserName=username)
# Attaching a policy
iam.attach_user_policy(
UserName=username,
PolicyArn='arn:aws:iam::aws:policy/PowerUserAccess'
)
return user_response['User']['UserName']
except Exception as e:
print(f"Erreur lors de la création: {e}")
return None
AWS KMS (Key Management Service)
# Example of using KMS
import boto3
def encrypt_data(key_id, data):
kms = boto3.client('kms')
try:
response = kms.encrypt(
KeyId=key_id,
Plaintext=data.encode('utf-8')
)
return response['CiphertextBlob']
except Exception as e:
print(f"Erreur de chiffrement: {e}")
return None
Conclusion
Key takeaways:
- Choose the right services based on your needs
- Optimize costs
- Build in security from the start
- Follow AWS best practices
- Monitor performance
Essential services:
- EC2 for compute
- S3 for storage
- RDS for relational databases
- DynamoDB for NoSQL databases
- VPC for networking
- IAM for security
About InSkillCoach
Training and technology expert
Coach specializing in advanced technologies and AI, backed by GNeurone Inc.
Certifications:
- AWS Certified Solutions Architect – Professional
- Google Cloud certifications
- Microsoft Certified: DevOps Engineer Expert
- Certified Kubernetes Administrator (CKA)
- CompTIA Security+
640
208
Comments
Comments are powered by GitHub Discussions
Sign in with GitHub to join the discussion