# srinivasshirure/image-resizing-project-on-aws architecture

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

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

## Overview

#### Purpose and entry points
This is Terraform-managed AWS infrastructure for an event-driven image-thumbnail pipeline. The operational entry point is an object upload to the source S3 bucket; the infrastructure entry point is Terraform deployment through the root `.tf` files. Lambda implementation is packaged as `CreateThumbnail.zip`, with handler `CreateThumbnail.handler`.

#### Provisioning and configuration
Terraform defines the AWS provider, remote/state backend, inputs, and derived naming values. Bucket and service names are parameterized and account-suffixed through locals; deployment credentials, region, and notification email are external inputs.
- `providers.tf`
- `backend.tf`
- `variables.tf`
- `locals.tf`

#### Ingestion boundary: source S3
A source S3 bucket accepts original image uploads. Its object-created event configuration is the event boundary that invokes Lambda. This separates untrusted uploaded image data from processing execution.
- `s3-bucket.tf`
- `lambda-function.tf`

#### Compute stage: Lambda thumbnail processor
AWS Lambda runs Python 3.9 with 256 MB memory and a 60-second timeout. It loads Pillow through the configured Klayers Python 3.9 layer, receives the S3 event, downloads the uploaded object, creates a thumbnail, and writes output. The deployment artifact is prebuilt rather than generated by Terraform.
- `lambda-function.tf`
- `CreateThumbnail.zip`

#### Output boundary: destination S3
A separate destination bucket stores resized images. Lambda is the intended writer, keeping originals and generated artifacts in distinct storage domains and avoiding source-trigger recursion.
- `s3-bucket.tf`
- `iam-policy.tf`

#### Notification stage: SNS email
After successful processing, Lambda publishes completion information—expected to include the resized image result—to an SNS topic. SNS delivers it to an email subscription whose address is supplied as Terraform input and requires recipient confirmation.
- `sns-topic.tf`
- `lambda-function.tf`
- `variables.tf`

#### Authorization and invocation control
A Lambda execution role and attached policies grant the minimum architectural capabilities: read source objects, write destination objects, and publish to SNS. Lambda resource configuration also permits S3 to invoke the function; these are distinct trust/control paths.
- `iam-role.tf`
- `iam-policy.tf`
- `lambda_policy.json`
- `lambda_role.json`

#### Primary flow and runtime dependencies
1. Client uploads an image to the source bucket.
2. S3 emits an object-created event to Lambda.
3. Lambda uses AWS S3 APIs and Pillow to fetch and resize the image.
4. Lambda writes the thumbnail to destination S3.
5. Lambda publishes status/result to Amazon SNS; SNS sends email.

Material external services are AWS S3, Lambda, IAM, SNS, CloudWatch Logs (Lambda observability), and the third-party Klayers Pillow Lambda layer.

Main entry points: [`lambda-function.tf`](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf) (Thumbnail Lambda), [`providers.tf`](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/providers.tf) (Terraform root), [`iam-role.tf`](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-role.tf) (Lambda execution role), [`s3-bucket.tf`](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/s3-bucket.tf) (Source S3 bucket)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terraform["Terraform provisioning"]
  node_terraform_root["Terraform root<br/>IaC entry point<br/>[providers.tf]"]
end

subgraph group_storage["Image storage"]
  node_source_bucket[("Source S3 bucket<br/>[s3-bucket.tf]")]
  node_destination_bucket[("Destination S3 bucket<br/>[s3-bucket.tf]")]
  node_s3_event["Object-created event<br/>S3 notification<br/>[lambda-function.tf]"]
end

subgraph group_processing["Thumbnail processing"]
  node_thumbnail_lambda{{"Thumbnail Lambda<br/>AWS Lambda<br/>[lambda-function.tf]"}}
  node_lambda_artifact["CreateThumbnail.zip<br/>Lambda artifact"]
  node_pillow_layer["Klayers Pillow layer<br/>Lambda layer<br/>[lambda-function.tf]"]
  node_lambda_role{{"Lambda execution role<br/>IAM role<br/>[iam-role.tf]"}}
  node_s3_access_policy["S3 access policy<br/>IAM policy<br/>[iam-policy.tf]"]
  node_sns_publish_policy["SNS publish policy<br/>IAM policy<br/>[iam-policy.tf]"]
  node_cloudwatch_logs[("CloudWatch Logs<br/>AWS observability<br/>[lambda-function.tf]")]
  node_s3_invoke_permission["S3 invoke permission<br/>Lambda resource policy<br/>[lambda-function.tf]"]
end

subgraph group_notification["Notification"]
  node_sns_topic["Completion SNS topic<br/>[sns-topic.tf]"]
  node_email_subscription["Email subscription<br/>SNS email endpoint<br/>[sns-topic.tf]"]
end

node_terraform_root -->|"provisions"| node_source_bucket
node_terraform_root -->|"provisions"| node_destination_bucket
node_terraform_root -->|"deploys"| node_thumbnail_lambda
node_terraform_root -->|"provisions"| node_sns_topic
node_source_bucket -->|"object upload"| node_s3_event
node_s3_event -->|"invokes"| node_thumbnail_lambda
node_s3_invoke_permission -.->|"authorizes S3 invocation"| node_thumbnail_lambda
node_thumbnail_lambda -->|"runs"| node_lambda_artifact
node_thumbnail_lambda -->|"uses"| node_pillow_layer
node_thumbnail_lambda -->|"assumes"| node_lambda_role
node_lambda_role -->|"attaches"| node_s3_access_policy
node_lambda_role -->|"attaches"| node_sns_publish_policy
node_thumbnail_lambda -->|"reads original"| 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_subscription
node_thumbnail_lambda -->|"writes logs"| node_cloudwatch_logs

click node_terraform_root "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/providers.tf"
click node_source_bucket "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/s3-bucket.tf"
click node_destination_bucket "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/s3-bucket.tf"
click node_s3_event "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_thumbnail_lambda "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_lambda_artifact "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/CreateThumbnail.zip"
click node_pillow_layer "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_lambda_role "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-role.tf"
click node_s3_access_policy "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-policy.tf"
click node_sns_publish_policy "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-policy.tf"
click node_cloudwatch_logs "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_sns_topic "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/sns-topic.tf"
click node_email_subscription "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/sns-topic.tf"
click node_s3_invoke_permission "https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.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_root toneBlue
class node_source_bucket,node_destination_bucket,node_s3_event toneAmber
class node_thumbnail_lambda,node_lambda_artifact,node_pillow_layer,node_lambda_role,node_s3_access_policy,node_sns_publish_policy,node_cloudwatch_logs,node_s3_invoke_permission toneMint
class node_sns_topic,node_email_subscription toneRose
```

## Components

### Terraform provisioning

Root Terraform defines and deploys the AWS resources.

- [Terraform root](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/providers.tf): IaC entry point · Provider, backend, inputs, and derived resource names. · `providers.tf`

### Image storage

Originals and generated thumbnails remain separated.

- [Source S3 bucket](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/s3-bucket.tf): S3 bucket · Accepts uploaded original images and emits object-created events. · `s3-bucket.tf`
- [Destination S3 bucket](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/s3-bucket.tf): S3 bucket · Stores generated thumbnails. · `s3-bucket.tf`
- [Object-created event](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf): S3 notification · Invocation boundary for uploaded objects. · `lambda-function.tf`

### Thumbnail processing

Event-driven Lambda runtime and dependencies.

- [Thumbnail Lambda](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf): AWS Lambda · Python 3.9 handler CreateThumbnail.handler; 256 MB and 60-second timeout. · `lambda-function.tf`
- [CreateThumbnail.zip](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/CreateThumbnail.zip): Lambda artifact · Prebuilt deployment package containing thumbnail logic. · `CreateThumbnail.zip`
- [Klayers Pillow layer](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf): Lambda layer · Provides Pillow for Python 3.9 image resizing. · `lambda-function.tf`
- [Lambda execution role](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-role.tf): IAM role · Runtime identity assumed by the thumbnail function. · `iam-role.tf`
- [S3 access policy](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-policy.tf): IAM policy · Allows source reads and destination writes. · `iam-policy.tf`
- [SNS publish policy](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/iam-policy.tf): IAM policy · Allows Lambda to publish completion messages. · `iam-policy.tf`
- [CloudWatch Logs](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf): AWS observability · Receives Lambda execution logs. · `lambda-function.tf`
- [S3 invoke permission](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/lambda-function.tf): Lambda resource policy · Permits the source bucket to invoke Lambda. · `lambda-function.tf`

### Notification

Completion delivery through SNS email.

- [Completion SNS topic](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/sns-topic.tf): SNS topic · Receives processing status and result notifications. · `sns-topic.tf`
- [Email subscription](https://github.com/srinivasshirure/image-resizing-project-on-aws/blob/main/sns-topic.tf): SNS email endpoint · Recipient must confirm the subscription. · `sns-topic.tf`

## Connections

- Terraform root → Source S3 bucket: provisions
- Terraform root → Destination S3 bucket: provisions
- Terraform root → Thumbnail Lambda: deploys
- Terraform root → Completion SNS topic: provisions
- Source S3 bucket → Object-created event: object upload
- Object-created event → Thumbnail Lambda: invokes
- S3 invoke permission → Thumbnail Lambda: authorizes S3 invocation
- Thumbnail Lambda → CreateThumbnail.zip: runs
- Thumbnail Lambda → Klayers Pillow layer: uses
- Thumbnail Lambda → Lambda execution role: assumes
- Lambda execution role → S3 access policy: attaches
- Lambda execution role → SNS publish policy: attaches
- Thumbnail Lambda → Source S3 bucket: reads original
- Thumbnail Lambda → Destination S3 bucket: writes thumbnail
- Thumbnail Lambda → Completion SNS topic: publishes completion
- Completion SNS topic → Email subscription: delivers email
- Thumbnail Lambda → CloudWatch Logs: writes logs
