Skip to content

Instantly share code, notes, and snippets.

@npearce
Last active November 29, 2018 20:31
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 npearce/13d4d4c72bd4781b96a0a811ffbc454d to your computer and use it in GitHub Desktop.
Save npearce/13d4d4c72bd4781b96a0a811ffbc454d to your computer and use it in GitHub Desktop.
Install Openwhisk on Amazon AMI w/ docker-compose

Install Openwhisk on docker in AWS

  1. Get docker and docker-compose running on Amazon Linux 2: https://gist.github.com/npearce/6f3c7826c7499587f00957fee62f8ee9

  2. git clone https://github.com/apache/incubator-openwhisk-devtools.git

  3. cd incubator-openwhisk-devtools/docker-compose

  4. make quick-start

Make Coffee / Pour some wine

  1. Get the AUTH_KEY used in the installation:

cat ./openwhisk-src/ansible/files/auth.guest

Install CLI tools

  1. Install wsk - https://openwhisk.apache.org/documentation.html#wsk-cli - (Mac)
brew update
brew install wsk
  1. Configure wsk ot communicate with your new Openwhisk installation:

Example: wsk -i property set --apihost API_HOST --auth AUTH_KEY --namespace guest

Where API_HOST is the IP address or Hostname of the new Openwhish install (the docker host in this example), and AUTH_KEY is retrieved in step 5. above.

NOTE: The -i above tells wsk to ignore the self-signed cert.

  1. Install wskdeploy:

brew install wskdeploy

Create a Function

  1. Create file called manifest.yml with the contents:
packages:
  hello_world_package:
    version: 1.0
    license: Apache-2.0
    actions:
      hello_world:
        function: src/hello.js
        runtime: nodejs:6
  1. Create the file src/hello.js with the contents:
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/*
 * Hello, world
 */
function main(params) {
  msg = "Hello, " + params.name + " from " + params.place;
  return { greeting:  msg };
}
  1. Deploy the function to Openwhisk:

wskdeploy -m manifest.yml --strict

NOTE: --strict to override the openwhisk runtime mapping and just use what was specified in the manifest file.

  1. Invoke the function:

wsk -i action invoke /guest/hello_world_package/hello_world --result -v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment