Register an API
Register your API to define endpoint constraints used when setting protection or delivery options in other Akamai products and services.
What you'll do
Add or update an API and activate it on an Akamai network.
Convert OpenAPI schema
Whether you're adding your API to our system for the first time or making updates, use the openapi
data source to convert an OpenAPI schema file to our format and pass the reformatted schema through the resource to add your API.
- You don't have to pass resources to register your API. They can be added later.
- To update an API, make changes to your schema file and convert the file again.
-
Flatten your OpenAPI schema into a single JSON or YAML file. Place all referenced items inline or in a components section.
-
Convert your schema file and add it to your state.
Note: Running
terraform plan
orterraform validate
only verify the format of your schema file. To add it, runterraform apply
.data "akamai_apidefinitions_openapi" "my_api" { file_path = "./my-api-schema.json" }
my_schema = { api = jsonencode( { enableApiGateway = true hostnames = [ "my_api_definition.com", ] matchCaseSensitive = true name = "Pet Store" resources = { "/pets" = { description = <<-EOT GET: List all pets POST: Create a pet EOT get = { parameters = [ { description = "How many items to return at one time (max 100)." in = "query" maximum = 1000 name = "limit" type = "integer" }, ] } name = "/pets" post = { requestBody = { json = { name = "Pet" properties = [ { name = "id" required = true type = "integer" }, { name = "name" required = true type = "string" }, { name = "tag" type = "string" }, ] required = true type = "object" } } } } } } ) api_file_name = null file_path = "./my-openapi.yml" }
-
Pass the returned
api
attribute as a local variable to register your collection.resource "akamai_apidefinitions_api" "my_api" { api = akamai_apidefinitions_openapi.my_api.api contract_id = "C-0N7RAC7" group_id = 12345 }
The resource response contains an id
attribute you need to activate your API on a network.
Activate an API
Activate your API collection on an Akamai network so that it's available to other Akamai services.
resource "akamai_apidefinitions_activation" "my_api_activation" {
api_id = akamai_apidefinitions_api.my_api.id
version = 1
network = "STAGING"
notification_recipients = ["jsmith@email.com"]
auto_acknowledge_warnings = true
}
Use your API's ID where needed when you set up protections using other Akamai security services.
Updated about 20 hours ago