Skip to content

Instantly share code, notes, and snippets.

View ScriptAutomate's full-sized avatar
:shipit:
Automating All The Things

Derek Ardolf ScriptAutomate

:shipit:
Automating All The Things
View GitHub Profile
@ScriptAutomate
ScriptAutomate / multiplication.py
Last active August 3, 2018 15:37
Multiplication Table Generator
import argparse
"""
Creates multiplication tables
"""
def get_arguments():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@ScriptAutomate
ScriptAutomate / S3NakedInPublic.ps1
Last active June 29, 2019 04:00
[PowerShell Core / AWSPowerShell.NetCore / AWS] List all S3 buckets, in the default region config, that have 'Public' permissions listed anywhere in the ACL
# Requires AWSPowerShell.NetCore Module
# Install-Module AWSPowerShell.NetCore
# https://www.powershellgallery.com/packages/AWSPowerShell.NetCore
foreach ($OhNoes in Get-S3Bucket) {
if (($OhNoes | Get-S3ACL).Grants.Grantee | where {$_.URI -eq 'http://acs.amazonaws.com/groups/global/AllUsers'}) {
$OhNoes
}
}
@ScriptAutomate
ScriptAutomate / S3NakedInPublic.py
Created October 24, 2018 21:39
[Python 3 / boto3 / AWS] List all S3 buckets, in the default region config, that have 'Public' permissions listed anywhere in the ACL
import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
for oh_noes in s3.BucketAcl(bucket.name).grants:
if oh_noes['Grantee']['Type'] == 'Group' and oh_noes['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers':
print(bucket)
@ScriptAutomate
ScriptAutomate / S3NakedInPublic.sh
Created October 26, 2018 22:23
[Bash Script / awscli / AWS] List all S3 buckets, in the default region config, that have 'Public' permissions listed anywhere in the ACL
#!/usr/bin/env bash
# Requires awcli
# pip install awscli --user --upgrade
# https://docs.aws.amazon.com/cli/latest/userguide/installing.html
BUCKETS=`aws s3api list-buckets --query 'Buckets[*].Name' --output text | tr " " "\n"`
for BUCKET in $BUCKETS
do
OH_NOES=`aws s3api get-bucket-acl --bucket $BUCKET | grep -e 'URI.*http\:\/\/acs\.amazonaws\.com\/groups\/global\/AllUsers\"'`
if [ ! -z "$OH_NOES" ]
@ScriptAutomate
ScriptAutomate / aws-sam-cli-alexa-skill-id.sh
Created January 11, 2019 21:09
Adding an Alexa Skills Kit Permission w/ InvokeFunction Permissions After Deploying w/ SAM CLI
#!/usr/bin/env bash
# Push package to S3 bucket
$STACK_NAME="hello-world-dev"
sam deploy \
--template-file packaged.yaml \
--stack-name $STACK_NAME \
--capabilities CAPABILITY_IAM
# Setup Alexa Skills Kit skill ID
@ScriptAutomate
ScriptAutomate / aws-ask-cli-alexa-modify.sh
Created January 16, 2019 01:11
ASK CLI Basic Usage for Cloning an Existing Alexa Skill Configuration for Version Control and Management via Code
# Install
sudo npm install -g ask-cli
# Initial Configuration of ask-cli
# Asks for AWS creds and Amazon Developer creds
ask init
# Duplicate existing skill
mkdir ask-aws-app-name
cd ask-aws-app-name
@ScriptAutomate
ScriptAutomate / ask-sam-template.yaml
Created January 16, 2019 20:12
Properly Configure Alexa Skill Id Permissions to Invoke Backend Lambda Function with SAM CLI Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Alexa App Hello World Lambda Endpoint
Mappings:
Variables:
AlexaSkillKit:
Id: amzn1.ask.skill.xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Globals:
@ScriptAutomate
ScriptAutomate / awsregions.py
Created August 13, 2019 10:57
List All AWS Regions via AWS EC2 API (PreReq: Need AWSCLI / Credentials Configured)
from boto3 import client
def gather_aws_regions():
'''Return all available AWS Regions via EC2 api'''
conn = client('ec2')
regions = conn.describe_regions(AllRegions=True)['Regions']
return [region['RegionName'] for region in regions]
@ScriptAutomate
ScriptAutomate / vpn-cloudformation-template.yaml
Last active May 22, 2024 02:50 — forked from pbzona/vpn-cloudformation-template.yaml
Roll your own Amazon Linux 2 OpenVPN with AWS CloudFormation (w/ Dynamically Discovered Latest AMI Id via Parameter Store)
# Personal OpenVPN Server Deployment
# Updates applied by Derek Ardolf / @ScriptAutomate / https://icanteven.io
# 11/08/2019 - Version 2.x:
# - Released with many updates, and tracked here: https://github.com/ScriptAutomate/openvpn-cfn
#
# Created by John Creecy / @zugdug
# 10/30/2017 - Version 1.0:
# - Original: https://gist.github.com/zugdud/b39eea02faa6926305f57fbde8d31b68
# Original Linux Academy blog series walkthrough on building the old OpenVPN template:
# - Part 1: https://linuxacademy.com/blog/tutorials/roll-vpn-aws-cloudformation-part-one/
@ScriptAutomate
ScriptAutomate / get_nitro_instance_types.py
Created August 30, 2019 19:18
[Python 3] Boto3 and Webscrape for List of AWS Instances Based on The Nitro System
import requests
import re
import json
import boto3
def get_all_ec2_types():
'''
Modified version of get_instances() from
https://github.com/powdahound/ec2instances.info/blob/master/ec2.py