This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def lambda_handler(event, context): | |
| print(json.dumps(event)) | |
| return { | |
| "statusCode": 200, | |
| "headers": { | |
| "Content-Type": "application/json" | |
| }, | |
| "body": json.dumps({ | |
| "message": "Hello from Lambda", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| print("Loading function") | |
| def lambda_handler(event, context): | |
| print(json.dumps(event, indent=2)) | |
| return { | |
| "statusCode": 200, | |
| "headers": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"}] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "PublicReadForGetBucketObjects", | |
| "Effect": "Allow", | |
| "Principal": "*", | |
| "Action": "s3:GetObject", | |
| "Resource": "arn:aws:s3:::myapp/*" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
NewerOlder