Skip to content

Instantly share code, notes, and snippets.

@akrabat
Last active December 15, 2017 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akrabat/0532dd126b4aa392b796a2a9b0e8f125 to your computer and use it in GitHub Desktop.
Save akrabat/0532dd126b4aa392b796a2a9b0e8f125 to your computer and use it in GitHub Desktop.
Binding an ElephantSQL's credentials to a Bluemix OpenWhisk action
# 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