Skip to content

Instantly share code, notes, and snippets.

View GregoryWiltshire's full-sized avatar

Gregory Wiltshire GregoryWiltshire

  • Warner Bros. Discovery
  • Atlanta, GA
View GitHub Profile
@GregoryWiltshire
GregoryWiltshire / db.sh
Last active January 12, 2023 20:18
postgres rds debeaver session w/ IAM and ssh tunneling
# useful script if you happen to have any rds instances on private subnets
# with a bastion host to tunnel into And IAM authentication
# Mostly inspired from this article on the AWS blog:
# https://aws.amazon.com/blogs/database/using-iam-authentication-to-connect-with-pgadmin-amazon-aurora-postgresql-or-amazon-rds-for-postgresql/
# Thanks to @mjreed-turner for teaching me all things Linux, as usual
export AWS_DEFAULT_REGION=us-east-1
export AWS_PROFILE=your-aws-creds-profile
export BASTION_EC2_INSTANCE=i-12345678
@GregoryWiltshire
GregoryWiltshire / gist:26f6a05d9741ba7f22d9b23e2e381c8d
Created November 10, 2020 20:36
Tutorial: PUT to Snowflake Internal Stage
brew cask install snowflake-snowsql
snowsql -a <snowflake_instance>.<region> -u <user.name>@COMPANY.com --authenticator=externalbrowser
# login with your federated login in your default browser
# MACOS
> PUT file:///Users/<your_username>/Desktop/test.csv @test_internal_stage;
> use database <YOUR_DB>;

View output of large plan

tf plan -no-color | subl  &

Migrate everything from state A → state B

Temporarily switch to a local states by commenting out any remote backends you have,
and running ‘terraform init’, ‘yes’ to copy the remote to local state files
run:
@GregoryWiltshire
GregoryWiltshire / snowflake_user_table_creates.txt
Created October 8, 2020 13:50
Snowflake User Table Creation History
// anything older than 20 days ago
SET cutoff = current_date() - 20;
SELECT h.query_text,
h.database_name,
h.user_name,
h.role_name,
t.table_name,
u.login_name
FROM snowflake.account_usage.query_history h

Dependencies:
brew install stoken

  1. Click on the RSA link in your email and copy the 'ctfData' string value from the address bar and use it with the command below:
    stoken import --token='com.rsa.securid://ctf?ctfData=YOUR-CTF-DATA-HERE'

  2. Enter your PIN as your password

  3. Get your Device ID or 'Binding ID' from your RSA ID app on your mobile device under the info tab, long pressing over the id also will allow you to share it to yourself.

This is a guide for how to get dbeaver connected to your rds cluster.

Dependencies:

brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk11
brew cask install dbeaver-community
  1. create bastion host to sit inside your vpc, and add ssh keys for your user