How abdullah786junaid-ux/image-resizing-project-on-aws-1 works
Purpose and Entry Points
This is Terraform-managed AWS infrastructure for a serverless image-thumbnail pipeline. Applying the root Terraform configuration provisions the runtime; image uploads are the operational entry point. The Lambda deployment artifact is CreateThumbnail.zip, with handler CreateThumbnail.handler.
Provisioning and State
Terraform composes AWS resources and provider/backend setup from:
• providers.tf
• backend.tf
• variables.tf
Inputs include AWS region/credentials and notification email. Shared naming, including account-suffixed bucket names, is centralized in locals.tf.
Source-to-Destination S3 Boundary
Two S3 buckets separate original and derived content:
• s3-bucket.tf
• locals.tf
The source bucket receives uploads and emits object-created events. The destination bucket stores generated thumbnails. This separation prevents resized output from recursively re-triggering processing and establishes distinct read/write permission boundaries.
Lambda Processing Stage
AWS Lambda is configured and packaged through:
• lambda-function.tf
• CreateThumbnail.zip
The function runs Python 3.9 with 256 MB memory and a 60-second timeout. It uses a Pillow Lambda layer, reads the S3 event payload, downloads the uploaded image, creates a thumbnail, and writes it to the destination bucket. S3 event notification plus Lambda invoke permission form the asynchronous trigger boundary.
IAM Authorization Model
The Lambda execution role and its resource permissions are defined in:
• iam-role.tf
• iam-policy.tf
• lambda_policy.json
The role scopes Lambda’s cross-service access: source-object reads, destination-object writes, and SNS publishing. Role/policy JSON artifacts may support or mirror Terraform-managed IAM definitions:
• lambda_role.json
Notification Stage
Completion is published to an SNS topic, which delivers email notifications to its configured subscriber:
• sns-topic.tf
• variables.tf
The notification occurs after successful thumbnail upload and includes the processing result/link. Email subscriptions require recipient confirmation outside Terraform’s direct delivery control.
Runtime and External Services
The deployed system depends on AWS S3, Lambda, IAM, SNS, and CloudWatch Logs for Lambda observability. Terraform is the infrastructure control plane; AWS credentials and target region are supplied at deployment time. Pillow is provided through the configured Lambda layer rather than a visible source dependency in this repository.
Main entry points: lambda-function.tf CreateThumbnail · providers.tf Terraform root · s3-bucket.tf Source bucket · locals.tf Shared bucket naming
Components 15
Terraform control plane
- Terraform root · Provisions the AWS pipeline.
providers.tf - Backend and provider
backend.tf - Deployment inputs · Supplies region, credentials, and notification email.
variables.tf - Shared bucket naming · Defines account-suffixed resource names.
locals.tf
S3 content boundary
- Source bucket · Receives original image uploads.
s3-bucket.tf - Thumbnail bucket · Stores generated thumbnails.
s3-bucket.tf
Thumbnail processing
- Object-created trigger · Asynchronously invokes Lambda for source uploads.
s3-bucket.tf - CreateThumbnail · Python 3.9 thumbnail processor.
lambda-function.tf - CreateThumbnail.zip · Contains CreateThumbnail.handler.
CreateThumbnail.zip - Pillow layer · Provides image-processing dependency.
lambda-function.tf - Lambda execution role · Grants runtime cross-service access.
iam-role.tf - S3 and SNS permissions · Allows source reads, destination writes, and SNS publishing.
iam-policy.tf - Lambda logs · Captures runtime observability data.
Completion notification
- Completion topic · Publishes successful processing results.
sns-topic.tf - Email subscriber · Must confirm the SNS subscription.
variables.tf
Connections 18
- Backend and provider → Terraform root: configures
- Deployment inputs → Terraform root: supplies inputs
- Shared bucket naming → Source bucket: names
- Shared bucket naming → Thumbnail bucket: names
- Terraform root → Source bucket: provisions
- Terraform root → Thumbnail bucket: provisions
- Terraform root → CreateThumbnail: deploys
- Source bucket → Object-created trigger: object created
- Object-created trigger → CreateThumbnail: invokes
- CreateThumbnail.zip → CreateThumbnail: package
- Pillow layer → CreateThumbnail: dependency
- S3 and SNS permissions → Lambda execution role: attached to
- Lambda execution role → CreateThumbnail: execution identity
- CreateThumbnail → Source bucket: reads uploaded image
- CreateThumbnail → Thumbnail bucket: writes thumbnail
- CreateThumbnail → Completion topic: publishes completion
- Completion topic → Email subscriber: delivers email
- CreateThumbnail → Lambda logs: writes logs