Skip to content

Instantly share code, notes, and snippets.

View syscod3's full-sized avatar

Giovanni Ferri syscod3

View GitHub Profile
@syscod3
syscod3 / ssh_key.tf
Created July 15, 2019 09:54 — forked from irvingpop/ssh_key.tf
Terraform external data source example - dynamic SSH key generation
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use:
# "${data.external.ssh_key_generator.result.public_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key_file}" (path)
data "external" "ssh_key_generator" {
program = ["bash", "${path.root}/../ssh_key_generator.sh"]
query = {
customer_name = "${var.customer_name}"
customer_group = "${var.customer_group}"
@syscod3
syscod3 / Metadata_S3.md
Created November 13, 2020 17:51 — forked from ChristophShyper/Metadata_S3.md
Pass metadata between Terraform modules using S3. Much faster than remote state.

Save outputs from a resource to a YAML file:

# Module Alpha
# https://www.terraform.io/docs/providers/aws/r/s3_bucket_object.html
resource "aws_s3_bucket_object" "outputs" {
  bucket = local.metadata_bucket
  key    = "${local.key_path}/organization.yml"
  content = yamlencode({
    "organization_arn" : aws_organizations_organization.default.arn
 "organization_id" : aws_organizations_organization.default.id
@syscod3
syscod3 / Metadata_S3.md
Created November 13, 2020 17:51 — forked from ChristophShyper/Metadata_S3.md
Pass metadata between Terraform modules using S3. Much faster than remote state.

Save outputs from a resource to a YAML file:

# Module Alpha
# https://www.terraform.io/docs/providers/aws/r/s3_bucket_object.html
resource "aws_s3_bucket_object" "outputs" {
  bucket = local.metadata_bucket
  key    = "${local.key_path}/organization.yml"
  content = yamlencode({
    "organization_arn" : aws_organizations_organization.default.arn
 "organization_id" : aws_organizations_organization.default.id
@syscod3
syscod3 / CANBusLogger.pde
Created August 25, 2022 01:20 — forked from SilverCory/CANBusLogger.pde
BMW F800GS CANBUS headlight detection for a lightbar. (double tap and the lightbar will come on). For arduino.
/*
* The aim of this is to try to detect changes in messages.
* A change in a message should correlate to an action/operation performed on the vehicle.
*/
import processing.serial.*;
import java.lang.IllegalArgumentException;
import java.lang.System;
import java.util.Map;

Build a OS image with QEMU and Ubuntu Cloud Image

Prerequirements

  • Packer
  • QEMU
  • Docker

Build an image of cloud-init settings

@syscod3
syscod3 / FBSD-microVM-README.md
Last active August 31, 2023 11:20 — forked from ctsrc/README.md
Guide: Run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc) with HVF acceleration (Hypervisor.framework)
@syscod3
syscod3 / tf_vars_sort.awk
Created August 30, 2024 09:47 — forked from yermulnik/tf_vars_sort.awk
Sort Terraform (HCL) file by Resource Block Names using GNU `awk`
#!/usr/bin/env -S awk -f
# https://gist.github.com/yermulnik/7e0cf991962680d406692e1db1b551e6
# Tested with GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
# Usage: /path/to/tf_vars_sort.awk < variables.tf | tee sorted_variables.tf
# Note: "chmod +x /path/to/tf_vars_sort.awk" before use
# No licensing; yermulnik@gmail.com, 2021-2024
{
# skip blank lines at the beginning of file
if (!resource_type && length($0) == 0) next
@syscod3
syscod3 / tf_vars_sort.awk
Created August 30, 2024 09:47 — forked from yermulnik/tf_vars_sort.awk
Sort Terraform (HCL) file by Resource Block Names using GNU `awk`
#!/usr/bin/env -S awk -f
# https://gist.github.com/yermulnik/7e0cf991962680d406692e1db1b551e6
# Tested with GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
# Usage: /path/to/tf_vars_sort.awk < variables.tf | tee sorted_variables.tf
# Note: "chmod +x /path/to/tf_vars_sort.awk" before use
# No licensing; yermulnik@gmail.com, 2021-2024
{
# skip blank lines at the beginning of file
if (!resource_type && length($0) == 0) next
@syscod3
syscod3 / nixos-oracle.md
Created September 3, 2024 15:34 — forked from itsnebulalol/nixos-oracle.md
Install NixOS on an Oracle Cloud VM

NixOS on an Oracle Cloud VM

This gist was made for my own reference, but feel free to follow along. You should use your own Nix flake.

Booting NixOS

Since NixOS is not an official image for use on Oracle Cloud VM's, and users have reported that uploading the NixOS image does not work, we will use kexec to boot the installer.

sudo -i