GuideReference
Guide

Hostname bucket

akamai_property_hostname_bucket

📘

This applies only to properties of the HOSTNAME_BUCKET type.

Add or remove hostnames from your property's bucket. To perform these operations, first, your hostname bucket property needs to be activated on the staging or production network.

With this resource, you can configure and manage up to 100,000 hostnames. You can have a maximum of two hostname bucket resources per property, one for staging and one for production.

Changes to the hostname bucket, whether addition or deletion, are independent of property activations and don't create a new property version. However, they do trigger a hostname activation for a specified network, staging or production, and will apply to all versions of the property.

Notes:

  • If any other hostname activation or property version activation is in progress, the PATCH request will fail.
  • You need to split your PATCH request if the number of changes is greater than 1000 hostnames.
  • To reduce log volume and speed up the processing of terraform plan and apply commands, set the Terraform-specific environment variable TF_LOG_SDK_FRAMEWORK to one of these values: OFF, ERROR, or WARN. This helps the hostname bucket resource manage up to 100,000 hostnames.
resource "akamai_property_hostname_bucket" "my-hostname-bucket" {
  property_id = "12345"
  network     = "STAGING"
  hostnames = {
    "example.com" : {
      cert_provisioning_type = "DEFAULT",
      edge_hostname_id       = "12345"
    },
    "other.example.com" : {
      cert_provisioning_type = "DEFAULT",
      edge_hostname_id       = "98765"
    },
  }
}
resource "akamai_property_hostname_bucket" "my-hostname-bucket" {
  property_id            = "12345"
  contract_id            = "C-0N7RAC7"
  group_id               = "12345"
  network                = "STAGING"
  timeout_for_activation = 300
  note                   = "Sample note"
  notify_emails          = ["jsmith@email.com"]
  hostnames = {
    "example.com" : {
      cert_provisioning_type = "DEFAULT",
      edge_hostname_id       = "12345"
    },
    "other.example.com" : {
      cert_provisioning_type = "DEFAULT",
      edge_hostname_id       = "98765"
    },
  }
}
resource "akamai_property" "my-new-property" {
  name                = "my-new-property"
  product_id          = "prd_Download_Delivery"
  contract_id         = "C-0N7RAC7"
  group_id            = "12345"
  rule_format         = "v2024-10-21"
  rules               = file("${path.root}/property-snippets/main.json")
  use_hostname_bucket = true
}

resource "akamai_property_activation" "my-staging-activation" {
  property_id = akamai_property.my-new-property.id
  contact     = ["jsmith@example.com"]
  version     = akamai_property.my-new-property.latest_version
  network     = "STAGING"
  note        = "Activating my property on staging."
}

resource "akamai_cps_third_party_enrollment" "my-enrollment" {
  contract_id    = "C-0N7RAC7"
  common_name    = "example.com"
  secure_network = "enhanced-tls"
  sni_only       = true
  // The rest of attributes are removed for brevity
}

data "akamai_cps_csr" "my-csr" {
  enrollment_id = akamai_cps_third_party_enrollment.my-enrollment.id
}

output "my-csr" {
  value = data.akamai_cps_csr.my-csr
}

resource "akamai_cps_upload_certificate" "upload-cert" {
  enrollment_id                          = akamai_cps_third_party_enrollment.my-enrollment.id
  certificate_ecdsa_pem                  = example_cert_ecdsa.pem
  trust_chain_ecdsa_pem                  = example_trust_chain_ecdsa.pem
  acknowledge_post_verification_warnings = true
  acknowledge_change_management          = true
  wait_for_deployment                    = true
}

resource "akamai_edge_hostname" "my-edge_hostname" {
  product_id          = akamai_property.my-new-property.product_id
  contract_id         = "C-0N7RAC7"
  group_id            = "12345"
  edge_hostname       = "example.com.edgekey.net"
  ip_behavior         = "IPV4"
  status_update_email = ["jsmith@email.com"]
}

resource "akamai_property_hostname_bucket" "my-property-hostname-bucket" {
  property_id = akamai_property_activation.my-staging-activation.property_id
  network     = "STAGING"
  hostnames = {
    (akamai_cps_third_party_enrollment.my-enrollment.common_name) : {
      cert_provisioning_type = "CPS_MANAGED",
      edge_hostname_id       = akamai_edge_hostname.my-edge-hostname.id
    },
  }
}
resource "akamai_property" "my-new-property" {
  name                = "my-new-property"
  product_id          = "prd_Download_Delivery"
  contract_id         = "C-0N7RAC7"
  group_id            = "12345"
  rule_format         = "v2024-10-21"
  rules               = file("${path.root}/property-snippets/main.json")
  use_hostname_bucket = true
}

resource "akamai_property_activation" "my-staging-activation" {
  property_id = akamai_property.my-new-property.id
  contact     = ["jsmith@example.com"]
  version     = akamai_property.my-new-property.latest_version
  network     = "STAGING"
  note        = "Activating my property on staging."
}

resource "akamai_edge_hostname" "my-edge_hostname" {
  product_id          = akamai_property.my-new-property.product_id
  contract_id         = "C-0N7RAC7"
  group_id            = "12345"
  edge_hostname       = "example.com.edgekey.net"
  ip_behavior         = "IPV4"
  status_update_email = ["jsmith@email.com"]
}

resource "akamai_property_hostname_bucket" "my-property-hostname-bucket" {
  property_id = akamai_property_activation.my-staging-activation.property_id
  network     = "STAGING"
  hostnames = {
    "example.com" : {
      cert_provisioning_type = "DEFAULT",
      edge_hostname_id       = akamai_edge_hostname.my-edge-hostname.id
    },
  }
}

Arguments

Pass your property ID, network, and hostnames to add them to a property's bucket. If your property belongs to more than one contract and group, add the group and contract IDs.

Argument Required Description
property_id Your property's ID.
network The network to activate on, either STAGING or PRODUCTION.
hostnames A mapping of public hostnames to edge hostnames. The map key is the cname_from attribute. Includes:
  • edge_hostname_id. Required. The edge hostname's ID.
  • cert_provisioning_type. Required. Your certificate's provisioning type. Possible values:
    • CPS_MANAGED for custom certificates you provision.

      Notes:
      • CPS_MANAGED certificates must be deployed on the production network even if you want to add hostnames to a staging network. To deploy such certificates, they must be active on staging and production networks.
      • When using CPS_MANAGED certificates, cname_from must be equal to the common_name or one of the sans from the DV or third-party enrollment resource.
    • DEFAULT for certificates provisioned automatically.

      Notes:
      • When the DEFAULT certificate's production or staging status is PENDING, EXPIRING_SOON_NEEDS_VALIDATION, or EXPIRED_NEEDS_VALIDATION, perform a domain validation to prove you control the domain. You can do this by adding a CNAME record to your DNS.
      • When using DEFAULT certificates, cname_from doesn't need to match any value from CPS, since PAPI will be providing the certificate.
contract_id Your contract's ID.
group_id Your group's ID.
note A human-readable message about the request.

Note: A note change doesn't trigger a hostname activation.
notify_emails A list of email addresses to notify when the activation status changes.

Note: A notify_emails change doesn't trigger a hostname activation.
timeout_for_activation The timeout value in minutes after which a single hostname activation will be canceled. Defaults to 50 minutes.

Attributes

If you've not set an output method, the response only provides a success message with the resource's ID.

Setting an output method returns the hostname bucket details you provided on create along with these computed attributes.

Attribute Description
id The resource's ID in the property_id:network format.
activation_id The latest hostname bucket activation's ID if the activation was a successful PATCH or CANCEL request.
hostnames A mapping of public hostnames to edge hostnames. Includes this computed attribute:
  • cname_to. The hostname for edge content.
pending_default_certs The number of hostnames with a DEFAULT certificate type that are still in the PENDING state.

Run the Hostnames data source with the filter_pending_default_certs argument to see which hostnames are still in the PENDING state and get information about the target value of a CNAME record used to validate the domain.
hostname_count The computed number of hostnames that will be active after applying desired changes. Used only to inform during the plan phase.