Skip to content

Instantly share code, notes, and snippets.

View aodj's full-sized avatar
⌨️

Alexander O'Donovan-Jones aodj

⌨️
  • Reykjavik, Iceland
View GitHub Profile
locals {
chunks = "${chunklist(local.whitelist, 5)}"
rules = [
{ action = "allow", priority = "0", match = { versioned_expr = "SRC_IPS_V1", config = { src_ip_ranges = ["${local.chunks[0]}"] }}},
{ action = "deny(403)", priority = "2147483647", match = { versioned_expr = "SRC_IPS_V1", config = { src_ip_ranges = ["*"] }}, description = "Default rule: deny all"}
]
}
resource "google_compute_security_policy" "policy" {
project = "${var.project}"
@aodj
aodj / main.tf
Created March 23, 2020 10:54
Using chunklist in TF11
variable "ips" {
default = [
"1.1.1.1/32",
"2.2.2.2/32",
"3.3.3.3/32",
"4.4.4.4/32",
"5.5.5.5/32",
"6.6.6.6/32",
"7.7.7.7/32",
"8.8.8.8/29",
@aodj
aodj / azure-ne-we-ip-ranges.json
Created February 13, 2020 15:09
addressPrefixes for North and West Europe for Azure
[
"104.214.192.0/18",
"104.214.231.110/32",
"104.214.236.47/32",
"104.214.237.135/32",
"104.214.243.32/28",
"104.40.128.0/17",
"104.40.129.89/32",
"104.40.147.180/32",
"104.40.147.216/32",
@aodj
aodj / .bashrc
Created October 23, 2019 16:13
pyenv scratch commands
init_scratch_dir () {
pushd ~/Documents/scratch
echo scratch-3.7.2 >> .python-version
pyenv virtualenv 3.7.2 scratch-3.7.2
popd
}
scratch () {
pushd ~/Documents/scratch
}
from scrapy.pipelines.files import FilesPipeline, S3FilesStore, FSFilesStore
class S3FilesStore_V4(S3FilesStore):
AWS_ACCESS_KEY_ID = None
AWS_SECRET_ACCESS_KEY = None
AWS_DEFAULT_REGION = None
def __init__(self, uri):
super(S3FilesStore_V4, self).__init__(uri)
@aodj
aodj / bosun.conf
Last active November 6, 2015 15:59
Sending Twilio SMS alerts from Bosun
notification sms {
post = https://{AccountSid}:{Authtoken}@api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json
body = Body={{.}}&To={ToPhoneNumber}&From={FromPhoneNumber}
}
{
"size": 0,
"query": {
"filtered": {
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "_type:logs"
}
},
@aodj
aodj / ec2metadata.toml
Created August 10, 2015 14:03
Example Heka configuration to get some metadata items from the `ec2metadata` tool
[ec2_metadata]
type = "ProcessInput"
ticker_interval = 10
decoder = "ec2_metadata_decoder"
[ec2_metadata.command.0]
bin = "/usr/bin/ec2metadata"
args = ["--ami-id", "--instance-id", "--instance-type", "--local-ipv4"]
[ec2_metadata_decoder]
#!/bin/sh
tar xvzf virtualenv-1.11.6.tar.gz
cd virtualenv-1.11.6
sudo python virtualenv.py ../$1
cd ..
# activate the virtualenv, install the requirements
source $1/bin/activate
sudo pip install -r mac_requirements.txt
@aodj
aodj / create_virtualenv.sh
Last active August 29, 2015 14:05
step #2
#!/bin/sh
tar xvzf virtualenv-1.11.6.tar.gz
cd virtualenv-1.11.6
sudo python virtualenv.py ../$1
cd ..
source $1/bin/activate
sudo pip install -r mac_requirements.txt
rm -rf virtualenv-1.11.6
deactivate