Skip to content

Instantly share code, notes, and snippets.

View reecestart's full-sized avatar
💻

Reece reecestart

💻
View GitHub Profile
@reecestart
reecestart / getAvailableIPs.py
Last active November 15, 2022 14:25
Checks all Subnets in all Regions for those with less than 20 available IP addresses
import boto3
# Define the connection
client = boto3.client('ec2')
# Get all Regions
response = client.describe_regions()
# Create an Array for Region Names
RegionNames = []
@reecestart
reecestart / set-iam-password-policy.sh
Created July 20, 2018 02:43
Set AWS IAM Password Policy to clear Trusted Advisor Check
aws iam update-account-password-policy --minimum-password-length 8 --require-numbers --require-uppercase-characters --require-lowercase-characters --require-symbols
@reecestart
reecestart / describe-rds-private-ips.py
Last active April 30, 2024 17:40
Will print out RDS DB Instance DB Identifiers with their ENI and Private IP. Will only work if one SG is used per RDS DB (EDIT: Updated to work for DB Clusters e.g. Aurora Serverless)
import boto3
ec2_client = boto3.client('ec2')
rds_client = boto3.client('rds')
rdsNetworkInterfaces = ec2_client.describe_network_interfaces(
Filters=[
{
'Name': 'attachment.instance-owner-id',
'Values': [
@reecestart
reecestart / t2UnlimitedLaunchTemplateWithASG.json
Created June 15, 2018 03:03
Creates a Launch Template and Auto Scaling Group with two t2.micro T2 Unlimited EC2 Instances
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "T2 Unlimited Launch Template",
"Outputs": {
"LaunchTemplate": {
"Value": {
"Ref": "TestLaunchTemplate"
}
}
},
@reecestart
reecestart / check-ASG-SLRs.ps1
Created May 31, 2018 05:27
Checks all ASG's to see if they were created with a Service Linked Role and if not, lists username of who created the ASG
cls
$ASGs = Get-ASAutoScalingGroup
$ASGsWithoutSLR = @()
foreach ($ASG in $ASGs)
{
if ($ASG.ServiceLinkedRoleARN -eq $null)
{
$ASGsWithoutSLR += $ASG
@reecestart
reecestart / get-RI-utilization.sh
Created February 14, 2018 04:12
Bash script to get the RI Utilization given a start and end date, granularity either daily or monthly
#!/usr/bin/env
# To check RI Utilization
echo "What is your Start Date for checking RI Utilization? (YYYY-MM-DD)"
read startDate
startDateString="Start=$startDate"
echo "What is your End Date for checking RI Utilization? (YYYY-MM-DD)"
read endDate
endDateString="End=$endDate"
@reecestart
reecestart / test-s3-version-sync.sh
Created February 1, 2018 01:48
Testing the effect of S3 Sync on an object with multiple Versions
#!/bin/bash
# Tested using bash version 3.2.57
echo Source Test Bucket?
read sourcetestbucketname
sourcetestbucket="s3://$sourcetestbucketname"
aws s3 mb $sourcetestbucket
echo Destination Test Bucket?
@reecestart
reecestart / create-account.py
Created January 24, 2018 03:19
Create AWS Account with Python using Organizations
import time
import boto3
import pprint
# setup pprint
pp = pprint.PrettyPrinter(indent=1)
# define the connection
client = boto3.client('organizations')
@reecestart
reecestart / getVirtualCoresForEC2InstanceTypes.ps1
Created January 10, 2018 05:44
Programmatically get the # of virtual cores for an EC2 instance type to figure out licensing costs
# Programmatically get the # of virtual cores for an EC2 instance type to figure out licensing costs
# https://aws.amazon.com/ec2/virtualcores/
$Region = 'us-east-1'
$ServiceCode = 'AmazonEC2'
$Products = Get-plsproduct -ServiceCode $ServiceCode -Filter @{Type="TERM_MATCH";Field="productFamily";Value="Compute Instance"},@{Type="TERM_MATCH";Field="location";Value="Asia Pacific (Sydney)"} -Region $Region
$VirtualCoresByAmazonEC2InstanceType = @()
@reecestart
reecestart / listRunningEC2InstancesWithTags.ps1
Created January 9, 2018 04:32
cmdlet that can list all running ec2 instances with tags in table format
$Regions = Get-EC2Region
$Regions = $Regions.RegionName
$RunningInstances = @()
foreach ($Region in $Regions)
{
$EC2Instances = Get-EC2Instance -Region $Region
foreach ($EC2Instance in $EC2Instances)
{
if ($EC2Instance.Instances.state.name.value -eq 'running')
{