Skip to content

Instantly share code, notes, and snippets.

View matwerber1's full-sized avatar

Mathew Werber matwerber1

  • Seattle
View GitHub Profile
@matwerber1
matwerber1 / compose.yml
Last active November 9, 2023 18:16
AWS - Containers - Compose - mount ~/.aws/cred
version: "3.8"
services:
AwsCLI:
image: public.ecr.aws/aws-cli/aws-cli
container_name: aws-cli
platform: linux/x86_64
volumes:
- ~/.aws/:~/.aws/ # Mount local credentials into container to use AWS CLI/SDK
environment:
@matwerber1
matwerber1 / aws-profile
Created November 27, 2023 05:46
Super Duper AWS CLI Profile Switching Script
#! /bin/bash -i
set -e
# Constants
PROFILE_NICKNAME_FILE=".awsprofile.env"
AWS_CONFIG_FILE="$AWS_CONFIG_FILE"
# Variables
original_request="$1"
requested_profile=""
@matwerber1
matwerber1 / readme.md
Created December 13, 2023 08:01
Querying AWS Cost and Usage V2 (CURv2) with Amazon Athena - DDL and Queries

DDL for Athena Table

This could be improved, but does the trick for now. This is for a report configured as "daily" with resource IDs:

CREATE EXTERNAL TABLE IF NOT EXISTS `org_data`.`curv2` (
  `discount_bundled_discount` string,
  `discount_total_discount` string,
  `identity_line_item_id` string,
  `identity_time_interval` string,
@matwerber1
matwerber1 / README.md
Created June 23, 2025 08:34
Terraform - Deploy Windows BitBucket Self-hosted Runner as a service using AWS SSM Run Command

Terraform to create an AWS Systems Manager (SSM) RunCommand that can be used to configure an EC2 Windows instance as a bitbucket pipeline runner.

The installation uses WinSW to wrap the runner process as a Windows service and configures it to restart on failure / reboots as described in https://jira.atlassian.com/browse/BCLOUD-21928, also based on https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-windows/

This is for a workspace-level runner.

A repository-level runner requires an extra parameter in the XML file and the SSM document.

Not all of the install scripts are included as they're pretty straightforward (e.g. choco install xyz, apart from the initial install of chocolately (see powershell-scripts/winEc2-choco-install-git.ps1) and disabling of pagefile+swapfile (see powershell-scripts/winEc2-disable-pagefile-and-swapfile.ps1).

@matwerber1
matwerber1 / gist:8c05e53438723a46e079fb106e61e936
Last active May 16, 2026 20:53
AWS SecurityLake - CloudTrail Logs - Source v2 (OCSF 1.1.0) - Investigate IAM Roles Anywhere Failures
-- == 90% APPLICABLE TO ANY CLOUDTRAIL
-- == It's the unnested fields like api.resquest.data
-- == and api.request.data that are contextual, depend on the service that called them
SELECT DISTINCT
-- ===== Scalar top-level columns =====
date_format(from_unixtime((time - (time % 600000)) / 1000) AT TIME ZONE
'America/Los_Angeles', '%Y-%m-%d %h:%i %p') AS event_time_10min_local,