Skip to content

Instantly share code, notes, and snippets.

View J00MZ's full-sized avatar
🍋
Snicket

Joe Tavin J00MZ

🍋
Snicket
View GitHub Profile
@J00MZ
J00MZ / quick_terraform.md
Last active July 7, 2022 09:34
Quickly create terraform files from resources - reverse Terraform

Create .tf files from remote resources

Disclaimer

Generating configuration from remote state is still not officially supported by Terraform.

However, when I stupidly enough deleted a complex DataDog resource that I had created manually, I managed to fully restore it and create a full terraform file for it using a few simple commands

This worked for me with the datadog_synthetics_test resource, so this will be the example resource below.
If this works for you with any other Terraform resources, I would love to know 🤗 .

@J00MZ
J00MZ / secrets.md
Last active July 6, 2022 09:14
Jenkins_Get_Secrets

Get Jenkins Secrets as plaintext

def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
    com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
    Jenkins.instance,
    null,
    null
);
for (c in creds) {
@J00MZ
J00MZ / repo_pull_aliases.sh
Last active January 17, 2023 18:41
Pull All Repos Command
# Version 1 - one repo at a time
function pull_all_repos(){
CURRENT_DIR="$(pwd)"
DIRLIST=($(cdr && ls -1|xargs))
REPODIR="$(cdr && pwd)"
for dir in "${DIRLIST[@]}";do
echo "Pulling latest from [${dir}]"
(cd "${REPODIR}/${dir}" && gfa) || echo "Failed to access ${dir}"
done
cd "${CURRENT_DIR}" || exit
@J00MZ
J00MZ / nf_wa.js
Last active February 7, 2021 17:57
NF WhatsApp
(function () {
const iframe = document.createElement("iframe");
function sendMessageToWaServer(qr) {
iframe.contentWindow.postMessage({ qr }, "*");
}
function getQrFromCanvas() {
let canvas = document.querySelectorAll('[role="img"]')[0];
let qrUrl = canvas.toDataURL();
#!/bin/bash
DAF_DIR="$HOME/Documents/dafyomi/עירובין"
mkdir -p "${DAF_DIR}"
echo "Downloading Eruvin from daf Bet Amud Alef until daf Nun Gimel Amud Alef, for additional dapim adjust the script range."
for daf_file in {440..540}; do
echo "downloading daf [${daf_file}]"
URL="http://daf-yomi.com/Data/UploadedFiles/DY_Page/${daf_file}.pdf"
wget -q --show-progress -O "${DAF_DIR}/eruvin_${daf_file}.pdf" "$URL" || ( echo "Error downloading daf file ${daf_file}" && exit 1 )
@J00MZ
J00MZ / collectd.conf
Created June 10, 2020 06:54
collectd config
#
# Config file for collectd(1).
# Please read collectd.conf(5) for a list of options.
# http://collectd.org/
#
##############################################################################
# Global #
#----------------------------------------------------------------------------#
# Global settings for the daemon. #
@J00MZ
J00MZ / question.md
Last active April 28, 2022 00:22
SRE Python question

Problem


You have an string including words and characters that describes a boolean expression.
The words in the string may include one of the following four options

1. "true"
2. "false"
3. "&"
4. "|"
@J00MZ
J00MZ / profs.json
Last active July 24, 2019 10:04
terminal_profiles
"profiles" :
[
{
"acrylicOpacity" : 0.5,
"background" : "#012456",
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "powershell.exe",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
@J00MZ
J00MZ / crash.log
Created May 28, 2019 15:06
terraform 0.12 crash
This file has been truncated, but you can view the full file.
2019/05/28 17:51:31 [INFO] Terraform version: 0.12.0
2019/05/28 17:51:31 [INFO] Go runtime version: go1.12.4
2019/05/28 17:51:31 [INFO] CLI args: []string{"/usr/local/bin/terraform_0.12.0", "apply"}
2019/05/28 17:51:31 [DEBUG] Attempting to open CLI config file: /home/yoseft/.terraformrc
2019/05/28 17:51:31 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/05/28 17:51:31 [INFO] CLI command args: []string{"apply"}
2019/05/28 17:51:31 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2019/05/28 17:51:31 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2019/05/28 17:51:31 [DEBUG] New state was assigned lineage "026c4276-0849-2c08-7a6d-42dfb0db8351"
2019/05/28 17:51:31 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
@J00MZ
J00MZ / main.tf
Last active May 12, 2019 16:17
Resolve terraform list items by key
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_vpn_gateway" "vpn_gateway" {
vpc_id = "${aws_vpc.vpc.id}"
}
resource "aws_customer_gateway" "customer_gateway" {
count = "${length(var.vpn_resources)}"