Skip to content

Instantly share code, notes, and snippets.

View ericreeves's full-sized avatar

Eric Reeves ericreeves

  • HashiCorp
  • Houston, TX
  • 15:44 (UTC -05:00)
  • X @ericreeves
View GitHub Profile
@ericreeves
ericreeves / wpmdctl.ps1
Last active June 2, 2025 23:06
wpmdctl
param(
[Parameter(Position = 0, Mandatory = $false)]
[string]$Action,
[Parameter(Position = 1, ValueFromRemainingArguments = $true)]
[string[]]$args
)
# Ensure 'wpmctl' is executable within the current context and path
try {
#!/bin/bash
#
# Search HashiCorp Vault for a Secret Value, Traversing all Nested namespaces
#
##########################################################################
# DISCLAIMER: THIS SCRIPT IS PROVIDED STRICTLY AS A PROOF OF CONCEPT.
# EXECUTING THIS SCRIPT ASSUMES ALL LIABILITY.
##########################################################################
#
packer {
required_plugins {
amazon = {
version = ">= 1.0.1"
source = "github.com/hashicorp/amazon"
}
}
}
data "amazon-ami" "ubuntu-server-east" {
@ericreeves
ericreeves / archivist_renamer.py
Created January 23, 2024 00:26
Script to Rename TubeArchivist Downloads Using the TubeArchivist API
import os
import requests
import sys
from datetime import datetime
# Configurable variables
archivist_api_token = os.getenv('ARCHIVIST_API_TOKEN')
archivist_host = os.getenv('ARCHIVIST_HOST')
# Function to sanitize file name
@ericreeves
ericreeves / namespace-bound-service-account-audit.sh
Last active January 2, 2024 22:02
Audit HashiCorp Vault for Unique Bound Service Account Names in Each Namespace
#!/bin/bash
# Ensure VAULT_ADDR and VAULT_TOKEN are exported.
# Ensure VAULT_NAMESPACE is unset
# Function to list namespaces recursively
function list_namespaces {
entry_point=$(echo ${1} | sed 's/\/$//')
echo "${entry_point}/"
## first, check if root ns, and if so collect children slightly differently due to path specification
@ericreeves
ericreeves / tfe_list_all_workspaces.sh
Last active August 21, 2023 20:43
Terraform Enterprise/Cloud - List All Workspaces
#!/bin/bash
#
# Terraform Enterprise/Cloud - List All Workspaces in All Organizations
#
#------------------------------------------
# DESCRIPTION
#------------------------------------------
# This script will list all workspaces in all organizations visible to the user for which the TFE_TOKEN was generated
#
#------------------------------------------
@ericreeves
ericreeves / vault_recursive_namespace_list.sh
Created May 17, 2023 00:50
Bash Script to List Vault Namespaces Recursively
#!/bin/bash
# First passing argument is the depth
# The second passing argument is the starting namespace
# Example usage to list namespaces 10 levels deep from the "root" namespace:
# ./vault_recursive_namespace_list.sh 10
# Example usage to list namespaces 5 levels deep from the "customer1" namespace.
# ./vault_recursive_namespace_list.sh 5 customer1
@ericreeves
ericreeves / denied-resources.sentinel
Created May 11, 2023 18:33
Sentinel Policy to Deny Deployment of Specific Resource Types
# This policy uses the tfconfig/v2 import to deny resources
# from an denied list
# Import common-functions/tfconfig-functions/tfconfig-functions.sentinel
# with alias "config"
import "tfconfig-functions" as config
# List of denied resources
denied_list = ["aws_instance", "azurerm_virtualmachine", "google_compute_instance"]
@ericreeves
ericreeves / tfx-remote-state-sharing.sh
Last active May 11, 2023 18:22
Quick Bash Script Wrapper for TFX to List All Remote Source Sharing for All Workspaces in an Organization
#!/bin/bash
#
# Quick and dirty script that wraps around the TFX CLI tool to list all Workspaces within an Orgainzation, and then list all remote state
# sharing for each Workspace.
#
# Acquire tfx here: https://tfx.rocks/
# TFX can be configured using environment variables TFE_HOSTNAME, TFE_ORGANIZATION, TFE_TOKEN
#
export TFE_HOSTNAME="app.terraform.io"
#export VAULT_TOKEN="<root>"
export NS="TEST-NAMESPACE"
echo "--- Creating namespace"
vault namespace create $NS
echo "--- Enable approle auth within namespace"
vault auth enable -namespace=$NS approle
# create policy
echo "--- Writing ns-admin policy"
echo '# Read TEST-NAMESPACE Namespace