Skip to content

Instantly share code, notes, and snippets.

View jojees's full-sized avatar

Joji Vithayathil Johny jojees

View GitHub Profile
@jojees
jojees / all_aws_managed_policies.json
Created January 15, 2019 06:57 — forked from gene1wood/all_aws_managed_policies.json
A list of all AWS managed policies and they're policy documents as well as a short script to generate the list
{
"APIGatewayServiceRolePolicy": {
"Arn": "arn:aws:iam::aws:policy/aws-service-role/APIGatewayServiceRolePolicy",
"AttachmentCount": 1,
"CreateDate": "2018-08-10T17:57:44+00:00",
"DefaultVersionId": "v3",
"Document": {
"Statement": [
{
"Action": [
@jojees
jojees / role_arn_to_session.py
Created January 7, 2019 17:45 — 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')
"""
@jojees
jojees / lambda-codecommit-trigger-codebuild.py
Created June 2, 2018 12:17 — forked from FlorinAsavoaie/lambda-codecommit-trigger-codebuild.py
AWS Lambda functions that you can set to be triggered by Codecommit push triggers and it will trigger builds on any CodeBuild Project that has this repository as source.
import boto3
codecommit = boto3.client('codecommit')
codebuild = boto3.client('codebuild')
def trigger_build(project, commit, branch):
codebuild.start_build(projectName=project, sourceVersion=commit,
environmentVariablesOverride=[
{ 'name': 'ENVIRONMENT', 'value': branch, 'type': 'PLAINTEXT' }
])
@jojees
jojees / worker_function.py
Created May 27, 2018 12:50 — forked from dnmellen/worker_function.py
AWS Lambda function that performs an ssh command through a bastion server to another server. The function will be triggered by a Cloudwatch Alarm
import json
import boto3
import paramiko
def worker_handler(event, context):
ALLOWED_HOSTS = [
'host1',
'host2,
---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Create a Lambda function that will take a comma seperated list of key=value pairs and return an array of key value pairs that can then be used in cloudformation tags resource parameter"
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

Here's the canonical TOML example from the TOML README, and a YAML version of the same. Which looks nicer?

title = "TOML Example"

[owner] name = "Tom Preston-Werner"

@jojees
jojees / dict.py
Created May 15, 2018 09:18 — forked from eproxus/dict.py
Ansible dict map helper
"""Ansible dict filters."""
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.errors import AnsibleError
@jojees
jojees / ansible-summary.md
Created May 15, 2018 09:17 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

@jojees
jojees / find_iam_user.py
Created March 6, 2018 12:36 — forked from OnlyInAmerica/find_iam_user.py
Find an AWS IAM user corresponding to an AWS Access Key
# Find the IAM username belonging to the TARGET_ACCESS_KEY
# Useful for finding IAM user corresponding to a compromised AWS credential
# Requirements:
#
# Environmental variables:
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# python:
# boto
@jojees
jojees / tmux-cheatsheet.markdown
Created August 6, 2017 13:04 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname