akamai / terraform-provider-akamai

Terraform Akamai provider
https://www.terraform.io/docs/providers/akamai/
Mozilla Public License 2.0
110 stars 99 forks source link

DXE-4025 Feature request: Cloudlets policy: Provide staging and production versions #564

Open siwinski opened 5 months ago

siwinski commented 5 months ago

The akamai_property resource provides version attributes latest_version, staging_version, and production_version which makes it possible to conditionally activate either the latest version or keep the version already currently activated on a network.

The akamai_cloudlets_policy resource only provides version attribute version (latest version) so it is not possible to conditionally activate the latest version or a version already currently activated on a network. Either the latest version always has to be activated or a hard-coded version can be activated.

See examples below in "Terraform Configuration Files" section.

Terraform and Akamai Terraform Provider Versions

Terraform v1.9.0
on linux_amd64
+ provider registry.terraform.io/akamai/akamai v6.2.0

Affected Resource(s)

akamai_cloudlets_policy

Terraform Configuration Files

Cloudlet activate latest version example:

resource "akamai_cloudlets_policy" "policy" {
  # ...
}

resource "akamai_cloudlets_policy_activation" "staging" {
  # ...
  network = "staging"
  version = akamai_cloudlets_policy.policy.version
}

resource "akamai_cloudlets_policy_activation" "production" {
  # ...
  network = "production"
  version = akamai_cloudlets_policy.policy.version
}

Cloudlet activate hard-coded version example:

resource "akamai_cloudlets_policy" "policy" {
  # ...
}

resource "akamai_cloudlets_policy_activation" "staging" {
  # ...
  network = "staging"
  version = 1
}

resource "akamai_cloudlets_policy_activation" "production" {
  # ...
  network = "production"
  version = 1
}

Property activate conditional version example:

variable "activate_latest_on_staging" {
  type = bool
}

variable "activate_latest_on_production" {
  type = bool
}

resource "akamai_property" "property" {
  # ...
}

resource "akamai_property_activation" "staging" {
  # ...
  network = "STAGING"
  version = (
    var.activate_latest_on_staging
    ? akamai_property.property.latest_version
    : akamai_property.property.staging_version
  )
}

resource "akamai_property_activation" "production" {
  # ...
  network = "PRODUCTION"
  version = (
    var.activate_latest_on_production
    ? akamai_property.property.latest_version
    : akamai_property.property.production_version
  )
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

akamai_cloudlets_policy resources provide staging and production version attributes (in addition to currently-provided latest version attribute) so activation versions can be conditional.

Actual Behavior

akamai_cloudlets_policy resources only provide the latest version attribute so forced to either always activate latest versions or activate hard-coded versions.

Steps to Reproduce

See examples above in "Terraform Configuration Files" section.

Important Factoids

I have tried using akamai_cloudlets_policy and akamai_cloudlets_shared_policy datasources to dynamically determine activated staging and production versions, but that has been proven unreliable as their activations attribute "empties" when new cloudlet versions are created but not activated right away (perhaps this is a bug in the datasources).

The following data sources should probably provide the same staging and production version attributes as well:

References

N/A

lsadlon commented 5 months ago

Hi @siwinski

Thanks for this idea, we will think it over and go back to you.

BR, Lukasz