Policy image
akamai_imaging_policy_image
Create, update, or delete an image policy within your policy set. Use terraform destroy to remove it.
See Transform images for a complete list of available transformations for an image policy. To define variables in your policy, see Use variables.
resource "akamai_imaging_policy_image" "my-image-policy" {
  activate_on_production = false
  contract_id            = "12345"
  policy_id              = "my-image-policy-1"
  policyset_id           = akamai_imaging_policy_set.my-policy-set.id
  json = jsonencode(
    {
      "rolloutInfo" : {
        "startTime" : 1740163087,
        "endTime" : 1740163088,
        "rolloutDuration" : 1,
        "serveStaleEndTime" : 1740163087
      },
      "breakpoints" : {
        "widths" : [
          300,
          451,
          2039,
          5000
        ]
      },
      "output" : {
        "quality" : 94,
        "adaptiveQuality" : 70
      },
      "transformations" : [
        {
          "transformation" : "Contrast",
          "brightness" : 0.5,
          "contrast" : 0.2
        },
        {
          "gravity" : {
            "var" : "centerGravity"
          }
          "image" : {
            "url" : "www.example.com/image.png"
          },
          "transformation" : "Composite",
          "xPosition" : 0,
          "yPosition" : 0
        },
        {
          "default" : {
            "aspect" : "fit",
            "height" : {
              "var" : "ResizeDim"
            },
            "transformation" : "Resize",
            "type" : "normal",
            "width" : {
              "var" : "ResizeDim"
            }
          },
          "dimension" : "height",
          "lessThan" : {
            "allowExpansion" : true,
            "gravity" : "Center",
            "height" : {
              "var" : "ResizeDim"
            },
            "transformation" : "Crop",
            "width" : {
              "var" : "ResizeDim"
            },
            "xPosition" : 0,
            "yPosition" : 0
          },
          "transformation" : "IfDimension",
          "value" : {
            "var" : "MinDim"
          }
        }
      ],
      "postBreakpointTransformations" : [
        {
          "color" : "#ffffff",
          "transformation" : "BackgroundColor"
        },
        {
          "transformation" : "Blur",
          "sigma" : 5
        }
      ],
      "variables" : [
        {
          "defaultValue" : "280",
          "name" : "ResizeDim",
          "type" : "number"
        },
        {
          "defaultValue" : "10",
          "name" : "MinDim",
          "type" : "number"
        },
        {
          "defaultValue" : "Center",
          "name" : "centerGravity",
          "type" : "gravity"
        }
      ]
    }
  )
}
// Use a path to a JSON-formatted policy
resource "akamai_imaging_policy_image" "my-image-policy" {
  activate_on_production = false
  contract_id            = "12345"
  policy_id              = "my-image-policy-1"
  policyset_id           = akamai_imaging_policy_set.my-policy-set.id
  json                   = file("${path.module}/image_policy.json")
}
// Reference an image policy data source
resource "akamai_imaging_policy_image" "my-image-policy" {
  activate_on_production = false
  contract_id            = "12345"
  policy_id              = "my-image-policy-1"
  policyset_id           = akamai_imaging_policy_set.my-policy-set.id
  json                   = data.akamai_imaging_policy_image.my-image-policy-definition.json
}
Arguments
Send all the required arguments to create an image policy.
| Argument | Required | Description | 
|---|---|---|
| contract_id | ✔ | Your contract's ID. | 
| policy_id | ✔ | Your image policy's ID. If you change this value, Terraform forces a replacement. It destroys your current policy and creates a new one. | 
| policyset_id | ✔ | Your image policy set's ID. | 
| json | ✔ | Your JSON-encoded image policy. | 
| activate_on_production | When set to true, the policy is saved on the production network. You can set it back tofalseonly when there are any changes to the existing policy qualifying it for a new version. Setting it tofalseallows you to make changes on staging without affecting the version already saved to production. Defaults tofalseif not set. | 
Attributes
There is no default standard output. Upon creation, the last line of the process log contains a success message with the resources's id in the policyset_id:policy_id format.
Adding an output block returns the image policy details you provided on create and the computed id and version attributes.
Updated 5 months ago
