GuideReference
TrainingSupportCommunity
Guide

Use our Terraform provider to provision and manage your Akamai configurations in Terraform.

Before you begin

What you'll do

Initialize our provider, set up basic authentication, and begin your Akamai configuration set up.

Start your configuration

Your Akamai Terraform configuration starts with listing us as a required provider, stating which version of our provider to use, and initializing both a Terraform session and an install of our provider.

  1. Create a file named akamai.tf in your project directory. This is your base Akamai configuration file.

  2. Add our provider to your file. We require a minimum Terraform version of 1.0.

    terraform {
      required_providers {
        akamai = {
          source  = "akamai/akamai"
          version = "6.6.0"
        }
      }
      required_version = ">= 1.0"
    }
    
    provider "akamai" {
      # Configuration options
    }
    

📘

If you choose to use multiple configuration files to limit the scope of work or to share work across teams, our provider information only needs to be in one.

Add authentication

Authentication credentials for the majority of our API use a hash-based message authentication code or HMAC-SHA-256 created through an API client. Each member of your team use their own client set up locally to prevent accidental exposure of credentials.

There are different types of API clients that grant access based on your need, role, or how many accounts you manage.

API client typeDescription
BasicAccess to the first 99 API associated with your account without any specific configuration. Individual service read/write permissions are based on your role.
AdvancedConfigurable permissions to limit or narrow down scope of the API associated with your account.
ManagedConfigurable permissions that work for multiple accounts.

To set up and use multiple clients, clients that use an account switch key, or clients as environment variables, see Alternative authentication.

Create a basic API client

  1. Navigate to the Identity and Access Management section of Akamai Control Center and click Create API Client.

  2. Click Quick and then Download in the Credentials section.

  3. Open the downloaded file with a text editor and add [default] as a header above all text.

    [default]
    client_secret = C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=
    host = akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net
    access_token = akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij
    client_token = akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj
    
  4. Save your credentials as an EdgeGrid resource file named .edgerc in your local home directory.

    // Linux
    $ /home/{username}/.edgerc
    
    // MacOS
    $ /Users/{username}/.edgerc
    
    // Windows
    C:\Users\{username}\.edgerc
    
  5. In the provider block of your akamai.tf file, add in a pointer to your .edgerc file.

    provider "akamai" {
      edgerc         = "~/.edgerc"
      config_section = "default"
    }
    

Initialize our provider

To install our provider and begin a Terraform session, run terraform init. The response log verifies your initialization along with a notice that the rest of the terraform commands should work.

Set up resources

Each of our subproviders use a set of resource objects that build out infrastructure components and data sources that provide information to and about those resources. Add these to your configurations manually or import them.

Get contract and group IDs

We also require a connection to your company's account, contract, and assets. This is done by adding a contract_id and a group_id to your configuration file.

Use the groups data source to get a list of the groups associated with your contracts.

data "akamai_groups" "my-ids" {
}

output "groups" {
  value = data.akamai_groups.my-ids
}

The response breaks down all groups available to a particular contract. The values can be used directly or as variables.

Test and go live

Check your configuration as you work by using a resource's data source and then activate your configuration in the stage environment for end-to-end testing.

  • terraform fmt to format your config per HCL guidelines.
  • terraform validate to check your config's syntax
  • terraform plan to create an execution plan to preview the changes that Terraform plans to make to your infrastructure.

When you're satisfied with the way things are running, activate your config for the production environment to analyze and respond to user requests.

To activate your configuration, run terraform apply.

🚧

If multiple people are making changes to same configuration file, be mindful that running Terraform's apply command to activate your configuration will overwrite others' changes.