Skip to content

Commit b559e05

Browse files
authored
Merge branch 'main' into main
2 parents b5fb89e + 0a04fca commit b559e05

File tree

4 files changed

+70
-2
lines changed

4 files changed

+70
-2
lines changed

integration-kinesis-to-lambda/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import base64
2+
def lambda_handler(event, context):
3+
4+
for record in event['Records']:
5+
try:
6+
print(f"Processed Kinesis Event - EventID: {record['eventID']}")
7+
record_data = base64.b64decode(record['kinesis']['data']).decode('utf-8')
8+
print(f"Record Data: {record_data}")
9+
# TODO: Do interesting work based on the new data
10+
except Exception as e:
11+
print(f"An error occurred {e}")
12+
raise e
13+
print(f"Successfully processed {len(event['Records'])} records.")

integration-kinesis-to-lambda/snippet-data.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Using AWS Lambda with Amazon Kinesis without Batch Item Handling.",
44
"type": "Integration",
55
"services": ["lambda", "kinesis"],
6-
"languages": ["Node", "TypeScript", ".NET", "Java", "Go"],
6+
"languages": ["Node", "TypeScript", ".NET", "Java", "Go", "Python"],
77
"tags": [],
88
"introBox": {
99
"headline": "How it works",
@@ -85,6 +85,17 @@
8585
"language": "rust"
8686
}
8787
]
88+
},
89+
{
90+
"id": "Python",
91+
"title": "Usage Example with Python",
92+
"description": "Consuming Kinesis event with Lambda using Python without batch item handling.",
93+
"snippets": [
94+
{
95+
"snippetPath": "main.py",
96+
"language": "python"
97+
}
98+
]
8899
}
89100
]
90101
}
@@ -112,6 +123,13 @@
112123
"image": "https://pbs.twimg.com/profile_images/888727786797412352/DEZ1mRjs_400x400.jpg",
113124
"bio": "Solutions Architect Architect at AWS",
114125
"linkedin": "ananthanr"
126+
},
127+
{
128+
"headline": "Python Example Presented by Umang Aggarwal",
129+
"name": "Umang Aggarwal",
130+
"image": "https://media.licdn.com/dms/image/D5603AQGPJSLqUSGPmA/profile-displayphoto-shrink_800_800/0/1684261011000?e=1707350400&v=beta&t=YoDvcLUA8y_w5ZAq0p6wDNL5nut8PVKCUvrf6rTi43A",
131+
"bio": "Cloud Support Engineer at AWS",
132+
"linkedin": "umangaggarwal"
115133
}
116134
]
117-
}
135+
}

integration-sns-to-lambda/example.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/aws/aws-lambda-go/events"
8+
"github.com/aws/aws-lambda-go/lambda"
9+
)
10+
11+
func handler(ctx context.Context, snsEvent events.SNSEvent) {
12+
for _, record := range snsEvent.Records {
13+
processMessage(record)
14+
}
15+
fmt.Println("done")
16+
}
17+
18+
func processMessage(record events.SNSEventRecord) {
19+
message := record.SNS.Message
20+
fmt.Printf("Processed message: %s\n", message)
21+
// TODO: Process your record here
22+
}
23+
24+
func main() {
25+
lambda.Start(handler)
26+
}

integration-sns-to-lambda/snippet-data.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@
5353
}
5454
]
5555
},
56+
{
57+
"id": "Go",
58+
"title": "Usage Example with Go:",
59+
"description": "Consuming an SNS event with Lambda using Go.",
60+
"snippets": [
61+
{
62+
"snippetPath": "example.go",
63+
"language": "go"
64+
}
65+
]
66+
},
5667
{
5768
"id": "Python",
5869
"title": "Usage Example with Python:",

0 commit comments

Comments
 (0)