Skip to content

Instantly share code, notes, and snippets.

View babo's full-sized avatar

Attila Babo babo

View GitHub Profile
function SelectSubscription () {
$context=$null
try {
$context = Get-AzureRmContext
} catch [ System.Management.Automation.PSInvalidOperationException] {}
if ($context -eq $null) {
$context = (Login-AzureRmAccount).Context
}
@babo
babo / userdata.ps1
Created March 2, 2016 15:53
Userdata for windows machines
<powershell>
Import-Module AWSPowerShell
Copy-S3Object -BucketName joc-internal-resources -Key installer/windows2012/run_userdata.ps1 -LocalFile "$env:temp\run_userdata.ps1"
Set-ExecutionPolicy -executionpolicy remotesigned -force
& "$env:temp\run_userdata.ps1"
</powershell>
@babo
babo / aws_resources.py
Created December 20, 2015 12:50
Skeleton to list all AWS resources by security group.
#!/usr/bin/env python3
import json
import boto3
def main():
all_ec2 = {}
all_rds = {}
all_cache = {}
all_elb = {}
@babo
babo / list_aws_resources.py
Created December 18, 2015 22:32
List security groups, EC2, RDS and Elasticache instances and they security groups.
#!/usr/bin/env python3
import boto3
def main():
region_names = [x['RegionName'] for x in boto3.client('ec2').describe_regions()['Regions']]
for region_name in region_names:
ec2 = boto3.resource('ec2', region_name=region_name)
for sg in ec2.security_groups.iterator():
print(region_name, 'security_group', sg.group_name, sg.group_id)
for instance in ec2.instances.iterator():
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1442914547000",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": [
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
@babo
babo / lambda.py
Created December 17, 2015 11:55
Simple AWS lambda job to create an SQS event for each S3 events.
#!/usr/bin/env python
import argparse
import logging
try:
from urllib import splittype
except ImportError:
from urllib.parse import splittype
import boto3
#!/usr/bin/env python3
import redis
import pymysql
REDIS = 'redis.cache.amazonaws.com'
MYSQL = 'my.rds.amazonaws.com'
USER = 'whomai'
PASSWORD = 'SECRET'
DB = 'mdb'
#!/usr/bin/env perl
use Redis;
use CGI;
my $cgi = new CGI;
my $vars = $cgi->Vars;
my ($type,$nr) = ($vars->{type},$vars->{id});
if ($nr > 0 && $type) {

Keybase proof

I hereby claim:

  • I am babo on github.
  • I am babo (https://keybase.io/babo) on keybase.
  • I have a public key whose fingerprint is B2E6 C087 42DB 7CFA CE5E 2454 5FBC 652F 9EA3 A514

To claim this, I am signing this object: