Skip to content

Instantly share code, notes, and snippets.

@UriBer
UriBer / main.py
Created April 30, 2026 15:35
Simple Lambda that gets displays the value from test json
def lambda_handler(event, context):
print(json.dumps(event))
return {
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": json.dumps({
"message": "Hello from Lambda",
@UriBer
UriBer / aws-lambda-hello.py
Last active April 30, 2026 09:16
Python AWS Lambda Function URL example that returns JSON and safely handles query string parameters.
import json
print("Loading function")
def lambda_handler(event, context):
print(json.dumps(event, indent=2))
return {
"statusCode": 200,
"headers": {
{
"name": "aws-course-demo",
"description": "aws course material for my students",
"version": "0.0.1",
"private": true,
"dependencies": {
"aws-sdk": "^2.683.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "4.16.2",
var port = process.env.PORT || 8080;
var express = require('express')
var cors = require('cors')
var app = express()
var AWS = require("aws-sdk");
var bodyParser = require('body-parser');
AWS.config.update({
"region": "us-east-2",
"accessKeyId": "",
var port = process.env.PORT || 8080;
var express = require('express')
var cors = require('cors')
var app = express()
var AWS = require("aws-sdk");
AWS.config.update({
"region": "",
"accessKeyId": "",
"secretAccessKey": ""
var port = process.env.PORT || 8080;
var express = require('express')
var cors = require('cors')
var app = express()
app.use(cors())
var obj = [{"id":11, "title":"hello", "body":"world"}]
@UriBer
UriBer / aws s3 policy
Created June 11, 2019 17:12
s3 bucket policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::myapp/*"
}
@UriBer
UriBer / gist:41e9705753e993f82bc2763a4f6bc10e
Created April 29, 2018 13:27
get list of items (full table scan)
@application.route('/bi/', methods=['GET'])
def get():
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
table = dynamodb.Table('eb_logger_log')
# replace table scan
resp = table.scan()
# print(str(resp))
items = resp['Items']
for item in items:
print(item['path'])
@UriBer
UriBer / gist:a49c116637f0deb5921abaa38a2f326c
Created April 29, 2018 13:23
save ip metadata to dynamodb
@application.route('/log/<path>', methods=['GET'])
def get_temp(temp):
# get ip metadata
response = get_ip_meta()
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
table = dynamodb.Table('eb_logger_log')
res_data = {k: v for k, v in response.items() if v!=''}
print(res_data)
item={
'path': temp,
import requests
import json
def get_ip_meta():
user_ip = str(request.environ['REMOTE_ADDR'])
service_url = 'ipinfo.io/{}'.format(user_ip)
return requests.get(service_url).json()