Skip to content

Instantly share code, notes, and snippets.

View brikis98's full-sized avatar

Yevgeniy Brikman brikis98

View GitHub Profile
@brikis98
brikis98 / terraform-environments-comparison.md
Last active May 30, 2023 23:52
How to manage multiple environments with Terraform comparison table
Workspaces Branches Terragrunt
Minimize code duplication ■■■■■ □□□□□ ■■■■□
See and navigate environments □□□□□ ■■■□□ ■■■■■
Different settings in each environment ■■■■■ ■■■■□ ■■■■■
Different backends for each environment □□□□□ ■■■■□ ■■■■■
Easy to manage multiple backends □□□□□ ■■■■□ ■■■■■
Different versions in each environment □□□□□ ■■□□□ ■■■■■
Share data between modules ■■□□□ ■■□□□ ■■■■■
Work with multiple modules concurrently □□□□□ □□□□□ ■■■■■

Keybase proof

I hereby claim:

  • I am brikis98 on github.
  • I am brikis98 (https://keybase.io/brikis98) on keybase.
  • I have a public key whose fingerprint is 244F 9804 C5B4 EBB7 BBC6 CFD8 EFA1 0183 0BB0 B4DE

To claim this, I am signing this object:

@brikis98
brikis98 / main.tf
Last active March 14, 2023 23:43
A hacky way to create a dynamic list of maps in Terraform
# The goal: create a list of maps of subnet mappings so we don't have to statically hard-code them in aws_lb
# https://www.terraform.io/docs/providers/aws/r/lb.html#subnet_mapping
locals {
# These represent dynamic data we fetch from somewhere, such as subnet IDs and EIPs from a VPC module
subnet_ids = ["subnet-1", "subnet-2", "subnet-3"]
eips = ["eip-1", "eip-2", "eip-3"]
}
# Here's the hack! The null_resource has a map called triggers that we can set to arbitrary values.
# We can also use count to create a list of null_resources. By accessing the triggers map inside of
@brikis98
brikis98 / script.js
Last active March 7, 2018 00:15
Get course summary from Teachable
var result = $('.section-item .item').get().reduce(function(total, item) {
var text = $(item).text().split("\n").join(" ");
var matches = /.+\((\d):(\d\d)\)/g.exec(text);
var minutes = parseInt(matches[1]);
var seconds = parseInt(matches[2]);
var totalMin = total[0] + minutes;
var totalSec = total[1] + seconds;
@brikis98
brikis98 / main.tf
Last active October 12, 2016 10:17
Conditionals with inline attributes in Terraform
resource "aws_dynamodb_table" "one_attribute" {
count = "${replace(replace(var.num_attributes, "1", "1"), "/^[^1]$/", 0)}"
name = "${var.name}"
attribute {
name = "${var.first_attribute_name}"
type = "${var.first_attribute_type}"
}
}
@brikis98
brikis98 / keybase.md
Created March 4, 2016 05:23
keybase.md

Keybase proof

I hereby claim:

  • I am brikis98 on github.
  • I am brikis98 (https://keybase.io/brikis98) on keybase.
  • I have a public key whose fingerprint is 2543 515A DE47 7C73 3388 F250 5B46 DF05 5BAD 069A

To claim this, I am signing this object:

class MyEnvironment extends Environment[MyUser, CookieAuthenticator] {
override val identityService: IdentityService[MyUser] = new MyIdentityService()
override val authenticatorService: AuthenticatorService[CookieAuthenticator] = new CookieAuthenticatorService(
settings = CookieAuthenticatorSettings(),
dao = None,
fingerprintGenerator = new DefaultFingerprintGenerator(),
idGenerator = new SecureRandomIDGenerator(),
clock = Clock()
)
@brikis98
brikis98 / gist:4c7a7432f70699d88841
Created June 7, 2015 02:03
bashprof output on running a sourced function using the run method in bats
brikis98-pro:docker-osx-dev brikis98$ ../bashprof/bin/bashprof bats test/docker-osx-dev.bats
✓ configure_paths_to_sync with non-existent docker-compose file results in syncing the current directory
1 test, 0 failures
Statement breakdown
===================
Total µs Total % Count Statement
123368 15.4% 306 [[ "$line" =~ $pattern ]]
@brikis98
brikis98 / gist:cc86ff010ac2838a00fe
Created June 7, 2015 02:02
bashprof output on running a sourced function directly in bats
brikis98-pro:docker-osx-dev brikis98$ ../bashprof/bin/bashprof bats test/docker-osx-dev.bats
✓ configure_paths_to_sync with non-existent docker-compose file results in syncing the current directory
1 test, 0 failures
Statement breakdown
===================
Total µs Total % Count Statement
814081 51.5% 3 IFS= read -r line
@brikis98
brikis98 / gist:e71d6c736158080968f5
Created April 16, 2015 19:34
Getting a sorted list of tags in Jekyll with no plugins
{% capture tags %}{% for tag in site.tags %}{{ tag[0] }}|{% endfor %}{% endcapture %}
{% assign sortedtags = tags | split:'|' | sort %}
{% for tag in sortedtags %}
<a name="{{ tag }}"></a>
<h2>{{ tag }}</h2>
<ul>
{% for post in site.tags[tag] %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}