jq is useful to slice, filter, map and transform structured json data.
brew install jq
#!/usr/bin/env | |
# Python Docs https://docs.python.org/3/library/secrets.html | |
import secrets | |
secrets.token_hex(5).upper() # The number of actual character returned will be double the number in token_hex(n) |
num = 27 | |
steps = 0 | |
# while steps < 30: # use this while logic to show that it continuously loops 4,2,1. The number 30 can be changed to any arbitrary number | |
while num != 1: | |
if num % 2 != 0: | |
num = num * 3 + 1 | |
else: | |
num = num / 2 | |
print(num) | |
steps += 1 |
#! /bin/bash | |
region='us-east-1' | |
# Find all gp2 volumes within the given region | |
volume_ids=$(/usr/bin/aws ec2 describe-volumes --region "${region}" --filters Name=volume-type,Values=gp2 | jq -r '.Volumes[].VolumeId') | |
# Iterate all gp2 volumes and change its type to gp3 | |
for volume_id in ${volume_ids};do | |
result=$(/usr/bin/aws ec2 modify-volume --region "${region}" --volume-type=gp3 --volume-id "${volume_id}" | jq '.VolumeModification.ModificationState' | sed 's/"//g') |
#Function Create-RandomFiles{ | |
<# | |
.SYNOPSIS | |
Generates a number of dumb files for a specific size. | |
.DESCRIPTION | |
Generates a defined number of files until reaching a maximum size. | |
.PARAMETER TotalSize | |
Specify the total size you would all the files combined should use on the harddrive. |
--- | |
AWSTemplateFormatVersion: 2010-09-09 | |
Description: Creates a CodeBuild project to audit an AWS account with Prowler and stores the html report in a S3 bucket. This will run onece at the beginning and on a schedule afterwards. Partial contribution from https://github.com/stevecjones | |
Parameters: | |
ServiceName: | |
Description: 'Specifies the service name used within component naming' | |
Type: String | |
Default: 'prowler' | |
LogsRetentionInDays: |
# https://www.radishlogic.com/aws/lambda/how-to-get-the-aws-account-id-in-lambda-python/ | |
def lambda_handler(event, context): | |
aws_account_id = context.invoked_function_arn.split(":")[4] | |
print(aws_account_id) |
\+?1?\s?\-?\(?\d{3}\)?\s?\-?\d{3}\s?\-?\d{4} |
Random recipes of JMESPath for the AWS CLI tools that I might have written or stumbled upon.
———————————————————————————————————————————————————————————————————————————————————————————————————— | |
BBEDIT/TEXTWRANGLER REGULAR EXPRESSION GUIDE MODIFIED 2016/02/29 17:26 | |
———————————————————————————————————————————————————————————————————————————————————————————————————— | |
NOTES: | |
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use. | |
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete. |