Skip to content

Instantly share code, notes, and snippets.

@vvalorous
vvalorous / cognito.yaml
Created March 29, 2018 06:40 — forked from singledigit/cognito.yaml
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
@vvalorous
vvalorous / slack_result.py
Created March 31, 2018 01:45
slack in python - message fields example
#!/usr/bin/env python
import slackweb
import argparse
def notify():
parser = argparse.ArgumentParser(description='slack notification script')
parser.add_argument('--webhook_url', help='incoming webhook url', required=True)
parser.add_argument('--verdict', help='pass or fail', default='pass')
@vvalorous
vvalorous / slack.py
Created March 31, 2018 01:46 — forked from zackferrofields/slack.py
AWS CodeDeploy trigger Lambda Slack message
'''
Follow these steps to configure the webhook in Slack:
1. Navigate to https://<your-team-domain>.slack.com/services/new
2. Search for and select "Incoming WebHooks".
3. Choose the default channel where messages will be sent and click "Add Incoming WebHooks Integration".
4. Copy the webhook URL from the setup instructions and use it in the next section.
@vvalorous
vvalorous / evaluate_vpc_flow_logs_enabled_for_aws_config.py
Created March 31, 2018 01:52 — forked from okochang/evaluate_vpc_flow_logs_enabled_for_aws_config.py
Sample rule for AWS Config Rules that evaluate vpc flow logs enabled or disabled
import boto3
import datetime
import json
config = boto3.client("config")
ec2 = boto3.client("ec2")
def evaluate_flowlog(vpc_id):
response = ec2.describe_flow_logs(
Filter=[
@vvalorous
vvalorous / EBS-Orphaned-Report-Lambda.py
Created March 31, 2018 05:21 — forked from mlapida/EBS-Orphaned-Report-Lambda.py
Generate a report of orphaned EBS volumes and send an SNS. A full writeup can be found on my site http://mlapida.com/thoughts/lambda-tracking-orphaned-ebs-volumes
import boto3
import logging
from datetime import *
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
#define the connection
ec2 = boto3.resource('ec2', region_name="us-west-2")
@vvalorous
vvalorous / aws_tag_audit.py
Created April 2, 2018 06:30 — forked from nskitch/aws_tag_audit.py
aws tag audit NON_COMPLIANT_TAGGING
#!/usr/bin/env python
#
# Author: Nick Skitch
# For Tagging Compliance.
prog_desc = "Evaluation of AWS EC2 instances for tag compliance. If dryrun false, will add non_compliant_tag key tag with value \
of missing required tags. WIP."
import boto3
import json
import argparse
@vvalorous
vvalorous / example-lambda.py
Created April 4, 2018 04:17 — forked from johnaxel/example-lambda.py
Example Lambda to illustrate concepts in lambda blog post
import hashlib
import boto3
import time
## CONFIG ##
BUCKET = 'bucket-name'
FILEPATH = 'hashes'
SEP = '\t'
def log(metric_name, metric_type='count', metric_value=1, tags=[]):
@vvalorous
vvalorous / slack_slash_cmd.py
Created April 6, 2018 01:31 — forked from devStepsize/slack_slash_cmd.py
Server-side logic to handle a Slack slash command using Python and Flask
'''
This is an example of the server-side logic to handle slash commands in
Python with Flask.
Detailed documentation of Slack slash commands:
https://api.slack.com/slash-commands
Slash commands style guide:
https://medium.com/slack-developer-blog/slash-commands-style-guide-4e91272aa43a#.6zmti394c
'''
@vvalorous
vvalorous / ecs-run
Created April 7, 2018 19:51 — forked from vcastellm/ecs-run
Run task and wait for result in AWS ECS
#!/usr/bin/env bash
set -e
function usage() {
set -e
cat <<EOM
##### ecs-run #####
Simple script for running tasks on Amazon Elastic Container Service
One of the following is required:
Required arguments:
@vvalorous
vvalorous / amazonctl.py
Created April 7, 2018 21:06 — forked from jtpaasch/amazonctl.py
A collection of functions commonly used to do AWS stuff.
# -*- coding: utf-8 -*-
"""A simple tool to document how to control AWS resources.
AWS AUTHENTICATION
-------------------
In order to run any of the code below, you need a profile with AWS credentials
set up on your computer. It's very easy to do this. Google how to configure
your profile with boto3, or visit the docs: