Site iconAxway Blog

Deploy an API Builder container to AWS Fargate

Deploy an API Builder container to AWS Fargate

In a prior blog post we looked at how to deploy API Builder containers on Google Cloud Run. In this blog post we will see how we can easily deploy an API Builder container using AWS Fargate.

For this blog post, you will need familiarity and access to the following:

You will also need a working and tested API Builder project.

The basic steps are:

We will describe the steps from start to finish, and when we are done we will have an API deployed in AWS Fargate that can be publicly accessed over the internet. Most of the work involved is in setting up CLI’s (which is a one time task) and getting an API Builder Docker image into the Elastic Container Registry. Creating the Fargate/ECS service is actually quite quick and easy.

Create Repository in ECR

Start at the ECR repositories page:

Note that I will use the API Builder Stock Watchlist API described here.

Push Container Image to ECR

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/w3u3w3k3
docker build -t watchlist .
docker tag watchlist:latest public.ecr.aws/w3u3w3k3/watchlist:latest
docker push public.ecr.aws/w3u3w3k3/watchlist:latest

When the docker push command is complete you should see an image in your ECR repository that you just created:

Create Fargate Service

Click Get Started

curl --location --request GET 'http://3.93.25.230:8080/api/watchlist?stocklist=aapl,txn,intc,amzn,t' --header 'accept: application/json' --header 'apikey: 123456789'

The response for the watchlist API should be:

[
  {
    "symbol": "AAPL",
    "lastPrice": 137.89,
    "change": -4.75
  },
  {
    "symbol": "TXN",
    "lastPrice": 158.33,
    "change": -3.25
  },
  {
    "symbol": "INTC",
    "lastPrice": 39.275,
    "change": -0.7349968
  },
  {
    "symbol": "AMZN",
    "lastPrice": 109.79,
    "change": -6.3600006
  },
  {
    "symbol": "T",
    "lastPrice": 20.755,
    "change": -0.125
  }
]

Note that the API will be accessible via http on port 8080. We’ll look at how to modify the security settings so that the API will be accessible via https in a future blog post.

Summary

AWS Fargate offers a simple way to deploy API Builder Docker images. In this blog post we worked through the steps required to publish your API Builder API to AWS Fargate and test it.

Need help with API Builder? Extend your skills with Axway University.

Exit mobile version