Skip to content

Instantly share code, notes, and snippets.

View evankozliner's full-sized avatar

Evan Kozliner evankozliner

View GitHub Profile
@evankozliner
evankozliner / other_file.py
Last active November 14, 2020 18:26
example 2 gist
import re
import argparse
import requests
def main():
args = parse_args()
gist_id = find_id(args.url, args.follow_redirects)
print(f"Found gist ID {gist_id}")
gist_api_adaptor = GistAPIAdaptor(gist_id)
@evankozliner
evankozliner / result.sh
Created November 8, 2020 23:21
result.sh
# Finally: Run our copy!
aws s3 cp s3://source s3://destination --recursive --profile porter
copy: s3://source/1.txt to s3://destination/1.txt
copy: s3://source/2.txt to s3://destination/2.txt
...
@evankozliner
evankozliner / credentials
Created November 8, 2020 23:18
~/.aws/credentials
[source-admin]
aws_access_key_id = some-access-id
aws_secret_access_key = some-secret
[destination-admin]
aws_access_key_id = some-access-id-2
aws_secret_access_key = some-secret-2
[porter]
aws_access_key_id = access-key-id
@evankozliner
evankozliner / tutorial-setup-1.sh
Created November 8, 2020 23:16
Tutorial part 1
# Set up our source and destination buckets
% aws kms create-key --profile destination-admin
...
"KeyId": "destination-key-id",
...
% aws kms create-key --profile source-admin --policy file://source-encryption-key.json
...
"KeyId": "source-key-id",
...
% aws s3 mb s3://destination --profile destination-admin
@evankozliner
evankozliner / source-encryption-key-policy.json
Created November 2, 2020 02:00
Source encryption key resource policy
{
"Version": "2012-10-17",
"Id": "key-default-1",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::source-account-id:root"
},
@evankozliner
evankozliner / source-bucket-policy.json
Created November 2, 2020 01:56
Bucket resource policy for source account bucket
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::destination-account:role/S3Porter"
},
"Action": [
"s3:GetObject",
@evankozliner
evankozliner / destination-key.json
Created November 2, 2020 01:36
Destination key resource policy
{
"Version": "2012-10-17",
"Id": "key-default-1",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::destination-account-id:root"
},
@evankozliner
evankozliner / S3PorterPolicy.json
Last active November 8, 2020 16:31
S3Porter identity policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3CopyFromSource",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
@evankozliner
evankozliner / example-resource-policy.json
Last active October 19, 2020 13:50
example-resource-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowEC2",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:CreateUser"
],