Skip to content

Instantly share code, notes, and snippets.

@bkruger99
bkruger99 / ec2.py
Created August 24, 2016 18:42 — forked from iMilnb/ec2.py
AWS EC2 simple manipulation script using python and boto3
#!/usr/bin/env python
# Simple [boto3](https://github.com/boto/boto3) based EC2 manipulation tool
#
# To start an instance, create a yaml file with the following format:
#
# frankfurt:
# - subnet-azb:
# - type: t2.micro
# image: image-tagname
@bkruger99
bkruger99 / __init__.py
Created August 24, 2016 18:42 — forked from aubricus/__init__.py
Using Fabric to connect to the remote server via an ssh config.
from fabric.api import env
env.use_ssh_config = True
env.forward_agent = True
env.roledefs = {
# key # hostname from config
'foo': ['foo.production'],
}
@bkruger99
bkruger99 / get_account_id_lambda.py
Created September 15, 2016 20:16 — forked from gene1wood/01_get_account_id_for_user_ec2instance_role_or_lambda.py
Method to determine your AWS account ID using boto3 for either a user or an ec2 instance or lambda function
def get_account_id(context):
return context.invoked_function_arn.split(':')[4]
def lambda_handler(event, context):
print("My account ID is %s" % get_account_id(context))
@bkruger99
bkruger99 / highstate_magic.py
Created September 23, 2016 21:23 — forked from syphernl/highstate_magic.py
Saltstack MasterMinion show_highstate attempt
# -*- coding: utf-8 -*-
'''
Functions to interact with the state compiler on the master
'''
from __future__ import absolute_import
import pprint
# Import salt libs
import salt.utils.minion
@bkruger99
bkruger99 / gist:4f9ab0f5a8e3aaf4aff0e506b8c3d81e
Created October 11, 2016 01:22
aws SQS Sender ID attribute
What I notice from SQS SenderID attributes so far:
Autoscale Group SNS:
AIDAIT2UOQQY3AUEKVGXU
Lambda SQS Message:
AROAIL6GAI2XEC672SWG2:awslambda_39_20161007224708400
EC2 SQS Message
AROAIL6GAI2XEC672SWG2:i-12345678901234567 (known as the instance id that sent the message, but no account number if cross account)
@bkruger99
bkruger99 / role_arn_to_session.py
Created December 30, 2016 03:08 — forked from gene1wood/role_arn_to_session.py
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@bkruger99
bkruger99 / README.rst
Created January 17, 2017 19:45 — forked from PatOShea/README.rst
SaltStack Bootstrap for AWS EC2

SaltStack Bootstrap Script for AWS EC2

This script will currently only work with Windows8, Windows 2012R2, Amazon Linux, RHEL6 and RHEL7.

@bkruger99
bkruger99 / 0-STATE-RUN-SALT-API-GITHUB-HOOK-USE-CASE.md
Created February 28, 2017 19:52 — forked from Teino1978-Corp/0-STATE-RUN-SALT-API-GITHUB-HOOK-USE-CASE.md
State runner on salt-api POST from GitHub push hook

Validate and run a state when a valid GitHub hook call has been received from salt-api

Idea is that we can setup salt-api to receive hook call from GitHub, and configured run stat.sls only if the request HMAC signature matche is successful.

Unfortunately most documentation says to deactivate salt-api hooks authentication (i.e. webhook_disable_auth: True) which is not a good idea.

This Gist is about finding a way to declare which state to run based on data GitHub sends on push hook. But ONLY if the request is valid.

Skeleton defines desired logic, see reactor_github_push.py below.

@bkruger99
bkruger99 / README.md
Created March 10, 2017 21:46 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.

For more about AWS and AWS Certifications and updates to this Gist you should follow me @leonardofed