Skip to content

Instantly share code, notes, and snippets.

View chriskuech's full-sized avatar

Chris Kuech chriskuech

  • Datum Source, ex MSFT
View GitHub Profile
@chriskuech
chriskuech / deploy.sh
Created April 5, 2019 04:28
Elastic Beanstalk NodeJS deployment script
#!/bin/bash
# ensure there are no uncommitted changes
git diff-index --quiet HEAD -- || { echo "Untracked changes" >&2; exit 1; }
# derive variables
branch="$(git symbolic-ref --short HEAD)"
timestamp="$(date +%Y%m%dT%H%M%S)"
# do work on a separate branch
@chriskuech
chriskuech / Export-PfxToBase64ps1
Last active April 8, 2019 19:55
Export PFX from Windows as Base64 string without password
##
# Export PFX from Windows as Base64 string without password
#
$thumbprint = ""
[Convert]::ToBase64String((Get-Item Cert:\CurrentUser\My\$thumbprint).Export("pkcs12"))
# declarative
[ValidateRange(0, 10)]
[int]$n = Read-Host
# imperative
[int]$n = Read-Host
if ($n -lt 0 -or $n -gt 10) {
throw [IndexOutOfRangeException]::new()
}
$ErrorActionPreference = "Stop"
[AttributeName("param1", "param2")] $value
[AttributeName("param1", "param2")]
$name = "value"
[ValidateSet("ca", "eu", "us")]
$region = Read-Host
function Deploy-Cluster {
Param(
[Parameter(Mandatory)]
[ValidatePattern("^[a-z]+-[a-z]+-[a-z]+-[0-9]+$")]
[string] $ClusterId
)
...
class Cluster {
[ValidatePattern("^[a-z]+$")]
[string] $Service
[ValidateSet("TEST", "STAGE", "CANARY", "PROD")]
[string] $FlightingRing
[ValidateSet("eastus", "westus", "northeurope")]
[string] $Region
[ValidateRange(0, 255)]
[int] $Index
}
function Get-Cluster {
[OutputType([Cluster])
Param(
[ValidateNotNullOrEmpty()]
[string[]] $serviceIds
)
$serviceIds | ForEach-Object {
$service, $flightingRing, $region, $idx = $_ -split "-"
[Cluster]@{