Skip to content

Instantly share code, notes, and snippets.

View lantrix's full-sized avatar
:octocat:
always coding and merging

Ted B lantrix

:octocat:
always coding and merging
View GitHub Profile
@lantrix
lantrix / lambda-schedule-rule-template.yaml
Created November 26, 2019 12:50
Example of invoking a lambda by ARN and providing fixed input JSON to the lambda as the event - for AWS CloudFormation in YAML
AWSTemplateFormatVersion: "2010-09-09"
Description: A Schedule to invoke a Lambda
Parameters:
LambdaArn:
Type: String
Description: ARN of the lambda to be invoked
Resources:
InvokeLambdaRole:
Type: AWS::IAM::Role
Properties:
$lambda = 'test-ps-lambda'
Install-Module -Name AWS.Tools.Installer, AWSLambdaPSCore
Install-AWSToolsModule -Name Common, CloudWatchLogs, Lambda -Cleanup
New-AWSPowerShellLambda -Template Basic -ScriptName TestLambda -Directory testlambda
# Publish Lambda
$publishParams = @{
ScriptPath = ".\TestLambda.ps1"
@lantrix
lantrix / Dockerfile
Last active February 17, 2020 08:01
Build Environment for PowerShell 6 on AWS Lambda. It builds upon the Powershell alpine base image and installs the latest DotNet Core 2.1
FROM mcr.microsoft.com/powershell:6.2.3-alpine-3.8
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8
# Install .NET Core SDK
ENV DOTNET_SDK_VERSION 2.1.803
@lantrix
lantrix / Readme.md
Created October 21, 2019 06:09
Start Deving a new PowerShell DotNet Core lambda

Install

  • Install Powershell 6.x on Mac brew cask install powershell

  • Install the .NET Core 2.1 SDK (not runtime)

  • Install the AWSLambdaPSCore module. Install-Module AWSLambdaPSCore -Scope CurrentUser

@lantrix
lantrix / delete-default-vpcs.ps1
Created August 9, 2019 06:48
Delete all AWS Default VPCs with PowerShell
#Requires -Module @{ModuleName="AWSPowerShell";ModuleVersion="3.3.450.0"}
Write-Output -InputObject 'Delete all Default VPCs'
$AllRegions = Get-EC2Region
ForEach ($region in $AllRegions.RegionName) {
Write-Output -InputObject "Searching $region"
$defaultVpc = Get-EC2VPC -Filter @{name='isDefault'; Value='true'} -Region $region
if ($defaultVpc) {
Write-Output -InputObject "Found default VPC $($defaultVPC.VpcId) $($defaultVPC.CidrBlock) ... deleting"
$VPCFilter = New-Object -TypeName Amazon.EC2.Model.Filter
@lantrix
lantrix / ephemeraldisk.service
Last active June 29, 2019 00:38
EC2 Ubuntu 18.04 LTS Ephemeral disk format and swapfile
[Unit]
Description=Ephemeral disk and swap setup script
[Service]
ExecStart=/usr/local/sbin/mount-instance-store.sh
[Install]
WantedBy=multi-user.target
@lantrix
lantrix / New-ErrorRecord.ps1
Created June 21, 2019 05:48 — forked from wpsmith/New-ErrorRecord.ps1
PowerShell: Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error.
<#
.Synopsis
Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error.
.Description
Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error.
.Parameter Exception
The Exception that will be associated with the ErrorRecord.
@lantrix
lantrix / LightroomCC Rename Change Date.md
Last active May 12, 2019 06:50
Lightroom CC date change & rename workflow - until the feature exists

Rename Originals and in Lightroom & Set New Dates

An option for photos one has already uploaded in LRCC even after editing without loosing the non-destructive changes.

It's a nice work around, but I would prefer to have a re-naming function in LRCC of course.

Note that any image deleted from Lightroom CC shared on a web album with comments will lose the comments. In this case I put the comments into the description.

This idea was from Hans on the Photoshop Feedback site.

@lantrix
lantrix / scanned-photo-naming.md
Last active June 17, 2019 03:33
Naming of Scanned Photos
@lantrix
lantrix / save-direct-to-dropbox.sh
Last active April 5, 2019 02:56
Save a file from somewhere on the web direct to dropbox
#!/bin/bash
# Open the following URL in your Browser, and log in using your account: https://www.dropbox.com/developers/apps
# Click on "Create App", then select "Dropbox API app"
# Now go on with the configuration, choosing the app permissions and access restrictions to your DropBox folder
# Enter the "App Name" that you prefer
# Now, click on the "Create App" button.
# When your new App is successfully created, please click on the Generate button
# under the 'Generated access token' section, then copy and paste the new access token here: