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:

Architecture of static website with serverless backend API.

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:

Guestbook with sample entries.

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



More from Cloud

IBM Tech Now: October 2, 2023

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 86 On this episode, we're covering the following topics: AI on IBM Z IBM Maximo Application Suite 8.11 IBM NS1 Connect Stay plugged in You can check out the IBM Blog Announcements for a…

IBM Cloud inactive identities: Ideas for automated processing

4 min read - Regular cleanup is part of all account administration and security best practices, not just for cloud environments. In our blog post on identifying inactive identities, we looked at the APIs offered by IBM Cloud Identity and Access Management (IAM) and how to utilize them to obtain details on IAM identities and API keys. Some readers provided feedback and asked on how to proceed and act on identified inactive identities. In response, we are going lay out possible steps to take.…

IBM Cloud VMware as a Service introduces multitenant as a new, cost-efficient consumption model

4 min read - Businesses often struggle with ongoing operational needs like monitoring, patching and maintenance of their VMware infrastructure or the added concerns over capacity management. At the same time, cost efficiency and control are very important. Not all workloads have identical needs and different business applications have variable requirements. For example, production applications and regulated workloads may require strong isolation, but development/testing, training environments, disaster recovery sites or other applications may have lower availability requirements or they can be ephemeral in nature,…

IBM accelerates enterprise AI for clients with new capabilities on IBM Z

5 min read - Today, we are excited to unveil a new suite of AI offerings for IBM Z that are designed to help clients improve business outcomes by speeding the implementation of enterprise AI on IBM Z across a wide variety of use cases and industries. We are bringing artificial intelligence (AI) to emerging use cases that our clients (like Swiss insurance provider La Mobilière) have begun exploring, such as enhancing the accuracy of insurance policy recommendations, increasing the accuracy and timeliness of…