Skip to content

Instantly share code, notes, and snippets.

View YakDriver's full-sized avatar
🕳️
🌑

Dirk Avery YakDriver

🕳️
🌑
View GitHub Profile
fatal error: concurrent map writes
goroutine 18527 [running]:
github.com/hashicorp/terraform-plugin-log/tflog.SetField.func1(...)
/Volumes/develop/go/pkg/mod/github.com/hashicorp/terraform-plugin-log@v0.7.0/internal/logging/options.go:212
github.com/hashicorp/terraform-plugin-log/tflog.SetField({0xf042c40, 0xc0155e8d50}, {0xdbfb1dd, 0xd}, {0xb38bfe0?, 0xc0155ec0c0})
/Volumes/develop/go/pkg/mod/github.com/hashicorp/terraform-plugin-log@v0.7.0/tflog/provider.go:18 +0x111
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2.setAWSFields({0xf042c40?, 0xc015353ec0?}, 0xc00aa44000)
/Volumes/develop/go/pkg/mod/github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2@v2.0.0-beta.23/logger.go:41 +0xec
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2.logRequest(0xc00aa44000)
@YakDriver
YakDriver / main.tf
Created January 25, 2022 21:27
ECS Cluster, Capacity Provider Destroy Error
provider "aws" {}
locals {
// cluster_name is a local to avoid the cyclical dependency:
// cluster -> capacity provider -> asg -> launch template -> user data -> cluster.
cluster_name = random_pet.name.id
}
data "aws_availability_zones" "current" {
state = "available"
In Terraform provider development, if you were going to automate assigning characteristics of schema elements:
Check where element appears:
i = input (i.e., CreateObjectInput)
u = update (i.e., UpdateObjectInput)
o = output (i.e., DescribeObjectOutput)
This chart tells you when you need computed and forcenew.
func compareStringSlices(a []string, b []string) bool {
if len(a) != len(b) {
return false
}
sort.Strings(a)
sort.Strings(b)
for i := range b {
if a[i] != b[i] {
return false
}
@YakDriver
YakDriver / list-v-set.md
Created September 23, 2020 18:57
AWS Provider - Lists vs. sets

TypeSet vs. TypeList for Arguments and Attributes

General rule:

  1. Use TypeSet when collection elements should be unique and order doesn't matter
  2. Use TypeList otherwise

Special considerations:

  1. If the argument needs to be optional and computed, only TypeList is supported (probably)
  2. For configuration blocks where there can be only one, use TypeList MaxItems 1 to simplify things in the code/testing
@YakDriver
YakDriver / pillars.md
Created September 23, 2020 18:51
Pillars of AWS Provider development
  1. Best is the enemy of good
  2. The purpose of the provider is not to clean up the API
  3. Even when the API seems wrong, follow it. It might actually be right and, if not, you can pass the blame.
@YakDriver
YakDriver / history_count.sh
Created May 13, 2020 22:53
Makefile help - figure out which commands you use most and might want to move to a makefile
history | awk '{print $2 " " $3}' | sort | uniq -c | sort -nr
@YakDriver
YakDriver / terraform12_clean_upgrade.txt
Last active September 18, 2019 21:05
Helpful Visual Studio Code REGEXes to upgrade and clean up Terraform 0.12 config
Assumptions:
- Terraform 0.12 tool has already been run
- Variables fields are in the order: type, description, default (if any)
---------------------------------------------
BOOL
Transform 0.11 string booleans to native bool
---------------------------------------------
Find:(type\s+=\s*)string(\n\s+description.*\n\s+default\s+=\s+)"(false|true)"
Replace:$1bool$2$3
$ terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_s3_bucket.encrypted will be created
+ resource "aws_s3_bucket" "encrypted" {
2019/05/24 17:44:02 [INFO] Terraform version: 0.12.0
2019/05/24 17:44:02 [INFO] Go runtime version: go1.12.4
2019/05/24 17:44:02 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2019/05/24 17:44:02 [DEBUG] Attempting to open CLI config file: /Users/maviemarcos/.terraformrc
2019/05/24 17:44:02 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/05/24 17:44:02 [INFO] CLI command args: []string{"apply"}
2019/05/24 17:44:02 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2019/05/24 17:44:02 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2019/05/24 17:44:02 [DEBUG] New state was assigned lineage "0eb1377e-4a69-a17b-5ddf-f4d25de5d570"
2019/05/24 17:44:02 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)