This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import boto3 | |
import pytz | |
from datetime import datetime | |
from dateutil.relativedelta import relativedelta | |
print('Loading function') | |
def lambda_handler(event, context): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import logging | |
#setup simple logging for INFO | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
#define the connection | |
ec2 = boto3.resource('ec2') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import boto3 | |
def main(argv): | |
ec2 = boto3.resource('ec2') | |
instances = ec2.instances.all() | |
elb = boto3.client('elb') | |
autoscaling = boto3.client('autoscaling') | |
auto_scaling_groups = autoscaling.describe_auto_scaling_groups()['AutoScalingGroups'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'sdk/sdk.class.php'; | |
$hosts = array( | |
'linux' => array('id' => 'i-123ee456', 'ip' => '1.2.3.4'), | |
'windows' => array('id' => 'i-123ee457', 'ip' => '1.2.3.5'), | |
); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import datetime | |
def lambda_handler(event, context): | |
print("Connecting to RDS") | |
client = boto3.client('rds') | |
print("RDS snapshot backups stated at %s...\n" % datetime.datetime.now()) | |
client.create_db_snapshot( | |
DBInstanceIdentifier='web-platform-slave', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Nicked from http://blog.ranman.org/cleaning-up-aws-with-boto3/ | |
import boto3 | |
from datetime import datetime, timedelta | |
region = "eu-west-1" | |
cloudwatch = boto3.client("cloudwatch", region_name=region) | |
today = datetime.now() + timedelta(days=1) # today + 1 because we want all of today | |
two_weeks = timedelta(days=14) | |
start_date = today - two_weeks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import urllib, urllib2 | |
SLACK_URL = 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX' | |
ICON = { | |
"cloudwatch": { | |
"OK": ":cloudwatch:", | |
"ALARM": ":alarm:", | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('[Amazon CloudWatch Notification]'); | |
/* | |
configuration for each condition. | |
add any conditions here | |
http://docs.aws.amazon.com/macie/latest/userguide/macie-alerts.html | |
*/ | |
var ALARM_CONFIG = [ | |
{ | |
condition: "INFORMATIONAL", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boto.ec2.cloudwatch import CloudWatchConnection | |
from boto.sqs.connection import SQSConnection | |
import boto | |
import sys | |
from datetime import datetime, timedelta | |
import locale | |
from time import sleep | |
if(len(sys.argv) > 1): | |
queue_name = sys.argv[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk'); | |
var cloudwatch = new AWS.CloudWatch({ region: 'us-east-1'}); | |
exports.handler = function (event, context) { | |
var ElasticSearchHost = 'elasticsearch.example:9200'; | |
var Environment = 'int'; | |
var EndTime = new Date; | |
var StartTime = new Date(EndTime - 15*60*1000); | |
var Metrics = { |