search

Accessing Bluemix Services from AWS Lambda


Many developers may be surprised to learn that services from IBM Bluemix can be called from environments other than IBM Bluemix. In this blog post I am going to show you how you can call the IBM Globalization Pipeline service on IBM Bluemix from Amazon Web Services (AWS) Lambda. So let’s get started.

 

  1. Create an instance of the Globalization Pipeline service on Bluemix and don’t bind it to any application.

    Unbound Instance of Globalization Pipeline Service

    Unbound Instance of Globalization Pipeline Service

  2. Copy the service url and instance id from the Service Credentials tab. We will use these values later when call the RESTful APIs.

    Service Credentials

    Service Credentials

  3. Click on the Manage tab and then select the Users tab from the Globalization Pipeline service’s dashboard and create a New User. Create a user called reader and make the type reader with access to all bundles.

    Globalization Pipeline User

    Globalization Pipeline User

  4. Click Save and then copy the User Id and Password. We will use these values when we call the RESTful APIs.

    User ID and Password

    User ID and Password

  5. Create a resource bundle in the Globalization Pipeline service and translate it into as many languages as you like. Here is a link that shows you how to get started with the Globalization Pipeline service.
  6. Download my sample code and fill in the values for the service url, instance id, user id, and password in the index.js file.
  7. Create an AWS Lambda function on the AWS console and upload the zip archive that contains your modified source code. Here are links that show you how to create AWS Lambda functions.
    Lambda Configuration

    Lambda Configuration

    Upload Lambda Code

    Upload Lambda Code

  8. To test your Lambda function create a test event and use a JSON object that contains the name of your bundle and the language that you translated your bundle into.
    Input Test Event

    Input Test Event

    Sample Output

    Sample Output

    That’s all there is to it. As you can see it is pretty easy to call a Bluemix service from other environments including other clouds.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

close
search

Hi, guest!

settings

menu