Skip to content

Instantly share code, notes, and snippets.

@AwsGeek
AwsGeek / bucket.json
Created December 23, 2018 20:17
Setting up a Static Website on S3
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::www.aws-today.com/*"]
}]
}
@AwsGeek
AwsGeek / handler.py
Last active January 10, 2021 18:45
Parse S3 logs and send to Google Analytics using the Google Analytics Measurement Protocol
from __future__ import print_function
import re
import urllib
import boto3
from botocore.vendored import requests
s3 = boto3.client('s3')
pattern = re.compile(r'(?P<owner>\S+) (?P<bucket>\S+) \[(?P<time>.*)\] (?P<ip>\S+) (?P<requester>\S+) (?P<reqid>\S+) (?P<operation>\S+) (?P<key>\S+) (?P<request>"[^"]*") (?P<status>\S+) (?P<error>\S+) (?P<bytes>\S+) (?P<size>\S+) (?P<totaltime>\S+) (?P<turnaround>\S+) (?P<referrer>"[^"]*") (?P<useragent>"[^"]*") (?P<version>\S)')
@AwsGeek
AwsGeek / index.html
Last active June 1, 2021 15:28
AWS Price List API Sample
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AWS Price List API</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<style>
body { font-size: 62.5%; }