Last active
December 15, 2017 16:43
-
-
Save akrabat/0532dd126b4aa392b796a2a9b0e8f125 to your computer and use it in GitHub Desktop.
Binding an ElephantSQL's credentials to a Bluemix OpenWhisk action
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
# A simple action to prove it works | |
$ cat myaction.php | |
<?php | |
function main(array $args) : array | |
{ | |
return $args; | |
} | |
$ bx wsk action update myaction myaction.php | |
# Create the PostgreSQL database | |
$ bx service create elephantsql turtle mydatabase | |
# Create some credentials for the database | |
$ bx service key-create mydatabase openwhisk-creds | |
# Bind the credentials to the "myaction" action | |
$ bx wsk service bind elephantsql myaction --instance mydatabase --keyname openwhisk-creds | |
# Run the action to prove it works | |
$ bx wsk action invoke myaction -r | |
{ | |
"__bx_creds": { | |
"elephantsql": { | |
"credentials": "openwhisk-creds", | |
"instance": "mydatabase", | |
"max_conns": "5", | |
"uri": "postgres://******:******@packy-01.db.elephantsql.com:5432/uhbbioqq" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment