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

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

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

## Overview

#### Purpose and entry points
This is Terraform infrastructure for an event-driven AWS image-thumbnail pipeline. The deployment entry point is the root Terraform module: `providers.tf`, `backend.tf`, and the resource definitions applied through Terraform. Runtime processing enters through an S3 object-upload event and invokes the packaged Lambda handler `CreateThumbnail.handler` in `CreateThumbnail.zip`.

#### 1. Terraform deployment and shared naming
The root module configures AWS provider/backend concerns, input variables, and derived resource names. Bucket names are intended to be account-suffixed, avoiding globally unique-name collisions.
- `providers.tf`
- `backend.tf`
- `variables.tf`
- `locals.tf`

#### 2. Source and destination object-storage boundary
Two S3 buckets separate unprocessed uploads from generated thumbnails. The source bucket is the external ingestion boundary; the destination bucket receives Lambda output and is not described as a trigger source, preventing recursive processing.
- `s3-bucket.tf`
- `locals.tf`

#### 3. Event-to-compute integration
S3 upload notifications invoke the image-resizing Lambda. Terraform must establish both the bucket notification/event configuration and permission for S3 to invoke the Lambda; this is the central asynchronous handoff.
- `s3-bucket.tf`
- `lambda-function.tf`

#### 4. Lambda image-processing runtime
The Lambda deployment consumes `CreateThumbnail.zip`, uses Python 3.9, and executes `CreateThumbnail.handler`. It is configured for 256 MB memory and a 60-second timeout. Pillow is supplied through the Klayers Python 3.9 Pillow layer, keeping native image-processing dependencies outside the application ZIP.
- `lambda-function.tf`
- `CreateThumbnail.zip`

#### 5. Processing flow
For each qualifying S3 event, the handler reads the uploaded object from the source bucket, resizes it into a thumbnail, writes the result into the destination bucket, then emits a completion notification. Bucket names and SNS topic identity are expected to be passed to the function through Terraform-managed configuration.
- `CreateThumbnail.zip`
- `lambda-function.tf`
- `s3-bucket.tf`

#### 6. IAM authorization boundary
A dedicated Lambda execution role grants only the cross-service actions needed for the pipeline: source-object reads, destination-object writes, and SNS publishing. Role trust and permission policies are split into Terraform resources and policy documents.
- `iam-role.tf`
- `iam-policy.tf`
- `lambda_policy.json`
- `lambda_role.json`

#### 7. Notification delivery
An SNS topic decouples successful processing from email delivery. Terraform creates the topic and an email subscription using the configured recipient; delivery requires the recipient to confirm the SNS subscription.
- `sns-topic.tf`
- `variables.tf`

#### Operational dependencies
The system runs entirely on AWS managed services: Amazon S3, AWS Lambda, Amazon SNS, IAM, and CloudWatch Logs for Lambda observability. Terraform requires AWS credentials and an initialized backend/provider configuration. The principal failure boundaries are S3 event delivery, Lambda execution/dependency availability, IAM access, destination writes, and SNS subscription confirmation.

Main entry points: [`lambda-function.tf`](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf) (CreateThumbnail Lambda), [`s3-bucket.tf`](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf) (Source uploads bucket), [`locals.tf`](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/locals.tf) (Inputs and bucket names), [`providers.tf`](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/providers.tf) (Root Terraform module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terraform["Terraform deployment"]
  node_root["Root Terraform module<br/>[providers.tf]"]
  node_state["Provider and backend<br/>Terraform setup<br/>[backend.tf]"]
  node_naming["Inputs and bucket names<br/>Terraform variables<br/>[locals.tf]"]
end

subgraph group_storage["Storage and events"]
  node_source_bucket[("Source uploads bucket<br/>Amazon S3 bucket<br/>[s3-bucket.tf]")]
  node_s3_notification["Upload notification<br/>S3 event notification<br/>[s3-bucket.tf]"]
  node_lambda_permission["S3 invoke permission<br/>Lambda permission<br/>[lambda-function.tf]"]
  node_destination_bucket[("Thumbnail bucket<br/>Amazon S3 bucket<br/>[s3-bucket.tf]")]
end

subgraph group_runtime["Image processing"]
  node_lambda{{"CreateThumbnail Lambda<br/>AWS Lambda<br/>[lambda-function.tf]"}}
  node_package["CreateThumbnail package<br/>Lambda ZIP"]
  node_pillow_layer["Klayers Pillow layer<br/>Lambda layer<br/>[lambda-function.tf]"]
  node_execution_role["Lambda execution role<br/>IAM role<br/>[iam-role.tf]"]
  node_access_policy["Pipeline access policy<br/>IAM policy<br/>[iam-policy.tf]"]
  node_cloudwatch_logs["Lambda logs<br/>CloudWatch Logs"]
end

subgraph group_delivery["Notification delivery"]
  node_sns_topic["Completion topic<br/>Amazon SNS topic<br/>[sns-topic.tf]"]
  node_email_subscription["Recipient email subscription<br/>SNS email subscription<br/>[sns-topic.tf]"]
end

node_root -->|"configures"| node_state
node_root -->|"uses"| node_naming
node_naming -->|"names"| node_source_bucket
node_naming -->|"names"| node_destination_bucket
node_source_bucket -->|"emits uploads"| node_s3_notification
node_s3_notification -->|"invokes"| node_lambda
node_lambda_permission -->|"permits S3 invocation"| node_lambda
node_source_bucket -.->|"authorized caller"| node_lambda_permission
node_package -->|"deployed as"| node_lambda
node_pillow_layer -->|"attached to"| node_lambda
node_execution_role -->|"executes as"| node_lambda
node_access_policy -->|"attached to"| node_execution_role
node_lambda -->|"reads uploaded object"| node_source_bucket
node_lambda -->|"writes thumbnail"| node_destination_bucket
node_lambda -->|"publishes completion"| node_sns_topic
node_sns_topic -->|"delivers notification"| node_email_subscription
node_lambda -->|"writes logs"| node_cloudwatch_logs

click node_root "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/providers.tf"
click node_state "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/backend.tf"
click node_naming "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/locals.tf"
click node_source_bucket "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf"
click node_s3_notification "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf"
click node_lambda_permission "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_lambda "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_package "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/CreateThumbnail.zip"
click node_pillow_layer "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf"
click node_destination_bucket "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf"
click node_execution_role "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/iam-role.tf"
click node_access_policy "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/iam-policy.tf"
click node_sns_topic "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/sns-topic.tf"
click node_email_subscription "https://github.com/aws7908/image-resizing-project-on-aws/blob/main/sns-topic.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_root,node_state,node_naming toneBlue
class node_source_bucket,node_s3_notification,node_lambda_permission,node_destination_bucket toneAmber
class node_lambda,node_package,node_pillow_layer,node_execution_role,node_access_policy,node_cloudwatch_logs toneMint
class node_sns_topic,node_email_subscription toneRose
```

## Components

### Terraform deployment

- [Root Terraform module](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/providers.tf): Terraform module · Applies the AWS infrastructure. · `providers.tf`
- [Provider and backend](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/backend.tf): Terraform setup · `backend.tf`
- [Inputs and bucket names](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/locals.tf): Terraform variables · Derives account-suffixed resource names. · `locals.tf`

### Storage and events

- [Source uploads bucket](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf): Amazon S3 bucket · External ingestion boundary. · `s3-bucket.tf`
- [Upload notification](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf): S3 event notification · Qualifying object uploads invoke the function. · `s3-bucket.tf`
- [S3 invoke permission](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf): Lambda permission · `lambda-function.tf`
- [Thumbnail bucket](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/s3-bucket.tf): Amazon S3 bucket · Receives generated thumbnails and does not trigger processing. · `s3-bucket.tf`

### Image processing

- [CreateThumbnail Lambda](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf): AWS Lambda · Python 3.9 handler with 256 MB and 60-second timeout. · `lambda-function.tf`
- [CreateThumbnail package](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/CreateThumbnail.zip): Lambda ZIP · Contains CreateThumbnail.handler. · `CreateThumbnail.zip`
- [Klayers Pillow layer](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/lambda-function.tf): Lambda layer · Supplies native Pillow dependencies. · `lambda-function.tf`
- [Lambda execution role](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/iam-role.tf): IAM role · Trusted by Lambda. · `iam-role.tf`
- [Pipeline access policy](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/iam-policy.tf): IAM policy · Allows source reads, destination writes, and SNS publishing. · `iam-policy.tf`
- **Lambda logs**: CloudWatch Logs

### Notification delivery

- [Completion topic](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/sns-topic.tf): Amazon SNS topic · Decouples processing completion from email delivery. · `sns-topic.tf`
- [Recipient email subscription](https://github.com/aws7908/image-resizing-project-on-aws/blob/main/sns-topic.tf): SNS email subscription · Requires recipient confirmation. · `sns-topic.tf`

## Connections

- Root Terraform module → Provider and backend: configures
- Root Terraform module → Inputs and bucket names: uses
- Inputs and bucket names → Source uploads bucket: names
- Inputs and bucket names → Thumbnail bucket: names
- Source uploads bucket → Upload notification: emits uploads
- Upload notification → CreateThumbnail Lambda: invokes
- S3 invoke permission → CreateThumbnail Lambda: permits S3 invocation
- Source uploads bucket → S3 invoke permission: authorized caller
- CreateThumbnail package → CreateThumbnail Lambda: deployed as
- Klayers Pillow layer → CreateThumbnail Lambda: attached to
- Lambda execution role → CreateThumbnail Lambda: executes as
- Pipeline access policy → Lambda execution role: attached to
- CreateThumbnail Lambda → Source uploads bucket: reads uploaded object
- CreateThumbnail Lambda → Thumbnail bucket: writes thumbnail
- CreateThumbnail Lambda → Completion topic: publishes completion
- Completion topic → Recipient email subscription: delivers notification
- CreateThumbnail Lambda → Lambda logs: writes logs
