Skip to content

Instantly share code, notes, and snippets.

@vancluever
vancluever / acme-new-config.tf
Last active May 18, 2017 20:00
Brainstorming config for work to get terraform-provider-acme upstream
variable "cert_domains" {
type = "list"
default = [
"www.example.com",
"www.example.org",
]
}
provider "acme" {
@vancluever
vancluever / DIFFNOTES.md
Created May 24, 2017 17:59
Terraform ResourceDiff notes

Why we don't want to use diff in ResourceDiff

  • scheamMap.diff needs d (and a bunch of other stuff)
  • writers don't generally need this stuff
  • relationship should be
  • scheaMap -> resource helper -> reader/writer

Challenges

  • Storing computed values in a pseudo-diff correctly
  • newValueWriter - A map[string]struct{Value interface{} Computed bool}
  • OR
@vancluever
vancluever / nomaddiff.log
Last active June 3, 2017 02:25
Nomad diff
2017/06/02 19:18:33 [INFO] Terraform version: 0.9.6 dev f84310e15c4f307fda900cc543894591bf98ea16+CHANGES
2017/06/02 19:18:33 [INFO] Go runtime version: go1.8.3
2017/06/02 19:18:33 [INFO] CLI args: []string{"/home/chrism/Documents/code/GOPATH/bin/terraform", "plan", "-out", "terraform.tfplan"}
2017/06/02 19:18:33 [DEBUG] Detected home directory from env var: /home/chrism
2017/06/02 19:18:33 [DEBUG] Detected home directory from env var: /home/chrism
2017/06/02 19:18:33 [DEBUG] Attempting to open CLI config file: /home/chrism/.terraformrc
2017/06/02 19:18:33 [INFO] CLI command args: []string{"plan", "-out", "terraform.tfplan"}
2017/06/02 19:18:33 [DEBUG] Detected home directory from env var: /home/chrism
2017/06/02 19:18:33 [DEBUG] command: loading backend config file: /home/chrism/src/tf_examples/nomad_job_custom_diff_test
2017/06/02 19:18:33 [DEBUG] command: no data state file found for backend config
@vancluever
vancluever / resource_aws_security_group_attachment.go
Created June 6, 2017 15:40
Start of a security group attachment resource (attach a SG to a single instance or ENI)
package aws
import (
"fmt"
"github.com/hashicorp/terraform/helper/schema"
)
func resourceAwsSecurityGroupAttachment() *schema.Resource {
return &schema.Resource{
@vancluever
vancluever / vecty_hello.go
Created June 7, 2017 15:19
A small-ish example on how to use vecty
package plan
import (
"log"
"github.com/davecgh/go-spew/spew"
"github.com/gopherjs/vecty"
"github.com/gopherjs/vecty/elem"
"github.com/gopherjs/vecty/event"
"github.com/gopherjs/vecty/prop"
@vancluever
vancluever / ssh-agent.service
Created January 4, 2018 05:19
SSH agent systemd service
[Unit]
Description=OpenSSH Agent
[Service]
Type=simple
Environment=SSH_AUTH_SOCK="%t/ssh-agent.socket"
ExecStart=/usr/bin/ssh-agent -D -t 14400 -a "${SSH_AUTH_SOCK}"
[Install]
WantedBy=default.target
@vancluever
vancluever / asciinema.bashrc
Created January 4, 2018 05:37
Add a recording signal to your bash prompt if you are using asciinema
if [ -n "${ASCIINEMA_REC}" ]; then
PS1='[\[\e[31m\]•REC\[\e[0m\] \W]\$ '
else
PS1='[\u@\h \W]\$ '
fi
@vancluever
vancluever / genselfsignedcrt.sh
Created February 7, 2018 21:42
OpenSSL self-signed cert one-liner
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout server.key -out server.crt
@vancluever
vancluever / mixed_indent_hcl.go
Created April 26, 2018 21:15
HCL + Go mixed indentation example (vim-airline)
package main
import "fmt"
const fooBar = `
resource "foo" "bar" {
a = "b"
}
`
@vancluever
vancluever / tfr-provider-downloads-ranked.sh
Last active June 3, 2021 20:39
Get Terraform Registry providers, sort by most downloads (use --community to get community providers only)
#!/usr/bin/env bash
getproviders() {
for (( PAGE=1; ; PAGE++ )); do
if [ "$1" == "--community" ]; then
DATA="$(curl -fs "https://registry.terraform.io/v2/providers?filter[tier]=community&page[number]=$PAGE")"
else
DATA="$(curl -fs "https://registry.terraform.io/v2/providers?page[number]=$PAGE")"
fi