Skip to content

Instantly share code, notes, and snippets.

View damienpontifex's full-sized avatar

Damien Pontifex damienpontifex

View GitHub Profile
<#
.DESCRIPTION
An example runbook which gets all the ARM resources using the Managed Identity
.NOTES
AUTHOR: Azure Automation Team
LASTEDIT: Oct 26, 2021
#>
try
{
@damienpontifex
damienpontifex / bazel-azure-storage-remote-cache.sh
Last active August 12, 2024 18:48
Bazel remote cache with Azure Storage
# Interactive read the storage account name
read -p "Storage account name: " STORAGE_ACCOUNT
# Or set variable directly here
# STORAGE_ACCOUNT=azurestorageaccountname
STORAGE_CONTAINER=bazel-cpp-tutorial
ACCESS_TOKEN=$(az account get-access-token \
--resource="https://${STORAGE_ACCOUNT}.blob.core.windows.net/" \
--query accessToken --output tsv)
@damienpontifex
damienpontifex / cloudformation-yaml-language-server.yml
Created May 26, 2021 01:02
Snippet that defines schema for cloud formation yaml to be used with yaml-language-server
# yaml-language-server: $schema=https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json
AWSTemplateFormatVersion: 2010-09-09
Resources:
@damienpontifex
damienpontifex / .amplify-cli-usage
Last active May 3, 2024 22:27
Making the amplify CLI easier to use
Purposefully left blank for naming
#!/usr/bin/env bash
## For debugging
#PS4='Line ${LINENO}: '
#set -o xtrace
RG_NAME=pontitest
COMMON_ARGS=(--resource-group $RG_NAME --location australiaeast)
az group show --resource-group $RG_NAME > /dev/null 2>&1
@damienpontifex
damienpontifex / azure-devops-pr-labels.yml
Last active October 25, 2022 09:35
Get labels applied to PR. Used if we want to do custom actions in the build based on those labels. We should set them as environment variables or whatever action you want
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: Job1
steps:
- script: |
LABELS_JSON=$(curl -H "Authorization: Bearer ${SYSTEM_ACCESSTOKEN}" "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullRequests/$(System.PullRequest.PullRequestId)/labels?api-version=5.1-preview.1")
echo $LABELS_JSON
env:
@damienpontifex
damienpontifex / openssl_tasks.py
Last active November 17, 2019 20:16
Common OpenSSL
from OpenSSL import crypto
key = crypto.PKey()
key.generate_key(crypto.TYPE_RSA, 2048)
cert = crypto.X509()
subj = cert.get_subject()
subj.CN = "localhost"
cert.gmtime_adj_notAfter(365*24*60*60)
cert.set_pubkey(key)
#!/bin/bash
# Map variables retrieved from Key Vault to environment variables such as:
# env:
# CERT_DATA: $(certData)
# CERT_PASSWORD: $(certPassword)
# Read in the PFX data and save as pfx file
echo "${CERT_DATA}" | base64 --decode > cert.pfx
@damienpontifex
damienpontifex / azure_keyvault_letsencrypt.py
Last active August 3, 2019 05:59
acme letsencrypt python library and using Azure KeyVault to store account private keys
# %%
# !python -m pip install -qU azure-mgmt-dns acme azure-keyvault
# %%
import os
import hashlib
import base64
import logging
import datetime
from typing import List, Tuple, Optional, Callable, Generator
@damienpontifex
damienpontifex / az-storage-oauth-list-containers.sh
Last active October 5, 2018 06:08
Access storage by using OAuth token from az cli
#!/bin/bash
# Add your use account as "Storage Blob Data Contributor" RBAC to the Access Control of the storage account
STORAGE_ACCOUNT=<account-name>
STORAGE_ACCESS_TOKEN=$(az account get-access-token --resource https://storage.azure.com/ --query accessToken -o tsv)
curl \
-H "Authorization: Bearer $STORAGE_ACCESS_TOKEN" \