Skip to content

Instantly share code, notes, and snippets.

@phinze
phinze / clear-dock.sh
Created January 18, 2020 23:41
Remove all persistent apps from the macos dock
dockutil --list | grep persistent-apps | cut -d $'\t' -f1 | while read thing; do dockutil --remove "${thing}"; done
@phinze
phinze / terraform_dot_workspace_workaround.tf
Created September 23, 2019 19:59
Untested sketch of a workaround for terraform.workspace not resolving in Terraform Cloud.
variable "org" {}
data "tfe_workspace_ids" "all" {
names = ["*"]
organization = var.org
}
resource "tfe_variable" "workspace_name" {
for_each = tfe_workspace_ids.all.*.id
workspace = this.key
@phinze
phinze / teams-to-workspaces.tf
Last active June 21, 2022 04:23
An example of how you could map teams to many workspaces using the Terraform Enterprise provider
# Start w/ a data source to get a list of all the workspaces
# See: https://www.terraform.io/docs/providers/tfe/d/workspace_ids.html
data "tfe_workspace_ids" "all-workspaces" {
names = ["*"]
organization = "my-org-name"
}
# Look up the ID of the teamn you're looking to map
# See: https://www.terraform.io/docs/providers/tfe/d/team.html
data "tfe_team" "architects" {
@phinze
phinze / ennuigi.txt
Created November 17, 2017 23:22
All the reflections from Ennuigi https://www.lexaloffle.com/bbs/?tid=2232
am i...hungry?
no, not hungry. i should
eat something, but i'm
not hungry at all.
---
when did i eat last?
@phinze
phinze / main.tf
Created December 16, 2015 20:43
take a string like "a b c" and turn that in to "a", "b", "c" in the template
variable "input" {
default = "a b c"
}
resource "template_file" "json" {
template = "{ \"somekey\": [${list}] }"
vars {
list = "${join(", ", formatlist("\\"%s\\"", split(" ", var.input)))}"
}
}
provider "aws" {
access_key = "foo"
secret_key = "bar"
region = "us-east-1"
}
module "vpc" {
source = "./tf_aws_vpc"
name = "keyprovidertest"
@phinze
phinze / moving_vpcs.tf
Last active December 3, 2015 14:49
Example for terraform-tool mailing list of moving a subnet between VPCs
# See https://groups.google.com/d/msgid/terraform-tool/db2ee775-e8b8-4e6b-8b3a-35fb182a1571%40googlegroups.com
# Setting region so AMI always works, configure the rest via env vars
provider "aws" {
region = "us-west-2"
}
resource "aws_vpc" "from" {
cidr_block = "10.1.0.0/16"
}
@phinze
phinze / main.tf.js
Created April 15, 2015 21:26
Terraform: Double checking state flags
variable "region" { }
provider "aws" {
region = "${var.region}"
}
module "ami" {
source = "github.com/terraform-community-modules/tf_aws_ubuntu_ami/ebs"
region = "${var.region}"
distribution = "trusty"
@phinze
phinze / main.tf.js
Created April 15, 2015 14:28
Terraform Example: injecting config into an AWS instance
variable "instance_type" {
default = "t2.micro"
}
variable "region" {
default = "us-west-2"
}
variable "custom" {
default = "env-specific-value"
@phinze
phinze / main.tf.js
Last active June 14, 2021 23:20
Terraform Example: ebs_block_device that remains after instance termination
resource "aws_instance" "web" {
ami = "ami-7f89a64f"
instance_type = "t1.micro"
ebs_block_device {
device_name = "/dev/sdg"
volume_size = 5
volume_type = "gp2"
delete_on_termination = false
}
}