Blog

Set Up a Development Environment

Set Up a Development Environment

May 26, 2020 · by Javier Garza ·
Categories:

The Akamai Development Environment comes in the form of a Docker container pre-loaded with our command line interface (CLI) and many CLI packages and third party tools like HTTPie, curl, and Terraform that allow you to automate the management of Akamai services easily.

Introducing the technology: Docker

Docker containers encapsulate everything an application needs to run (and only those things), and they allow applications to be shuffled between environments easily. For example, you can use the same docker command to run the Akamai Developer environment on Windows, MacOS, and Linux. 

Pre-requisites:

Install Docker Desktop

In order to install Docker, open your browser and go to docker.com and download the right Docker Desktop for your operating system. Once installed, click the docker icon and ensure it says “Docker Desktop is Running”

Provision API credentials

To provision API credentials, log in to control.akamai.com (you must have admin privileges), then open the Identity and Access application and click New Client for Me.

New client for me

In the next screen, you’ll see a list of roles you can grant to the API client. By default, you’ll get the same access as the user who’s creating the API client. 

permissions

Now, click Next as you don’t want to restrict access for this API client right now (you can always go back to change permissions).

API

The next step is to give the API client a name. In terms of naming, a good practice to use a descriptive name which describes the intended usage we are going to give to the client. So we are going to call it “API credentials demo”.

API2

Now, we can grant this client access to individual APIs. We are going to follow “Zero Trust” best practices and give access to just two APIs for now. 

The API we’re going to use is the Property Manager API. In Control Center, search for “property manager”  and select “READ-WRITE” as the access level. This grants the API client access to the endpoints. 

You can repeat the same process for the Diagnostics API and then submit (at the bottom of the screen).

Our API client is created, click the “NEW CREDENTIAL” button to get your API credentials so you can authenticate your API calls. I am going to save the API credentials in a text file called .edgerc, the default location that the Akamai CLI uses.

Running the Docker container

Once you have installed Docker on your platform of choice, you can run one simple command to download and run the Akamai Docker image that will setup the Akamai Development Environment. You can find additional instructions on the Akamai GitHub repository: https://github.com/akamai/akamai-docker

Let’s get started with a quick tutorial to showcase how easy it is to install the Akamai Development Environment. 

Ensure that Docker is installed and running, then run the following command: 

docker run --rm -it --name akamai akamai/akamai-docker

You’ll see something like this in your output:

$ docker run --rm -it --name akamai akamai/akamai-docker
                ___    __                         _
               /   |  / /______ _____ ___  ____ _(_)
              / /| | / //_/ __ `/ __ `__ \/ __ `/ /
             / ___ |/ ,< / /_/ / / / / / / /_/ / /
            /_/  |_/_/|_|\__,_/_/ /_/ /_/\__,_/_/
===============================================================
=  Welcome to the Akamai Docker Image                         =
===============================================================
=  Project page:                                              =
=  https://github.com/akamai/akamai-docker                    =
===============================================================
Akamai DevOps [~] >>

Run Docker in interactive modeThis will:

  • Name your Docker image “akamai” 

  • Grab the contents from Docker Hub under akamai/akamai-docker.

  • Install all the required tools including the CLI and CLI packages you can use to manage different services (HTTPie, Terraform, cURL, and runtime dependencies like Python, Node.js and GoLang)

The Docker Image installs in under 3 minutes, but times can vary depending on internet speeds and CPU.

In order to authenticate your API requests, use the following command:

docker run --rm -it --name akamai -v $HOME/.edgerc:/root/.edgerc akamai/akamai-docker 

You’ll see something like this in your output:

$ docker run --rm -it --name akamai -v $HOME/.edgerc:/root/.edgerc akamai/akamai-docker
                ___    __                         _
               /   |  / /______ _____ ___  ____ _(_)
              / /| | / //_/ __ `/ __ `__ \/ __ `/ /
             / ___ |/ ,< / /_/ / / / / / / /_/ / /
            /_/  |_/_/|_|\__,_/_/ /_/ /_/\__,_/_/
===============================================================
=  Welcome to the Akamai Docker Image                         =
===============================================================
=  Project page:                                              =
=  https://github.com/akamai/akamai-docker                    =
===============================================================
Akamai DevOps [~] >>

There we go, the Akamai Development Environment is now fully installed and launched. You can now go ahead and use the Akamai Development Environment for a wide variety of use-cases. This command binds your local .edgerc file where you can store your Akamai EdgeGrid tokens and bind it to the Docker root .edgerc for execution. 

Tip: you can set up an alias to run the request even faster:

alias akadev="docker run --rm -it --name akamai -v $HOME/.edgerc:/root/.edgerc akamai/akamai-docker"

Binding akadev to the Docker command will actually help speed up the commands as demonstrated below to print the version of the Akamai CLI:

akadev akamai --version

You’ll see something like this in your output:

$ akadev akamai --version
akamai version 1.1.5

Resources

Learn more about docker and setting up a development environment: 

About the author

Javier Garza

 

Javier Garza is a developer advocate at Akamai Technologies where he helps the largest companies on the internet run fast and secure apps by leveraging web performance, security and DevOps best practices. Javier has written many articles on HTTP/2 and web performance, and is the co-author of the O’Reilly Book “Learning HTTP/2.” Javier has spoken at countless developer-related events around the world including well-known conferences like Velocity, AWS Re:Invent, and PerfMatters. His life’s motto is: share what you learn, and learn what you don’t. In his free time he enjoys challenging workouts and volunteering for non-profits that provide educational resources to children.