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 | |
# -*- coding: utf-8 -*- | |
''' | |
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". |
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 boto3 | |
""" | |
Generic AWS Helper call class to setup a boto3 Session. Now with assume role support. | |
Pass in 'type=' to do either 'client' or 'resource' | |
usage: |
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 python3 | |
import boto3 | |
import json | |
central_logging = '<insert your central logging account id here>' | |
# Variables for the grafana monitoring server | |
role_name = 'monitoring_prodcloudwatch_access_role' | |
policy_arn = 'arn:aws:iam::<insert your central logging account id here>:policy/monitor-assumerole' |
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 | |
boto3.setup_default_session(profile_name='IAM') | |
resource = boto3.resource('iam') | |
client = boto3.client("iam") | |
KEY = 'LastUsedDate' | |
for user in resource.users.all(): |
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 django.http import HttpResponse | |
from django.views.decorators.csrf import csrf_exempt | |
import requests, json | |
# Get an OAuth token from https://www.eventbrite.com/myaccount/apps/ | |
# Create a new app, then expand the expandy-thingy and copy out the | |
# 'Your personal OAuth token' value. | |
EVENTBRITE_OAUTH_TOKEN = '...' | |
# Should look something like https://yoursite.slack.com/services/hooks/incoming-webhook?token=xxx...xxx |
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
# urls.py | |
from django.conf.urls import url | |
from main import views | |
urlpatterns = [ | |
url(r'^oauthcallback/', views.oauthcallback) | |
] | |
# models.py | |
from django.db import models |
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
# -*- coding: utf-8 -*- | |
# /var/runtime/awslambda/bootstrap.py | |
""" | |
aws_lambda.bootstrap.py | |
Amazon Lambda | |
Copyright (c) 2013 Amazon. All rights reserved. | |
Lambda runtime implemention | |
""" |
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 argparse | |
import boto3 | |
import datetime | |
from dateutil.tz import tzutc | |
def is_in_autoscale_group(region, instance_id): | |
asg = boto3.client('autoscaling', region_name=region) | |
instances = \ | |
asg.describe_auto_scaling_instances(InstanceIds=[instance_id]) |
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
# Copyright (C) 2014 Cloudablity | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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 aiohttp | |
import asyncio | |
import logging | |
class SlackAPIError(Exception): pass | |
class Slack(object): | |
""" |