Skip to content

Instantly share code, notes, and snippets.

@erupare
erupare / boto3-gzip.py
Created May 7, 2021 10:45 — forked from tobywf/boto3-gzip.py
GZIP compressing files for S3 uploads with boto3
from io import BytesIO
import gzip
import shutil
def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'):
"""Compress and upload the contents from fp to S3.
If compressed_fp is None, the compression is performed in memory.
"""
### Option 1 - Terraform can generate SSL/SSH private keys using the tls_private_key resource
variable "key_name" {}
resource "tls_private_key" "example" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "aws_key_pair" "generated_key" {
@erupare
erupare / example.tf
Created May 4, 2020 00:55 — forked from bougyman/example.tf
Iterating over selected subnets in terraform (for spreading instances across subnets/azs)
# First find the vpc
data "aws_vpc" "admin" {
filter {
name = "tag:Name"
values = ["vpc-admin_svcs-${local.short_region}*-${local.dns_zone}"]
}
}
# This will expand to all subnets in the vpc which match the filter, but they will be returned in
# no particular order.
# This policy uses the tfstate import to restrict ACM certificates
# to have domains that are sub-domains of hashidemos.io
# Import the v2 tfstate import, but use the alias "tfstate"
import "tfstate/v2" as tfstate
# Import common-functions/tfstate-functions.sentinel with alias "state"
import "tfstate-functions" as state
# Get all AWS ACM certs
@erupare
erupare / list.txt
Created March 1, 2020 23:23 — forked from shortjared/list.txt
List of AWS Service Principals
acm.amazonaws.com
alexa-appkit.amazon.com
apigateway.amazonaws.com
application-autoscaling.amazonaws.com
appstream.application-autoscaling.amazonaws.com
appsync.amazonaws.com
athena.amazonaws.com
autoscaling.amazonaws.com
batch.amazonaws.com
channels.lex.amazonaws.com
#!/usr/bin/env python
import twitter
import boto3
import os
keyword = 'dev.classmethod.jp'
region = 'us-east-1'
size = 10 * 100
#!/usr/bin/env python
import twitter
import boto3
import os
keyword = '#reinvent'
lang = 'en'
region = 'us-east-1'
size = 100 * 100
@erupare
erupare / request_amazon_es.py
Created January 17, 2020 09:37 — forked from s-fujimoto/request_amazon_es.py
request to amazon es controled iam policy
#!/usr/bin/env python
from boto.connection import AWSAuthConnection
import requests
import json
import sys
def main():
host = sys.argv[1]
@erupare
erupare / pipeline.gdsl
Created November 23, 2019 14:56 — forked from ggarcia24/pipeline.gdsl
GDSL supporting pipeline declarative
//The global script scope
def ctx = context(scope: scriptScope())
//What things can be on the script scope
contributor(ctx) {
method(name: 'pipeline', type: 'Object', params: [body: Closure])
property(name: 'params', type: 'org.jenkinsci.plugins.workflow.cps.ParamsVariable')
property(name: 'env', type: 'org.jenkinsci.plugins.workflow.cps.EnvActionImpl.Binder')
property(name: 'currentBuild', type: 'org.jenkinsci.plugins.workflow.cps.RunWrapperBinder')
property(name: 'scm', type: 'org.jenkinsci.plugins.workflow.multibranch.SCMVar')