AWS Well-Architected Framework
Welcome to Lesson 9: AWS Well-Architected Framework! By now, you've built a solid foundation in AWS core services, security, monitoring, and cost management. In this lesson, we'll learn how to apply these concepts systematically using AWS's blueprint for building secure, high-performing, resilient, and efficient infrastructure.
Learning Goals:
- Understand the six pillars of the Well-Architected Framework
- Learn to apply framework principles to real-world scenarios
- Use the Well-Architected Tool to review workloads
- Identify common architectural improvements
The Six Pillars Explained
The AWS Well-Architected Framework provides a consistent approach for evaluating architectures and implementing designs that scale over time. Let's explore each pillar:
Operational Excellence
Focuses on running and monitoring systems to deliver business value and continually improving processes and procedures.
# Example: Infrastructure as Code for operational consistency
AWSTemplateFormatVersion: '2010-09-09'
Resources:
OperationalBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "operations-logs-${AWS::AccountId}"
VersioningConfiguration:
Status: Enabled
LoggingConfiguration:
DestinationBucketName: !Ref OperationalBucket
LogFilePrefix: "access-logs/"
Use AWS CloudFormation or Terraform for all infrastructure deployments. This ensures consistent environments and makes rollbacks predictable.
Security
Protects information and systems while delivering business value through risk assessments and mitigation strategies.
import boto3
def check_public_s3_buckets():
s3 = boto3.client('s3')
buckets = s3.list_buckets()
public_buckets = []
for bucket in buckets['Buckets']:
acl = s3.get_bucket_acl(Bucket=bucket['Name'])
for grant in acl['Grants']:
if grant['Grantee']['Type'] == 'Group' and 'AllUsers' in grant['Grantee']['URI']:
public_buckets.append(bucket['Name'])
return public_buckets
# Run security check
if __name__ == "__main__":
public = check_public_s3_buckets()
print(f"Public buckets found: {public}")
Reliability
Ensures workloads perform their intended functions correctly and consistently when expected to.
{
"DBInstanceIdentifier": "production-db",
"BackupRetentionPeriod": 35,
"PreferredBackupWindow": "03:00-04:00",
"PreferredMaintenanceWindow": "sun:04:00-sun:05:00",
"MultiAZ": true,
"AutoMinorVersionUpgrade": true
}
Performance Efficiency
Uses computing resources efficiently to meet system requirements and maintain that efficiency as demand changes.
- Python
- Node.js
import json
import boto3
def lambda_handler(event, context):
# Use connection reuse for better performance
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('HighTrafficTable')
# Implement efficient query patterns
response = table.query(
KeyConditionExpression=boto3.dynamodb.conditions.Key('user_id').eq(event['user_id']),
Limit=10 # Avoid scanning large datasets
)
return {
'statusCode': 200,
'body': json.dumps(response['Items'])
}
const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB.DocumentClient();
exports.handler = async (event) => {
const params = {
TableName: 'HighTrafficTable',
KeyConditionExpression: 'user_id = :uid',
ExpressionAttributeValues: {
':uid': event.user_id
},
Limit: 10
};
const result = await dynamodb.query(params).promise();
return {
statusCode: 200,
body: JSON.stringify(result.Items)
};
};
Cost Optimization
Avoids unnecessary costs by running systems at the lowest price point for your requirements.
#!/bin/bash
# Script to identify underutilized EC2 instances
REGION="us-east-1"
# Get instances with low CPU utilization (adjust threshold as needed)
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-1234567890abcdef0 \
--start-time 2023-01-01T00:00:00Z \
--end-time 2023-01-31T23:59:59Z \
--period 3600 \
--statistics Average \
--region $REGION \
--output table
Sustainability
Minimizes the environmental impacts of running cloud workloads.
Resources:
SustainableLambda:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: index.handler
MemorySize: 512 # Right-sized to avoid overallocation
Timeout: 30
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: sustainable-service
EfficientDynamoDB:
Type: AWS::DynamoDB::Table
Properties:
TableName: EfficientTable
BillingMode: PAY_PER_REQUEST # Scale to zero when unused
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
Using the Well-Architected Tool
AWS provides a free tool to help you review your workloads against the framework.
import boto3
def list_workload_reviews():
client = boto3.client('wellarchitected')
response = client.list_workloads()
for workload in response['WorkloadSummaries']:
print(f"Workload: {workload['WorkloadName']}")
print(f"ARN: {workload['WorkloadArn']}")
print(f"Updated: {workload['UpdatedAt']}")
print("-" * 50)
# Initialize a review
def create_workload_review():
client = boto3.client('wellarchitected')
response = client.create_workload(
WorkloadName='ProductionWebApp',
Description='Main customer-facing application',
Environment='PRODUCTION',
ReviewOwner='team@company.com'
)
return response['WorkloadArn']
The Well-Architected Tool is available at no additional cost in the AWS Management Console. It provides specific recommendations and tracks your improvement progress over time.
Common Pitfalls
- Ignoring cost optimization early: Many teams focus on functionality first and delay cost optimization, leading to expensive re-architecture later
- Over-engineering for reliability: Building for 99.999% availability when 99.9% would suffice, significantly increasing complexity and cost
- Security as an afterthought: Applying security controls after deployment instead of baking them into the design phase
- Manual operations: Using manual processes that can't scale and introduce human error
- Not using the Well-Architected Tool: Missing out on free, expert guidance tailored to your specific workload
Summary
The AWS Well-Architected Framework provides a structured approach to building cloud infrastructure that balances operational excellence, security, reliability, performance efficiency, cost optimization, and sustainability. By applying these principles and using the Well-Architected Tool, you can build systems that scale effectively while maintaining security and controlling costs.
Quiz
AWS Well-Architected Framework Fundamentals
Which pillar focuses on running and monitoring systems to deliver business value?