Site iconAxway Blog

Deploy an API Builder container to Amazon Lightsail

Deploy an API Builder Container to Amazon Lightsail

In this blog post, we’ll illustrate how to deploy an API Builder Docker container image to Amazon Lightsail, a powerful virtual cloud server.

We’ll use the API Builder watchlist container image on Docker Hub for this example. This API is described in this blog post.

You’ll need the AWS CLI, installed and working properly, and an Amazon Lightsail (or AWS) account.

Getting started

Log into Lightsail and create a container service.

Configure service

Now, let’s configure the container service.

It will take a couple of minutes for the service to be ready

Push container images to your Lightsail Account

You can use the Docker CLI to create a docker image of your API Builder project as described here.

We’ll use the Stock Watchlist Docker Hub image in the instructions below.

docker pull lbrenman/watchlist

aws lightsail push-container-image --region us-west-2 --service-name myservice --label mystaticwebsite --image mystaticwebsite:v2

I used the following command:

aws lightsail push-container-image --region us-east-2 --service-name watchlist --label watchlist --image lbrenman/watchlist
.
.
.
Digest: sha256:386542fc89d5149a7c19881a183f2c052ddbef798538455b08f172111082fac2
Image "lbrenman/watchlist" registered.
Refer to this image as ":watchlist.watchlist.2" in deployments.

Note that for me, the image name is :watchlist.watchlist.2

Create your deployment

curl --location --request GET 'https://watchlist.nu3rimb8ttorq.us-east-2.cs.amazonlightsail.com/api/watchlist?stocklist=aapl,txn,intc,amzn,t' \
--header 'accept: application/json' \
--header 'apikey: 0cded940-51be-4427-a066-bb0e56e3e40f'

with the following response:

[
  {
      "symbol": "AAPL",
      "lastPrice": 168.53,
      "change": 3.6100006
  },
  {
      "symbol": "TXN",
      "lastPrice": 182.17,
      "change": 4.4599915
  },
  {
      "symbol": "INTC",
      "lastPrice": 35.0867,
      "change": 0.5667
  },
  {
      "symbol": "AMZN",
      "lastPrice": 142.29,
      "change": 4.4599915
  },
  {
      "symbol": "T",
      "lastPrice": 18.045,
      "change": -0.055000305
  }
]

Summary

Amazon Lightsail provides a simple means to deploy API Builder Docker Container images. In this blog post we saw detailed instructions for how to do so.

Discover how Amplify API Builder lets you create and deploy perfect APIs in minutes.

Exit mobile version