Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyraywv committed Dec 5, 2022
1 parent 1fce940 commit 6185066
Show file tree
Hide file tree
Showing 13 changed files with 1,997 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.ipynb_checkpoints
_build
168 changes: 168 additions & 0 deletions asg.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"!pip3 install --upgrade pip\n",
"!pip3 install boto3\n",
"!pip3 install pyyaml"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"from functools import reduce\n",
"import os\n",
"import boto3\n",
"from botocore.client import Config\n",
"import yaml\n",
"from datetime import datetime, time, timedelta\n",
"import json\n",
"from pprint import pprint\n",
"from pprint import PrettyPrinter\n",
"from statistics import mean\n",
"import sys"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"print(sys.version_info)\n",
"print(sys.version_info[:3])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"config = yaml.load(open('config.yaml', 'r'))\n",
"#print(config)\n",
"aws_region = config['aws']['regions'][0]\n",
"account = config['aws']['accounts'][1]['name']\n",
"profile = config['aws']['accounts'][1]['profile']\n",
"account_number = config['aws']['accounts'][1]['account-number']\n",
"\n",
"print((\"%s - %s - %s - %s\" % (str(account_number),account,profile,aws_region)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"session = boto3.session.Session(profile_name=profile,region_name=aws_region)\n",
"print(session)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"asgClient = session.client('autoscaling')\n",
"print(asgClient)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"class Asg(object):\n",
" def __init__(self, name):\n",
" self.name = name\n",
" self.attributes = {}\n",
" \n",
" def __str__(self):\n",
" retrn = 'ASG: clusterName={0}'\n",
" return retrn"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"# Create a reusable Paginator\n",
"paginator = asgClient.get_paginator('describe_auto_scaling_groups')\n",
"#print(paginator)\n",
"\n",
"# Create a PageIterator from the Paginator\n",
"page_iterator = paginator.paginate()\n",
"\n",
"asgs = []\n",
"\n",
"for page in page_iterator: \n",
" print(page)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
16 changes: 16 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aws:
accounts:
- name: dev1
short-name: ""
description: ""
account-number: <AWS_ACCOUNT_ID>
profile: <AWS_PROFILE>
regions:
- us-west-2

aws-ec2-cw-stats:
metrics:
- metric: CPUUtilization
namespace: AWS/EC2
statistics: Minimum,Maximum,Average
minutes: 60
158 changes: 158 additions & 0 deletions ebs.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"!pip3 install --upgrade pip\n",
"!pip3 install boto3\n",
"!pip3 install pyyaml"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"from functools import reduce\n",
"import os\n",
"import boto3\n",
"import yaml\n",
"from datetime import datetime, time, timedelta\n",
"import json\n",
"from pprint import pprint\n",
"from pprint import PrettyPrinter\n",
"from statistics import mean\n",
"import sys"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"print(sys.version_info)\n",
"print(sys.version_info[:3])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"config = yaml.load(open('config.yaml', 'r'))\n",
"#print(config)\n",
"aws_region = config['aws']['regions'][0]\n",
"account = config['aws']['accounts'][1]['name']\n",
"profile = config['aws']['accounts'][1]['profile']\n",
"account_number = config['aws']['accounts'][1]['account-number']\n",
"\n",
"print((\"{} - {} - {} - {}\".format(str(account_number),account,profile,aws_region)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"session = boto3.session.Session(profile_name=profile,region_name=aws_region)\n",
"print(session)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"ec2Client = session.client('ec2')\n",
"print(ec2Client)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"response = ec2Client.describe_volumes(Filters = [{'Name':'tag:TAG_KEY', 'Values':['TAG_VALUE']}])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"pp = PrettyPrinter() #indent=1)\n",
"pp.pprint(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 6185066

Please sign in to comment.