Guest User

Untitled

a guest
Apr 24th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -eu
  4. [ "$#" -eq 1 ] || (echo "Usage: $0 db_name"; exit 1)
  5.  
  6. # CHANGEME
  7. cd /paas-bootstrap
  8.  
  9. docker pull postgres:9.5-alpine
  10. db_hostname=$(
  11. aws s3 cp s3://gds-paas-${DEPLOY_ENV}-state/cf.tfstate - \
  12. | jq -r '.modules[].outputs["cf_db_address"].value' \
  13. )
  14.  
  15. db_password=$(
  16. concourse/scripts/val_from_yaml.rb \
  17. secrets_cf_db_master_password \
  18. <(aws s3 cp s3://gds-paas-${DEPLOY_ENV}-state/cf-secrets.yml -) \
  19. )
  20.  
  21. TUNNEL=5432:${db_hostname}:5432
  22. export TUNNEL
  23.  
  24. make tunnel
  25. trap 'make stop-tunnel' EXIT
  26.  
  27. docker run --rm -ti \
  28. -e PGPASSWORD="${db_password}" \
  29. postgres:9.5-alpine \
  30. psql \
  31. --host=docker.for.mac.localhost \
  32. --username=dbadmin \
  33. --dbname="$1"
Add Comment
Please, Sign In to add comment