Skip to content

Instantly share code, notes, and snippets.

View straubt1's full-sized avatar
💭
Terraform All The Things

Tom Straub straubt1

💭
Terraform All The Things
View GitHub Profile
@straubt1
straubt1 / Terraform on Mac M1.md
Created June 14, 2022 18:38
Notes to install Terraform on M1

Installing the amd64 version of Terraform on Mac with M1

Not all Terraform providers are built for arm64.

One solution here is to install Terraform as amd64 which can be easily done from the downloads page.

However, for those who are using and switching between versions of Terraform often, a more streamlined approach is desirable.

Enter asdf.

@straubt1
straubt1 / main.tf
Last active September 9, 2021 15:45
Using Sensitive Terraform Values in for_each
# Using the 'random_pet' resource to drive the example and treating the "prefix" argument as a secret.
variable "pets" {
description = "Map of 'random_pets' to create. These would be any non-sensitive values used to configure the resource."
type = map(object({
length = number
separator = string
}))
# default for easy demo

Cinnamon Bread

Ingredients

  • 1 cup oil
  • 3 large eggs
  • ½ cup milk
  • ½ teaspoon vanilla
  • 1 cup granulated sugar
  • 2 cups flour
@straubt1
straubt1 / gist:7aa550c0851eb94d689b5531ceaba95f
Created December 10, 2020 21:30
Multiple VPC Endpoint Lookup
locals {
vpc_id = "vpc-xxxxx"
endpoints = [
"com.amazonaws.us-west-2.s3",
"com.amazonaws.us-west-2.ec2",
"com.amazonaws.us-west-2.rds",
]
}
@straubt1
straubt1 / README.md
Last active December 8, 2020 17:02
TFE with Custom Provider in Bundle

Terraform Bundle

terraform is 0.13.5

.
├── plugins
│   └── registry.terraform.io
│       ├── hashicorp
│       │   └── pshdns
│       │       └── 2.1.2
@straubt1
straubt1 / README.md
Last active December 2, 2020 22:40
Local Terraform Provider Diffs in TF 0.12 and TF 0.13

TF 0.12.29

main.tf:

terraform {
  required_providers {
    aws = {}
  }
  required_version = "~> 0.12.29"
locals {
config = {
vm_name_prefix = "mdl"
vm_num_prefix = 1
vm_role = "asrv"
vm_pool_count = 2
vm_servers_per_pool = 2
vm_singleton = false
vm_reserve = true
}
@straubt1
straubt1 / main.tf
Created September 10, 2020 13:35
Terraform 0.13 Variable Validation Rule
terraform {
required_version = "~> 0.13.0"
}
variable "environment_name" {
description = "The environment name."
type = string
validation {
condition = contains(["develop", "stage", "production"], var.environment_name)
@straubt1
straubt1 / restrict-iam-policy.sentinel
Created August 31, 2020 18:32
Sentinel policy to parse an AWS IAM Policy and fail based on not allowed actions
import "tfplan/v2" as tfplan
import "json"
import "types"
// Parametized not allowed list
param not_allowed_actions default [
"s3:*",
"s3:GetObject",
"s3:PutObject",
"kms:*",