Skip to content

Instantly share code, notes, and snippets.

View austoonz's full-sized avatar

Andrew Pearce austoonz

View GitHub Profile
@austoonz
austoonz / Get-EpochTimeFrom.ps1
Last active June 1, 2021 15:47
PowerShell snippets for dealing with epoch ('01-01-1970')
function Get-EpochTimeFrom {
param (
[int]$Seconds
)
(Get-Date -Date '01-01-1970') + ([System.TimeSpan]::FromSeconds($Seconds))
}
@austoonz
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
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 (
[ValidateSet('dynamodb')]
[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}.amazonaws.com' -f $ServiceForMeasurement, $region))
@austoonz
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 {
[CmdletBinding()]
param (
[ValidateScript({Test-Path -Path $_ -PathType Leaf})]
$FilePath
)
$awsCommands = @{}
$tokens = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Path $FilePath -Raw), [ref]$null)
@austoonz
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"
Resources:
Association:
Type: AWS::SSM::Association
Properties:
@austoonz
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
Parameters:
SourceSNSTopicArn:
Type: String
Description: SNS Topic Arn to subscribe the SQS Queue to
@austoonz
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
Parameters:
BucketName:
Type: String
Description: The name of the S3 Bucket to create