Provision properties
Create and manage the rule trees, behaviors, and criteria that process how your site's requests, responses, and other objects are served across our platform with property configurations.
Before you begin
- Understand the basics of Terraform.
- Complete the steps in Get started.
- Install Terraform CLI.
- Create or get your existing edge hostname.
What you'll do
Configure a property with defined rules, behaviors, and trigger criteria that trigger action to control how edge servers respond to various kinds of requests to your site and its content.
Tip
The Terraform VS Code Extension includes a dynamic edit feature that pulls in Property documentation and provides a list of available behaviors and match criteria.
1. Create or import a property
Create a new property or import an existing one to get a rule format and rule tree to spec out your rules.
Create new
-
Add a unique name and your product, contract, and group IDs to the
akamai_property resource
with a rule format value no earlier thanv2023-01-05
.resource "akamai_property" "new-property" { name = "my-new-property" product_id = "prd_product" contract_id = "ctr_C-0N7RAC7" group_id = "grp_12345" rule_format = "v2023-01-05" }
-
Run
terraform plan
to check your syntax, and if it's correct, runterraform apply
to create a property with the default rule format.
Import a property
-
Get a list of all of your properties to find the name of the property with the rule tree you want.
data "akamai_properties" "get-my-properties" { contract_id = "ctr_C-0N7RAC7" group_id = "grp_12345" } output "my-property-list" { value = data.akamai_properties.get-my-properties }
-
Use the name of the property you want as the value for the
export-property
argument of theakamai
CLI command.
By default, Terraform imports your latest property version whether it is active or not. Pass a version number with the--version
command flag to target a specific version.Exporting includes using the
--schema
flag requires use of rule format no earlier thanv2023-01-05
. If you've got an earlier date, update your rule format.akamai terraform --edgerc {location-of-your-edgerc-file} --section {section-of-edgerc-to-use} export-property --version {property-version-number} {property-name}
The response is your entire property configuration with its rules in JSON format.
-
Run the included import script to populate your Terraform state. This prevents Terraform from attempting to recreate your assets.
2. Set up your rules
Property configuration rules and includes use behaviors to determine the action taken when specific conditions are met. The options you choose define both the rule's behavior and the criteria that trigger the behavior's action.
Each rule format version contains the schema for a set of rules, behaviors, options, and criteria.
For more on how to work with the schema, see Property behaviors.
Update rule format
To update your rule format, pass the rule format version you need in the property resource.
resource "akamai_property" "update-rule-format" {
name = "my-property"
product_id = "prd_product"
contract_id = "ctr_C-0N7RAC7"
group_id = "grp_12345"
rule_format = "v2023-01-05"
}
Update rules
You can make edits to the full JSON file you pulled down or if you only want to update one or two rules, you can pass just those snippets using rule templates.
Whether you made edits or want to reuse an exported rule tree, you need to associate them with a property so you can activate them on a network.
If you made your updates directly in your rules JSON file, pass the path to the file in the property resource.
resource "akamai_property" "add-my-rules" {
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")
}
If you updated your files using rule templates, pass an absolute or relative path to the files in the rules template data source and then point to the data source in the property resource.
data "akamai_property_rules_template" "template-update" {
template_file = abspath("${path.root}/property-snippets/main.json")
}
resource "akamai_property" "example" {
contract_id = "ctr_C-0N7RAC7"
group_id = "grp_12345"
rule_format = "v2023-01-05"
rules = data.akamai_property_rules_template.template-update.json
}
To apply your rules on a network, activate your property.
3. Activate your property
Activate your property on staging first, promoting your configuration to production when you're satisfied with your test results.
To activate your property, use the property activation resource.
// Staging network example. Change network value to production for production environment.
resource "akamai_property_activation" "my_staging_activation" {
property_id = "prp_12345"
contact = [jsmith@example.com]
version = "latest"
network = "staging"
note = "Activating my property on staging."
}
Updated about 1 month ago