Skip to content

Instantly share code, notes, and snippets.

View zytek's full-sized avatar

Jakub Paweł Głazik zytek

View GitHub Profile
@zytek
zytek / README.md
Last active May 6, 2024 23:16
Terraform to manage AWS RDS PostgreSQL databases, users and owners

Terraform vs PostgreSQL RDS

Thanks to new resources (postgresql_default_priviledges) and some fixes Terraform can now add new databases and manage ownership / access to them.

This example creates new database and two users. You can use owner to create new tables and run migrations and user for normal read/write access to database.

@zytek
zytek / atlantis.yaml
Last active February 8, 2022 12:09
Terraform FMT check on Github Pull Requests via atlantis
# This will run terraform fmt check on pull requests before planning
# Requires atlantis >= 0.4.15
version: 2
automerge: true
projects:
- name: myproject
dir: .
workspace: default
terraform_version: v0.11.11
@zytek
zytek / terraform-s3-iam-recipes.md
Last active February 5, 2020 19:38
Terraform recipes for IAM and S3
####
####
# Terraform manifest that creates spot fleet by copying attributed from currently running instance.
# Is has a lot of copy-pasing due to two terraform 0.11 bugs
# - tags with dots in key names forced to copy-paste them in this manifest
# - instance data source does not provide user data script so it had to be manually copied to a file along with this manifest
# both bugs are being worker on in terraform 0.12
data "aws_caller_identity" "current" {}

Keybase proof

I hereby claim:

  • I am zytek on github.
  • I am zytek (https://keybase.io/zytek) on keybase.
  • I have a public key ASC7BCPFxteYsEAxwiaxBV75RWaZKqR1c8FAFjWe5TKRTgo

To claim this, I am signing this object:

@zytek
zytek / rds-snapshot-copy.sh
Last active May 18, 2018 09:09
Copy newest RDS snapshot between regions
set -e
set -u
SOURCE_REGION=us-west-2
DEST_REGION=eu-west-1
INSTANCE_IDENTIFIER=db-instance
SNAPSHOT_ARN=$(aws rds describe-db-snapshots --region $SOURCE_REGION --db-instance-identifier "$INSTANCE_IDENTIFIER" \
--query "DBSnapshots[? Status=='available']" \
| jq -r 'sort_by(.SnapshotCreateTime) | .[-1] | .DBSnapshotArn')
@zytek
zytek / lvm.txt
Created February 29, 2016 13:27
Create LVM PV+VG+LV volume
DISK=/dev/xvdd
VGNAME=vgjava
LVNAME=lvjava
pvcreate $DISK
vgcreate $VGNAME $DISK
lvcreate -l 100%free $VGNAME -n$LVNAME
mkfs.ext4 /dev/$VGNAME/$LVNAME