Skip to content

Instantly share code, notes, and snippets.

View geekzter's full-sized avatar

Eric van Wijk geekzter

View GitHub Profile
{
"extensions": [
"4ops.terraform",
"ms-azuretools.vscode-azureterraform",
"ms-azure-devops.azure-pipelines",
"ms-mssql.mssql",
"ms-vscode.azurecli",
"ms-vscode.PowerShell"
],
#!/usr/bin/env pwsh
# Runs post create commands to prep Codespace for project
# Update relevant packages
sudo apt-get update
#sudo apt-get install --only-upgrade -y azure-cli powershell
if (!(Get-Command tmux -ErrorAction SilentlyContinue)) {
sudo apt-get install -y tmux
}
@geekzter
geekzter / medium-codespaces-profile.ps1
Last active July 21, 2020 19:18
codespace profile
#!/usr/bin/env pwsh
# Find repo directories (may be different when not using main branch)
$repoDirectory = (Split-Path (get-childitem diagram.vsdx -Path ~ -Recurse).FullName -Parent)
$scriptDirectory = Join-Path $repoDirectory "scripts"
# Manage PATH environment variable
[System.Collections.ArrayList]$pathList = $env:PATH.Split(":")
# Insert script path into PATH, so scripts can be called from anywhere
@geekzter
geekzter / .tmux.conf
Last active October 1, 2020 12:06
medium-tmux.conf
# Theme, colors at https://i.stack.imgur.com/e63et.png
set -g default-terminal "screen-256color"
set -g status-bg default
set -g status-fg colour244
set -g window-status-current-bg default
#set -g window-status-current-style bg=default
set -g window-status-current-fg colour244
#set -g window-status-current-style fg=colour244
#set -g window-status-current-attr bold
set -g status-interval 60
@geekzter
geekzter / medium-tmux-functions.ps1
Last active October 1, 2020 12:21
medium-tmux-functions
#Requires -Version 7.0
function Connect-TmuxSession (
# Use Terraform workspace variable as default session name
[string]$Workspace=($env:TF_WORKSPACE ? $env:TF_WORKSPACE : "default")
) {
if ($env:TMUX) {
Write-Warning "Session already exixts: $env:TMUX"
return
}
@geekzter
geekzter / terraform-authentication-azure-pipeline.yml
Last active April 6, 2021 18:12
Terraform authentication inherits Azure Pipeline Service Connection credentials
- task: AzureCLI@2
displayName: 'Terraform init'
inputs:
azureSubscription: '$(subscriptionConnection)'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
# Propagate pipeline Service Principal as Terraform variables
$env:ARM_CLIENT_ID ??= $env:servicePrincipalId
$env:ARM_CLIENT_SECRET ??= $env:servicePrincipalKey
@geekzter
geekzter / terraform-authentication-powershell1.ps1
Last active April 6, 2021 18:11
Use Azure CLI to authenticate to Terraform interactively, ARM_SUBSCRIPTION_ID takes precedence
$env:ARM_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000
$env:ARM_TENANT_ID=00000000-0000-0000-0000-000000000000
az login -t $env:ARM_TENANT_ID
az account set --subscription $env:ARM_SUBSCRIPTION_ID
@geekzter
geekzter / terraform-authentication-powershell2.ps1
Last active April 6, 2021 18:11
Use Azure CLI to authenticate to Terraform interactively, Azure CLI subscription takes precedence
az login
az account set --subscription 00000000-0000-0000-0000-000000000000
$env:ARM_SUBSCRIPTION_ID=$(az account show --query "id" -o tsv)
$env:ARM_TENANT_ID=$(az account show --query "tenantId" -o tsv)
@geekzter
geekzter / github-action-azure-secret.json
Created March 22, 2021 10:20
Azure Service Principal credentials for GitHub Azure login action
{
"clientId": "00000000-0000-0000-0000-000000000000",
"clientSecret": "00000000-0000-0000-0000-000000000000",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000",
"objectId": "00000000-0000-0000-0000-000000000000",
(...)
}
@geekzter
geekzter / terraform-authentication-github-actions.yml
Last active May 13, 2024 19:49
Terraform authentication re-uses GitHub Azure Action credentials
- name: Get Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 'latest'
terraform_wrapper: false