GuideReference
TrainingSupportCommunity
Guide

Add custom cache layer

🚧

Beta

While the underlying code for our Cloud Wrapper subprovider has been vetted, we’ve placed the beta label here only to collect your feedback and work through any issues.

Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.

What you'll do

Create and activate a Cloud Wrapper configuration and associate it with an existing property on the production network.

1. Create new configuration

Get your contract's property IDs and traffic locations and their storage capacity to create a new Cloud Wrapper configuration.

🚧

The properties you want to use Cloud Wrapper with must be activated on the production network.

  1. Determine which properties to associate with your new configuration.

    For each property you want to use, get the property_id and property_name. Use the ID to create your Cloud Wrapper configuration and the name to associate it with your property.

  2. Get your contract's traffic locations.

    data "akamai_cloudwrapper_locations" "my_locations" {
    }
    
    output "my_locations" {
      value = data.akamai_cloudwrapper_locations.my_locations
    }
    
    Changes to Outputs:
    + my_locations = {
        + id        = "akamai_cloudwrapper_locations"
        + locations = [
            + {
                + location_id           = 1
                + location_name         = "United Kingdom"
                + multi_cdn_location_id = ""
                + traffic_types         = [
                    + {
                        + location_id     = "cw-s-gb"
                        + traffic_type    = "LIVE_VOD"
                        + traffic_type_id = 1
                      },
                    + {
                        + location_id     = "cw-s-gb-live"
                        + traffic_type    = "LIVE"
                        + traffic_type_id = 2
                      },
                  ]
              },
            + {
                + location_id           = 2
                + location_name         = "US East"
                + multi_cdn_location_id = ""
                + traffic_types         = [
                    + {
                        + location_id     = "cw-s-use-live"
                        + traffic_type    = "LIVE"
                        + traffic_type_id = 3
                      },
                    + {
                        + location_id     = "cw-s-use"
                        + traffic_type    = "LIVE_VOD"
                        + traffic_type_id = 4
                      },
                  ]
              },
          ]
      }
    

    This data source returns an Akamai created traffic_type_id that represents a location and its traffic type combined. Use the values of this ID in the create configuration resource.

  3. Find your location's capacity.

    data "akamai_cloudwrapper_capacities" "my_capacities" {
    }
    
    output "my_capacities" {
      value = data.akamai_cloudwrapper_capacities.my_capacities
    }
    
    Changes to Outputs:
    + my_capacities = {
        + capacities   = [
            + {
                + approved      = {
                    + unit  = "GB"
                    + value = 100
                  }
                + assigned      = {
                    + unit  = "GB"
                    + value = 11
                  }
                + contract_id   = "C-0N7RAC7"
                + location_id   = 1
                + location_name = "United Kingdom"
                + type          = "MEDIA"
                + unassigned    = {
                    + unit  = "GB"
                    + value = 89
                  }
              },
            + {
                + approved      = {
                    + unit  = "GB"
                    + value = 100
                  }
                + assigned      = {
                    + unit  = "GB"
                    + value = 18
                  }
                + contract_id   = "C-0N7RAC7"
                + location_id   = 2
                + location_name = "US East"
                + type          = "MEDIA"
                + unassigned    = {
                    + unit  = "GB"
                    + value = 82
                  }
              },
          ]
        + contract_ids = null
        + id           = "akamai_cloudwrapper_capacities"
      }
    

    The output from this step's data source gives you a unit of measurement, either GB or TB.

    You also get an unassigned capacity value. This value represents the difference between the approved and assigned capacity, giving you the total space you have left for a location.

    You need both the unit and a value within the limits of your approved capacity to create a wrapper configuration.

  4. Create a Cloud Wrapper configuration. Each location uses its own location block.

    resource "akamai_cloudwrapper_configuration" "my_configuration" {
      config_name         = "my_configuration"
      contract_id         = "C-0N7RAC7"
      property_ids        = ["12345"]
      comments            = "My configuration comments"
      location {
        traffic_type_id = 1
        comments        = "My traffic comments"
        capacity {
          value = 1
          unit  = "GB"
        }
      }
    }
    

    Returned to you is a revision hash. This value is required for activation.

2. Activate your wrapper configuration

Activate your configuration so it's available for your properties. Pass your Cloud Wrapper's configuration ID and the revision hash in the body of the wrapper activation resource.

📘

Activation processing takes 3-4 hours.

resource "akamai_cloudwrapper_activation" "my_activation" {
  config_id = 123
  revision  = "r351533eb7270e69c5e8"
}

3. Add to your properties

Once your configuration is active, connect it to your properties.

  1. Add a Cloud Wrapper rule and behavior to your properties' rule trees and set the trigger criteria.

    📘

    Use the rules builder or rules template data sources to help build out your rules.

    {
      "name": "Cloud Wrapper",
      "children": [],
      "behaviors": [
          {
              "name": "cloudWrapper",
              "options": {
                  "enabled": true,
                  "location": "cw-s-usw"
              }
          }
      ],
      "uuid": "auuid491-7d4f-4bd0-885b-c7fae55fuuid",
      "criteria": [
          {
              "name": "requestHeader",
              "options": {
                  "matchOperator": "IS_ONE_OF",
                  "matchWildcardName": false,
                  "matchWildcardValue": false,
                  "matchCaseSensitiveValue": true,
                  "headerName": "enable-cw",
                  "values": [
                      "true"
                  ]
              }
          }
      ],
      "criteriaMustSatisfy": "all",
      "comments": ""
    }
    
  2. Update each of your property configurations to include your new rule. Use multiple property resources if you're updating more than one.

    resource "akamai_property" "add_cw_rule" {
        name        = "my-property"
        product_id  = "prd_product"
        contract_id = "ctr_C-0N7RAC7"
        group_id    = "grp_12345"
        rule_format = "v2023-01-05"
        rules       = file("${path.root}/property-snippets/main.json")
    }
    
  3. Reactivate your property to enable your Cloud Wrapper configuration on the production network.

    resource "akamai_property_activation" "my_reactivation" {
        property_id                    = "prp_12345"
        network                        = "production"
        contact                        = ["jsmith@example.com"]
        note                           = "Sample activation"
        version                        = "2"
        auto_acknowledge_rule warnings = true
    }