Amazon Web Services (AWS)
Core AWS services and how they work together for scalable applications
Core Services Overview
AWS provides a wide range of cloud services that can be combined to create powerful, scalable applications. Here are the key services and how they can work together:
S3 (Simple Storage Service)
Object storage service that can store and retrieve any amount of data:
- Files are stored in "buckets" with unique global names
- Highly durable and available storage
- Can trigger events when files are added/modified
- Supports static website hosting
Common Use Cases:
- Static asset storage (images, videos, documents)
- Backup and archive storage
- Data lake for analytics
- Static website hosting
# Example S3 bucket policy for public read access
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::your-bucket-name/*"]
}
]
}
Lambda Functions
Serverless compute service that runs code in response to events:
- Supports multiple programming languages
- Pay only for compute time used
- Automatic scaling
- Integrates with other AWS services
Example Lambda Function (Node.js):
exports.handler = async (event) => {
// Example: Process an image uploaded to S3
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
// Process the image...
// Send notification using SNS
const message = `Processed image: ${key}`;
await sns.publish({
TopicArn: 'your-sns-topic-arn',
Message: message
}).promise();
return {
statusCode: 200,
body: JSON.stringify('Image processed successfully')
};
};
SNS (Simple Notification Service)
Fully managed pub/sub messaging service:
- Send messages to multiple subscribers
- Support for multiple protocols (HTTP, email, SMS, etc.)
- Fan-out architecture
- Integrates with many AWS services
EC2 (Elastic Compute Cloud)
Virtual servers in the cloud:
- Choose from various instance types optimized for different use cases
- Pay-as-you-go pricing
- Scalable compute capacity
- Complete control over virtual machines
Instance Types Overview:
- t2/t3: General purpose, burstable
- c5/c6: Compute optimized
- r5/r6: Memory optimized
- p3/p4: GPU instances
Creating Workflow Chains
AWS services can be connected to create automated workflows. Here's an example:
Example Workflow:
- User uploads file to S3 bucket
- S3 event triggers Lambda function
- Lambda processes the file
- Lambda sends notification via SNS
- SNS triggers another Lambda for additional processing
- Final result stored back in S3
// Example S3 event configuration
{
"LambdaFunctionConfigurations": [
{
"LambdaFunctionArn": "arn:aws:lambda:region:account-id:function:name",
"Events": ["s3:ObjectCreated:*"],
"Filter": {
"Key": {
"FilterRules": [
{
"Name": "suffix",
"Value": ".jpg"
}
]
}
}
}
]
}
CloudWatch
Monitoring and observability service:
- Monitor AWS resources in real-time
- Collect and track metrics
- Set alarms and create automated actions
- Log aggregation and analysis
IAM (Identity and Access Management)
Manage access to AWS services and resources:
- Create and manage users and groups
- Define fine-grained permissions
- Implement principle of least privilege
- Enable multi-factor authentication (MFA)
Example IAM Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::your-bucket/*"
}
]
}
Best Practices
- Always follow the principle of least privilege for IAM
- Use CloudWatch for monitoring and alerts
- Implement proper error handling in Lambda functions
- Set up proper backup and disaster recovery
- Use versioning for S3 buckets
- Implement proper security groups and network ACLs