This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TF_LOG=TRACE terraform foo | |
https://www.terraform.io/internals/debugging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# object | |
output "repo_ids" { | |
value = { | |
for idx,repo in aws_ecr_repository.repo : idx => repo.registry_id | |
} | |
} | |
# list | |
output elastic_ips { | |
value = [for eip in aws_eip.eip : eip.id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_network_interface" "subnets" { | |
for_each = { for subnet in module.vpc.public_subnets : subnet.id => subnet } | |
subnet_id = each.value.key | |
} | |
// reference: https://selleo.com/til/posts/cnfrqv1ipl-foreach-over-tuples-in-terraform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "template_file" "codebuild" { | |
template = file("${path.module}/policies/role-policy.json") | |
vars = { | |
aws_s3_bucket_arn = module.aws_s3_bucket.arn[0] | |
} | |
} | |
role-policy.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
iam_access_creds = ( | |
var.create ? | |
var.create_livewire_accesser ? | |
[module.iam[0].access_key_id, module.iam[0].access_key_secret, module.iam-restriction[0].access_key_id, module.iam-restriction[0].access_key_secret] : | |
[module.iam[0].access_key_id, module.iam[0].access_key_secret] : | |
[] | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username LIKE '%zveer%' | |
https://www.tutorialspoint.com/postgresql/postgresql_like_clause.htm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\t | |
\a | |
\o data.json | |
select json_agg(t) FROM (SELECT * from schedules_required_shifts) t; | |
// https://dba.stackexchange.com/questions/90482/export-postgres-table-as-json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dump | |
pg_dump -h localhost -U postgres -p 5432 -Fc -Z 9 --file=local.dump | |
# restore | |
pg_restore -h localhost -U postgres -Fc -j 8 -p 5432 -vvv -d postgres local.dump | |
# source: https://stackoverflow.com/questions/15692508/a-faster-way-to-copy-a-postgresql-database-or-the-best-way |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with auth | |
> psql -h 10.000.0.0 -d mydb -U myuser | |
> psql postgres postgres | |
drop schema public cascade; | |
create schema public; | |
\q and enter to exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this function takes an array of date ranges in this format: | |
// [{ start: Date, end: Date}] | |
// the array is first sorted, and then checked for any overlap | |
function overlap(dateRanges){ | |
var sortedRanges = dateRanges.sort((previous, current) => { | |
// get the start date from previous and current | |
var previousTime = previous.start.getTime(); | |
var currentTime = current.start.getTime(); |