Skip to content

Instantly share code, notes, and snippets.

View austoonz's full-sized avatar

Andrew Pearce austoonz

View GitHub Profile
austoonz / Simple-S3Bucket-SNS
Last active February 9, 2024 02:38
A CloudFormation template sample for creating an S3 Bucket with an SNS Trigger.
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple S3 Bucket with SNS Trigger
Type: String
Description: The name of the S3 Bucket to create
austoonz / SQS-SNS-Subscription
Last active January 23, 2024 22:35
A CloudFormation template sample to subscribe an SQS Queue to an SNS Topic.
AWSTemplateFormatVersion: '2010-09-09'
Description: SQS Queue subscribed to an SNS Topic
Type: String
Description: SNS Topic Arn to subscribe the SQS Queue to
austoonz / SSMAssociation
Created February 6, 2019 17:29
A CloudFormation template to create a PowerShell based AWS Systems Manager Association with inline PowerShell.
AWSTemplateFormatVersion: '2010-09-09'
Description: "Systems Manager Association"
Type: AWS::SSM::Association
austoonz / Get-AWSCommandsFromFile.ps1
Last active April 21, 2022 05:39
This function will use the PowerShell Parser, and the Get-AWSCmdletName cmdlet (found in AWS.Tools.Common, AWSPowerShell or AWSPowerShell.NetCore) to find and output all AWS Cmdlets from a script. This can be used to assist with migrations to the modular AWS Tools for PowerShell.
function Get-AWSCommandsFromFile {
param (
[ValidateScript({Test-Path -Path $_ -PathType Leaf})]
$awsCommands = @{}
$tokens = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Path $FilePath -Raw), [ref]$null)
austoonz / Get-AWSRegionLatency
Last active April 12, 2022 15:58
Sample PowerShell function to identify the closest AWS Region using AWS Service Endpoints.
function Get-AWSRegionLatency {
param (
[String] $ServiceForMeasurement = 'dynamodb'
$endpoints = [System.Collections.ArrayList]::new()
$regions = (Get-AWSRegion | Where-Object {$_.Region -notlike 'us-iso*'}).Region
foreach ($region in $regions) {
$null = $endpoints.Add(('{0}.{1}' -f $ServiceForMeasurement, $region))
austoonz / AWS-ApplyDSCMofs
Last active December 30, 2021 16:17
Samples for deploying an AWS Systems Manager Association using the 'AWS-ApplyDSCMofs' Document.
# Overview
This Gist provides samples to simplify the usage of the AWS Systems Manager Document, "AWS-ApplyDSCMofs".
austoonz / Get-EpochTimeFrom.ps1
Last active June 1, 2021 15:47
PowerShell snippets for dealing with epoch ('01-01-1970')
function Get-EpochTimeFrom {
param (
(Get-Date -Date '01-01-1970') + ([System.TimeSpan]::FromSeconds($Seconds))
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingCmdletAliases', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPlainTextForPassword', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
austoonz / Write-SSMComplianceItemExample
Last active April 5, 2019 22:31
Sample code for writing an AWS Systems Manager Compliance Item.
$managedInstanceId = (Get-Content -Path 'C:\ProgramData\Amazon\SSM\InstanceData\Vault\Store\RegistrationKey' -Raw | ConvertFrom-Json).instanceID
$moduleNames = @(
$complianceItems = [System.Collections.Generic.List[Amazon.SimpleSystemsManagement.Model.ComplianceItemEntry]]::new()
foreach ($moduleName in $moduleNames)
austoonz / Invoke-FastPing
Last active March 1, 2019 17:02
A PowerShell Function that uses asynchronous ping commands to quickly ping a fleet of target machines.
# This has been replaced by the FastPing PowerShell Module.
## Source
## Installation
Install-Module -Name FastPing -Scope CurrentUser