Skip to content

Instantly share code, notes, and snippets.

__author__ = 'ahmed'
import boto3, argparse, yaml
from time import sleep
import os.path
def tag_instances(awsTags):
reservations = ec2Client.describe_instances()
import boto3
import json
import logging
import time
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def notify_on_error(message):
import boto3
import json
import urllib, urllib2
import os
from datetime import datetime
from dateutil import tz
import time
ecs = boto3.client('ecs')
sns = boto3.client('sns')
@vvalorous
vvalorous / deployment.py
Created March 26, 2018 06:08 — forked from spandanb/deployment.py
Boto3 ECS
#Original Author https://raw.githubusercontent.com/kgoedecke/python-ecs-example/master/python_ecs_example/deployment.py
import boto3
import pprint
import os
# Credentials & Region
access_key = os.environ["AWS_ACCESS_KEY_ID"]
secret_key = os.environ["AWS_SECRET_ACCESS_KEY"]
region = "us-east-1"
@vvalorous
vvalorous / slack-pagerduty-oncall.py
Created March 26, 2018 23:14 — forked from devdazed/slack-pagerduty-oncall.py
Updates a Slack User Group with People that are on call in PagerDuty
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
from urllib2 import Request, urlopen, URLError, HTTPError
from base64 import b64decode
@vvalorous
vvalorous / ri-audit.py
Created March 26, 2018 23:15 — forked from devdazed/ri-audit.py
EC2 Reserved Instance auditing
import boto.ec2
def get_running_instances(region):
ec2 = boto.ec2.connect_to_region(region)
instances = [i for r in ec2.get_all_reservations() for i in r.instances]
return filter(lambda i: i.state == 'running', instances)
def get_reserved_instances(region):
ec2 = boto.ec2.connect_to_region(region)
reserved_instances = ec2.get_all_reserved_instances()
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
import re
from base64 import b64decode, b64encode
from urllib2 import Request, urlopen, URLError, HTTPError
@vvalorous
vvalorous / slack-blink1.py
Created March 26, 2018 23:36 — forked from jnth/slack-blink1.py
Interaction between Slack and Blink1.
#!/usr/bin/env python3.6
# coding: utf-8
"""Interaction between Slack and Blink1.
Use the Slack Real Time Messaging API to analyze message and turn on the
Blink1 device.
Based on this great blog article :
https://www.fullstackpython.com/blog/build-first-slack-bot-python.html
@vvalorous
vvalorous / slack_deploy_bot_template.py
Created March 27, 2018 06:29 — forked from achauve/slack_deploy_bot_template.py
Template of Slack bot for deployment
import logging
import os
import time
import traceback
# pip install slackclient
from slackclient import SlackClient