Created
November 9, 2018 08:51
-
-
Save yurenju/d3effbfc0ab7c4c2361a13cd4556e7ce to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -x | |
# Load .env variables | |
export $(egrep -v '^#' .env | xargs) | |
vault secrets enable database | |
vault write database/config/my-database \ | |
plugin_name=mysql-database-plugin \ | |
connection_url="{{username}}:{{password}}@tcp(mysql:3306)/" \ | |
allowed_roles=my-role username=${MYSQL_ROOT_USERNAME} password=${MYSQL_ROOT_PASSWORD} | |
vault write database/roles/my-role \ | |
db_name=my-database \ | |
creation_statements="CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}';GRANT SELECT ON *.* TO '{{name}}'@'%';" \ | |
default_ttl="10s" \ | |
max_ttl="20s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment