Skip to content

Instantly share code, notes, and snippets.

Avatar
🕳️
🌑

Dirk Avery YakDriver

🕳️
🌑
View GitHub Profile
@YakDriver
YakDriver / shell_try_catch.sh
Created Feb 14, 2018
Bash Basics: A Robust try/catch/finally for shell scripts
View shell_try_catch.sh
#!/bin/bash
# This script uses traps to create try/catch/finally functionality in shell scripts.
#
# OUTPUT:
#
# Hello! We're reporting live from script
# ./try_catch2.sh: line 23: badcommand: command not found
# ./try_catch2.sh: line 23: exiting with status 127
# It's the end of the line
View auto_schema.txt
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.
View compare_string_slices.go
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 Sep 23, 2020
AWS Provider - Lists vs. sets
View list-v-set.md

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 Sep 23, 2020
Pillars of AWS Provider development
View pillars.md
  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
Makefile help - figure out which commands you use most and might want to move to a makefile
View history_count.sh
history | awk '{print $2 " " $3}' | sort | uniq -c | sort -nr
@YakDriver
YakDriver / terraform12_clean_upgrade.txt
Last active Sep 18, 2019
Helpful Visual Studio Code REGEXes to upgrade and clean up Terraform 0.12 config
View terraform12_clean_upgrade.txt
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
View panic.log
$ 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" {
View crash.log
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)
@YakDriver
YakDriver / generate_test_script.sh
Created Nov 8, 2018
Get names of Terraform tests from a test file
View generate_test_script.sh
#!/bin/bash
awk '/^func Test/' aws/structure_test.go | sed "s/func \(Test[a-zA-Z0-9_]*\)(.*$/make testacc TESTARGS='-run=\1'/" > tests.sh