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 | |
from __future__ import print_function | |
import boto3 | |
print('Loading function') | |
#set region | |
REGION = 'us-west-2' | |
#set the SNS topic ARN you want to alert on | |
SNS_TOPIC_ARN = 'arn:aws:sns:REGION:ACCOUNT_ID:TOPIC_NAME' |
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 | |
from pprint import pprint | |
client = boto3.client('ec2',region_name='us-west-2') | |
interfaces = client.describe_network_interfaces() | |
sgs_in_use = [] | |
for interface in interfaces['NetworkInterfaces']: | |
for group in interface['Groups']: | |
if group['GroupId'] not in sgs_in_use: |
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 json | |
import base64 | |
import gzip | |
import re | |
import sys | |
import boto3 | |
from StringIO import StringIO | |
from pprint import pprint |
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
sudo easy_install virtualenv | |
virtualenv ~/virtualenvs/project_name | |
source ~/virtualenvs/project_name/bin/activate |
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 flask import Flask | |
application = Flask(__name__) | |
@application.route('/') | |
def hello_world(): | |
return 'Hello, World! Testing GitLab CI/CD :)" | |
if __name__ == "__main__": | |
application.run(host='0.0.0.0', debug=True) |
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
branch-defaults: | |
master: | |
environment: my_project | |
group_suffix: null | |
global: | |
application_name: my_project | |
branch: null | |
default_ec2_keyname: my_project | |
default_platform: python2.7 | |
default_region: us-west-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
>>> import six | |
>>> import datetime | |
>>> from dateutil.parser import parse | |
>>> now = datetime.datetime.utcnow() | |
>>> now | |
datetime.datetime(2017, 8, 16, 8, 38, 31, 766840) | |
>>> from dateutil.tz import tzutc | |
>>> test = now.replace(tzinfo=tzutc()) | |
>>> test | |
datetime.datetime(2017, 8, 16, 8, 38, 31, 766840, tzinfo=tzutc()) |
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 logging | |
import sys | |
import time | |
from jnpr.junos import Device | |
from jnpr.junos.utils.config import Config | |
logging.basicConfig(stream=sys.stdout, level=logging.INFO) | |
logger = logging.getLogger(__name__) |