# newrelic/aws_s3_log_ingestion_lambda architecture

> Architecture diagram of the GitHub repository newrelic/aws_s3_log_ingestion_lambda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/newrelic/aws_s3_log_ingestion_lambda
- Repository: https://github.com/newrelic/aws_s3_log_ingestion_lambda

## Overview

This is an AWS Lambda log shipper: an S3-triggered invocation reads an object, optionally interprets CloudTrail records, batches and compresses log payloads, then sends them to New Relic. The implementation is concentrated in one file, so its distinct runtime responsibilities share that source path. The README documents the S3-to-New-Relic purpose; omitted handler and configuration details limit certainty about event wiring and deployment setup.

Main entry points: [`src/handler.py`](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py) (Object reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["S3 ingestion"]
  node_s3_bucket[("S3 bucket")]
  node_lambda["Lambda handler<br/>[handler.py]"]
  node_object_reader["Object reader<br/>[handler.py]"]
end

subgraph group_transform["Log processing"]
  node_cloudtrail["CloudTrail conversion<br/>[handler.py]"]
  node_log_batching["Log batching<br/>[handler.py]"]
  node_payload["Payload compression<br/>[handler.py]"]
end

subgraph group_delivery["New Relic delivery"]
  node_endpoint["Endpoint selection<br/>[handler.py]"]
  node_request["Request creation<br/>[handler.py]"]
  node_retry["Async delivery<br/>[handler.py]"]
end

node_s3_event(("S3 event"))
node_new_relic["New Relic Logs"]

node_s3_event -.->|"invokes"| node_lambda
node_lambda -->|"fetches object"| node_object_reader
node_object_reader -->|"reads object"| node_s3_bucket
node_object_reader -->|"converts records"| node_cloudtrail
node_object_reader -->|"batches logs"| node_log_batching
node_log_batching -->|"packages payload"| node_payload
node_payload -->|"creates request"| node_request
node_request -->|"selects endpoint"| node_endpoint
node_request -->|"sends request"| node_retry
node_retry -->|"posts logs"| node_new_relic

click node_lambda "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_object_reader "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_cloudtrail "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_log_batching "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_payload "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_endpoint "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_request "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"
click node_retry "https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py"

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_s3_bucket,node_lambda,node_object_reader toneBlue
class node_cloudtrail,node_log_batching,node_payload toneAmber
class node_endpoint,node_request,node_retry toneMint
class node_s3_event,node_new_relic toneIndigo
```

## Components

### S3 ingestion

- **S3 bucket**
- [Lambda handler](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`
- [Object reader](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`

### Log processing

- [CloudTrail conversion](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`
- [Log batching](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`
- [Payload compression](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`

### New Relic delivery

- [Endpoint selection](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`
- [Request creation](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`
- [Async delivery](https://github.com/newrelic/aws_s3_log_ingestion_lambda/blob/master/src/handler.py): `src/handler.py`

### Other components

- **S3 event**
- **New Relic Logs**

## Connections

- S3 event → Lambda handler: invokes (evidence: `README.md`)
- Lambda handler → Object reader: fetches object (evidence: `src/handler.py`)
- Object reader → S3 bucket: reads object (evidence: `src/handler.py`)
- Object reader → CloudTrail conversion: converts records (evidence: `src/handler.py`)
- Object reader → Log batching: batches logs (evidence: `src/handler.py`)
- Log batching → Payload compression: packages payload (evidence: `src/handler.py`)
- Payload compression → Request creation: creates request (evidence: `src/handler.py`)
- Request creation → Endpoint selection: selects endpoint (evidence: `src/handler.py`)
- Request creation → Async delivery: sends request (evidence: `src/handler.py`)
- Async delivery → New Relic Logs: posts logs (evidence: `src/handler.py`)
