jq is useful to slice, filter, map and transform structured json data.
brew install jq
#! /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') |
#!/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 |
#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) |
<# | |
NOTE: DO NOT RUN THIS SCRIPT | |
This is simply a record of commands | |
demonstrated in the AWS PowerShell Webinar | |
#> | |
#Credentials | |
Get-EC2Instance -AccessKey $AccessKey -SecretKey $SecretKey -Region us-west-1 |
\+?1?\s?\-?\(?\d{3}\)?\s?\-?\d{3}\s?\-?\d{4} |
#!/usr/bin/python | |
import boto3 | |
from contextlib import closing | |
client = boto3.client('polly') | |
response = client.synthesize_speech( | |
OutputFormat='mp3', | |
Text='Amazon Polly is a service that turns text into lifelike speech. Polly lets you create applications that talk, enabling you to build entirely new categories of speech-enabled products. Polly is an Amazon AI service that uses advanced deep learning technologies to synthesize speech that sounds like a human voice. Polly includes 47 lifelike voices spread across 24 languages, so you can select the ideal voice and build speech-enabled applications that work in many different countries.', |