How to use IBM Cloud Code Engine to create a backend API for dynamic content in your static website hosted on IBM Cloud Object Storage.
Static websites are great for performance and security. Their architectural model is sometimes referred to as Jamstack (in reference to JavaScript, API and Markup). The static website with its markup (HTML) is hosted on object storage, such as GitHub, GitLab, specialized providers or just simply (cloud) object storage. The embedded JavaScript code can make calls to backend APIs to retrieve dynamic content. This could be maps, feedback forms, guestbooks, etc.
New tutorial
In a new tutorial, we show how such a backend API can be implemented and deployed to IBM Cloud Code Engine as a serverless app. The app interacts with a Cloudant NoSQL database to manage a simple guestbook (see screenshot at the bottom). The HTML page with the JavaScript code that calls the backend API is hosted on IBM Cloud Object Storage (COS) and made publicly available. See the following diagram for the overall architecture:
The backend API to create or retrieve the guestbook is a serverless app. The app is automatically scaled, depending on the workload and within its configured limits. If you expect few requests, it could automatically scale down to zero app instances (and not incur charges). In contrast, if you expect many requests and a high load — maybe not for a guestbook but for a discussion forum — you can configure some minimum instances and a higher upper boundary:
Get started
To deploy your own guestbook based on a static website with a serverless backend API, follow the instruction in the new tutorial: Serverless web application and API with Code Engine. The tutorial uses a pre-built container image for the app for ease of use. Alternatively, you could build your own container image using the source code provided in the GitHub repository serverless-guestbook.
If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn.