# abdullah786junaid-ux/image-resizing-project-on-aws-1 architecture

> Architecture diagram of the GitHub repository abdullah786junaid-ux/image-resizing-project-on-aws-1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdullah786junaid-ux/image-resizing-project-on-aws-1
- Repository: https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1

## Overview

#### 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`](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/lambda-function.tf) (CreateThumbnail), [`providers.tf`](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/providers.tf) (Terraform root), [`s3-bucket.tf`](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf) (Source bucket), [`locals.tf`](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/locals.tf) (Shared bucket naming)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_provisioning["Terraform control plane"]
  node_terraform["Terraform root<br/>IaC composition<br/>[providers.tf]"]
  node_terraform_backend["Backend and provider<br/>Terraform setup<br/>[backend.tf]"]
  node_deployment_inputs["Deployment inputs<br/>Terraform variables<br/>[variables.tf]"]
  node_shared_naming["Shared bucket naming<br/>Terraform locals<br/>[locals.tf]"]
end

subgraph group_storage["S3 content boundary"]
  node_source_bucket[("Source bucket<br/>AWS S3<br/>[s3-bucket.tf]")]
  node_destination_bucket[("Thumbnail bucket<br/>AWS S3<br/>[s3-bucket.tf]")]
end

subgraph group_processing["Thumbnail processing"]
  node_s3_event_trigger["Object-created trigger<br/>S3 notification<br/>[s3-bucket.tf]"]
  node_thumbnail_lambda{{"CreateThumbnail<br/>AWS Lambda<br/>[lambda-function.tf]"}}
  node_lambda_artifact["CreateThumbnail.zip<br/>Lambda artifact"]
  node_pillow_layer["Pillow layer<br/>Lambda layer<br/>[lambda-function.tf]"]
  node_lambda_role["Lambda execution role<br/>AWS IAM role<br/>[iam-role.tf]"]
  node_lambda_policy["S3 and SNS permissions<br/>AWS IAM policy<br/>[iam-policy.tf]"]
  node_cloudwatch_logs["Lambda logs<br/>CloudWatch Logs"]
end

subgraph group_notification["Completion notification"]
  node_sns_topic["Completion topic<br/>AWS SNS<br/>[sns-topic.tf]"]
  node_email_subscriber["Email subscriber<br/>External recipient<br/>[variables.tf]"]
end

node_terraform_backend -->|"configures"| node_terraform
node_deployment_inputs -->|"supplies inputs"| node_terraform
node_shared_naming -->|"names"| node_source_bucket
node_shared_naming -->|"names"| node_destination_bucket
node_terraform -->|"provisions"| node_source_bucket
node_terraform -->|"provisions"| node_destination_bucket
node_terraform -->|"deploys"| node_thumbnail_lambda
node_source_bucket -->|"object created"| node_s3_event_trigger
node_s3_event_trigger -->|"invokes"| node_thumbnail_lambda
node_lambda_artifact -->|"package"| node_thumbnail_lambda
node_pillow_layer -->|"dependency"| node_thumbnail_lambda
node_lambda_policy -->|"attached to"| node_lambda_role
node_lambda_role -->|"execution identity"| node_thumbnail_lambda
node_thumbnail_lambda -->|"reads uploaded image"| node_source_bucket
node_thumbnail_lambda -->|"writes thumbnail"| node_destination_bucket
node_thumbnail_lambda -->|"publishes completion"| node_sns_topic
node_sns_topic -->|"delivers email"| node_email_subscriber
node_thumbnail_lambda -->|"writes logs"| node_cloudwatch_logs

click node_terraform "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/providers.tf"
click node_terraform_backend "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/backend.tf"
click node_deployment_inputs "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/variables.tf"
click node_shared_naming "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/locals.tf"
click node_source_bucket "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf"
click node_destination_bucket "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf"
click node_s3_event_trigger "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf"
click node_thumbnail_lambda "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/lambda-function.tf"
click node_lambda_artifact "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/CreateThumbnail.zip"
click node_pillow_layer "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/lambda-function.tf"
click node_lambda_role "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/iam-role.tf"
click node_lambda_policy "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/iam-policy.tf"
click node_sns_topic "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/sns-topic.tf"
click node_email_subscriber "https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/variables.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_terraform,node_terraform_backend,node_deployment_inputs,node_shared_naming toneBlue
class node_source_bucket,node_destination_bucket toneAmber
class node_s3_event_trigger,node_thumbnail_lambda,node_lambda_artifact,node_pillow_layer,node_lambda_role,node_lambda_policy,node_cloudwatch_logs toneMint
class node_sns_topic,node_email_subscriber toneRose
```

## Components

### Terraform control plane

- [Terraform root](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/providers.tf): IaC composition · Provisions the AWS pipeline. · `providers.tf`
- [Backend and provider](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/backend.tf): Terraform setup · `backend.tf`
- [Deployment inputs](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/variables.tf): Terraform variables · Supplies region, credentials, and notification email. · `variables.tf`
- [Shared bucket naming](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/locals.tf): Terraform locals · Defines account-suffixed resource names. · `locals.tf`

### S3 content boundary

- [Source bucket](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf): AWS S3 · Receives original image uploads. · `s3-bucket.tf`
- [Thumbnail bucket](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf): AWS S3 · Stores generated thumbnails. · `s3-bucket.tf`

### Thumbnail processing

- [Object-created trigger](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/s3-bucket.tf): S3 notification · Asynchronously invokes Lambda for source uploads. · `s3-bucket.tf`
- [CreateThumbnail](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/lambda-function.tf): AWS Lambda · Python 3.9 thumbnail processor. · `lambda-function.tf`
- [CreateThumbnail.zip](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/CreateThumbnail.zip): Lambda artifact · Contains CreateThumbnail.handler. · `CreateThumbnail.zip`
- [Pillow layer](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/lambda-function.tf): Lambda layer · Provides image-processing dependency. · `lambda-function.tf`
- [Lambda execution role](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/iam-role.tf): AWS IAM role · Grants runtime cross-service access. · `iam-role.tf`
- [S3 and SNS permissions](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/iam-policy.tf): AWS IAM policy · Allows source reads, destination writes, and SNS publishing. · `iam-policy.tf`
- **Lambda logs**: CloudWatch Logs · Captures runtime observability data.

### Completion notification

- [Completion topic](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/sns-topic.tf): AWS SNS · Publishes successful processing results. · `sns-topic.tf`
- [Email subscriber](https://github.com/abdullah786junaid-ux/image-resizing-project-on-aws-1/blob/main/variables.tf): External recipient · Must confirm the SNS subscription. · `variables.tf`

## Connections

- 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
