Skip to content

Instantly share code, notes, and snippets.

@hoegertn
hoegertn / init.py
Created September 14, 2020 09:04
CDK bootstrap helper
import json
import inquirer
import boto3
import os
import sys
import subprocess
def select_account():
@miztiik
miztiik / .gitignore
Created February 13, 2020 23:17
Sample .gitignore file for AWS CDK Python projects
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
import psycopg2
# Functions for reading scripts
class ScriptReader(object):
@staticmethod
def get_script(path):
return open(path, 'r').read()
# Utils for messages
@sjakthol
sjakthol / s3_list_objects_parallel.py
Created January 11, 2019 20:20
Python code snippet for listing bucket objects in parallel.
#!/usr/bin/env python3
"""List S3 bucket objects in parallel.
This module contains a parallel implementation of S3 list_objects_v2()
API call. The implementation lists objects under every distinct prefix
in parallel. Hence, a speedup is achieved if objects are spread under
multiple distinct prefixes.
"""
import argparse
@Swalloow
Swalloow / dynamo_delete_all.py
Created May 18, 2018 06:38
Boto3 DynamoDB delete all items
import boto3
dynamodb = boto3.resource('dynamodb', 'region-name')
table = dynamodb.Table('table-name')
scan = table.scan(
ProjectionExpression='#k',
ExpressionAttributeNames={
'#k': 'name'
}
@quiver
quiver / athena.py
Last active August 19, 2022 11:19
query SQL to Amazon Athena and save its results from Amazon S3 Raw
#!/usr/bin/env python
# vim: set fileencoding=utf8 :
```
$ pip install -U boto3 retrying
$ export AWS_DEFAULT_PROFILE=test
$ cat foo.sql
select count(*)
from bar
$ python athena.py foo.sql
$ ls -1
@mojodna
mojodna / 0_register_planet.sql
Last active May 18, 2022 17:51
Sample OSM Athena queries
--
-- This will register the "planet" table within your AWS account
--
CREATE EXTERNAL TABLE planet (
id BIGINT,
type STRING,
tags MAP<STRING,STRING>,
lat DECIMAL(9,7),
lon DECIMAL(10,7),
nds ARRAY<STRUCT<ref: BIGINT>>,