This repository contains workshop materials for cloud architecture demonstrations, featuring both serverful and serverless approaches to building AWS applications.
This workshop consists of two parts:
- Part 1: Serverful Web Architecture - A high-availability web application using EC2, Auto Scaling, and Load Balancing
- Part 2: Serverless Todo API - A fully serverless REST API using Lambda, API Gateway, and DynamoDB
- AWS account with appropriate permissions
- Terraform installed (v1.0+)
- Git
To create a user for Terraform with the necessary permissions:
- Go to AWS IAM Console
- Click "Create user"
- Add User name "terraform" and click "Next"
- Click "Attach policies directly" and select the following policies:
- AmazonVPCFullAccess
- AmazonEC2FullAccess
- AmazonAPIGatewayAdministrator
- AWSLambda_FullAccess
- IAMFullAccess
- AmazonDynamoDBFullAccess
- Click "Next"
- Click "Create user"
Then create access keys for the user:
- Select the user "terraform"
- Go to "Security credentials"
- Click "Create access key"
- Choose "Command Line Interface (CLI)"
- Click "Next" and "Create access key"
- Save the access key and secret key
- Configure your environment:
# In the root of the directory
mkdir -p .aws
cat > .aws/creds << EOF
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
EOF
This part demonstrates a highly available web application using EC2 instances behind a load balancer.
- VPC with public subnets across 3 availability zones
- EC2 instances in an Auto Scaling Group
- Application Load Balancer to distribute traffic
- Security Groups for network access control
cd webserver
terraform init
terraform plan
terraform apply
After deployment, you can access your web application via the load balancer URL provided in the Terraform output.
- VPC Configuration: Custom network with public subnets
- Auto Scaling Group: Ensures high availability by maintaining the desired number of instances
- Launch Template: Defines the EC2 instance configuration with a bootstrap script
- Load Balancer: Routes traffic to healthy instances across availability zones
This part demonstrates a serverless REST API for managing todo items.
- Lambda functions for backend logic
- API Gateway for RESTful API interface
- DynamoDB for persistent data storage
- IAM roles and policies for security
cd todo
terraform init
terraform plan
terraform apply
After deployment, you can retrieve the API endpoint:
# Get the API endpoint from Terraform output
export TODO_API_ENDPOINT=$(terraform output -raw todo_api_endpoint)
echo $TODO_API_ENDPOINT
Test the API with curl:
# Get all todos
curl -X GET $TODO_API_ENDPOINT
# Add a new todo
curl -X POST $TODO_API_ENDPOINT \
-H "Content-Type: application/json" \
-d '{"text": "Plan a meeting with Alex to prepare the AWS workshop"}'
- Lambda Functions:
- getToDos: Retrieves all todo items from DynamoDB
- addToDo: Creates a new todo item in DynamoDB
- API Gateway: RESTful interface with two endpoints:
- GET /todos: List all todo items
- POST /todos: Create a new todo item
- DynamoDB: NoSQL database with a single table for todo items
To avoid incurring charges, remove all resources when finished:
# Clean up Todo API resources
cd todo
terraform destroy
# Clean up Webserver resources
cd ../webserver
terraform destroy
This project is licensed under the MIT License - see the LICENSE file for details.