AWS Elastic Beanstalk

This page will show you how to create API models when your service runs as a Docker container in Amazon Elastic Beanstalk.

If your Elastic Beanstalk application uses one of the supported languages directly, rather than as a Docker container, see Other Ways to Build API Models. You can also run the Akita agent on the underlying EC2 instances that run your Elastic Beanstalk application: see Single Host/VM. But, we do not have an integration in place that automates placement of the agent or ensures that it is kept up-to-date as Elastic Beanstalk grows or shrinks your cluster.

Elastic Beanstalk provides three ways to configure Docker applications; please find the section below that corresponds to your usage.

Using Docker Compose

Add the Akita CLI as an additional service to your docker-compose.yml file:

services:
  ...
  akita:
    container_name: akita
    image: public.ecr.aws/akitasoftware/akita-cli:latest
    
    env_file:
      - .env

    network_mode: "host"
    entrypoint: /akita apidump --service <your project here>

This configures the Akita CLI to listen for all traffic on the host, and upload it to the project you created during Set up the App. The CLI will receive the API key as an environment variable. The next section describes how to configure the values that are placed in the .env file through the Amazon web console.

Add the Akita API key as an environment property

Go the "configuration" section of the Elastic Beanstalk environment where you'll be deploying Akita. Edit the "software" category, and add environment properties named AKITA_API_KEY_ID and AKITA_API_KEY_SECRET, using the values of the API key you created:

2393

Creating an Application using a Dockerfile

If your application has only a single Dockerfile, then the easiest way to get Akita working is to use akita learn as a wrapper around your normal entry point.

Add the following line to your Dockerfile to install the latest Akita client.

RUN bash -c "$(curl -L https://releases.akita.software/scripts/install_akita.sh)"

Alternatively, you can download the Akita CLI's Debian package and copy it into the Dockerfile for installation, instead of running our install script each time. See Install on Linux.

Next, change the CMD directive in your Dockerfile to run the Akita CLI and start your previous entry point as a subprocess:

CMD ["/usr/local/bin/akita", "apidump", "--service", "<your project name>", \
     "-u", "root", "-c", "<your normal commnand line>", \
     "--rate-limit", "1000"]

You may instead choose to run Akita as a background process, but this requires writing a script that will do so during container start, before launching your normal main process.

Next, use the procedure above labeled "Add the Akita API key as an environment property" to make the API key available to the akita CLI.

Creating an Application using Dockerrun.aws.json

The Dockerrun.aws.json file is a version of the Amazon ECS task definition, so we can run the Akita CLI as a separate container using host networking (on Linux clusters), rather than modifying your existing Container. Add the following container definition to your configuration file:

{
  "containerDefinitions" : [
  ...
    {
      "name": "akita",
      "image": "public.ecr.aws/akitasoftware/akita-cli:latest",
      "essential": false,
      "memory": 256,
      "networkMode": "host",
      "entrypoint": ["/akita", "apidump, "--service", "<your project here>"]
    }
  ]

This will start an instance of the Akita CLI on each host, and monitor all network traffic on that host.

Next, use the procedure above labeled "Add the Akita API key as an environment property" to make the API key available to the akita CLI as an environment variable.

❗️

The configuration using Dockerfile.aws.json has not been fully tested; please contact us on the Akita Slack if you run into any difficulty, and we'll be happy to help.

Deploying to Elastic Beanstalk

Deploy the new version of your application as you normally would. The Akita agent will automatically start creating traffic, and a model will be created on the Akita console.