Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
)
type Doit struct {
count int64
}
@eldondevcg
eldondevcg / docker-compose.yml
Created May 3, 2017 19:24
Add ssh access to a wordpress docker-compose setup.
version: '2'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
@eldondevcg
eldondevcg / create.sql
Created January 25, 2017 21:53
Breaking out the data from bucket logs for Amazon Athena
CREATE EXTERNAL TABLE default.bucket_logs (
`bucketowner` string,
`bucket` string,
`datetime` string,
`sourceip` string,
`requestor_id` string,
`request_id` string,
`operation` string,
`key` string,
`http_line` string,
@eldondevcg
eldondevcg / README.md
Last active November 18, 2020 10:31
Cross account bucket access for IAM roles

For: https://www.reddit.com/r/aws/comments/5jf7fb/permissions_for_lambda_accessing_s3_buckets_in/

This is a little tricky, because it requires several different moving parts, specifically,

  • the lambda task that you want to execute the copy must have IAM access to the bucket in the other account. This is not something that was obvious to me to begin with, although my use case was more complicated.
  • the bucket policy on the destination account must be set to permit your lambda function to write to that bucket. For my special use cases, I have to upload a new bucket policy daily to the receiving buckets. Alternatively, the destination accounts could probably give your a cross-account IAM role to upload the bucket policy yourself.
  • You will likely want to write your objects with the bucket-owner-full-control acl, http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html otherwise, the bucket owner may not be able to download them.
@eldondevcg
eldondevcg / THOUGHTS.md
Last active December 15, 2016 16:36
Things you should be able to do in AWS
  • Cloud watch should have alerts for the total number of instances running in an Autoscaling group Available when you enable "group metrics"
  • You should be able to get an SNS alert when an ec2 instance is terminated, and the reason (price for spot requests, ASG, etc)
  • Spot instance requests have a frustrating filter interface. There isn't reasonable faceting like there is in the instances console.
  • It should be possible to edit launch configurations
  • It should be possible to view the per-hour price of an on-demand, reserved, or scheduled instance you launch in the reservation
@eldondevcg
eldondevcg / THOUGHTS.md
Last active January 24, 2017 18:01
Amazon Best Practices ideas

Ideas on amazon best practices

  • All instances should have IAM roles
  • All non-ephemeral instances should have elastic IP addresses
    • Ephemeral instances are instances in autoscaling groups and spot instances
  • All buckets should have bucket logging enabled.
  • All destinations for bucket logs should only store bucket logs.
  • All destinations for bucket logs should have bucket lifecycles enabled
  • Netflix ICE should be running.
  • All instances should be running in VPC.
@eldondevcg
eldondevcg / get_cloudwatch_logs.py
Last active January 13, 2023 21:11
Pull down cloudwatch logs with boto
# IF YOU INCUR HUGE COSTS WITH THIS OR IT BREAKS DON'T BLAME ME License
# This is a throw-away script I wrote to pull the json events for all of the streams from a cloudwatch log
# For some reason, the naive way to do vpc network logging does logging to different streams in a cloudwatch
# log based on interface.
# Great for diagnosing lots of things, and generating verbose logs, but for the broad-stroke analysis I was doing,
# all I really wanted was the basic data. This would have been easier if I had logged to s3, but I did not see a
# way to do that in 2 clicks.
group_name = 'CHANGEME'
@eldondevcg
eldondevcg / Vagrantfile
Last active August 29, 2015 14:22
A vagrantfile which gets the latest go source (required by goxc), builds it, installs goxc, godep, and docker from the docker debian repo
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
config.vm.provision "shell", privileged: false, inline: <<-SHELL
sudo apt-get update
@eldondevcg
eldondevcg / Vagrantfile
Last active August 29, 2015 14:21
A vagrantfile to upgrade the vbox additions
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
config.vm.provision "shell", inline: <<-SHELL
set -e
sudo apt-get install -y dkms wget linux-headers-`uname -r`
wget http://dlc-cdn.sun.com/virtualbox/4.3.28/VBoxGuestAdditions_4.3.28.iso