akamai / terraform-provider-akamai

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

akamai_datastream after akamai_property_bootstrap fails #583

Open rolmo opened 3 weeks ago

rolmo commented 3 weeks ago

Hi there,

In the past, there was the problem that you needed the ID of a property for the akamai_datastream, but the property needed the ID of a akamai_datastream, which meant that the whole thing could not be rolled out automatically.

As far as I understand it, the resource akamai_property_bootstrap should be used for this:

But this fails.

Terraform and Akamai Terraform Provider Versions

Terraform: v1.9.6 Akamai-Provider: 6.4.0

Affected Resource(s)

Terraform Configuration Files

resource "akamai_property_bootstrap" "test" {
  name        = "test-akamai"
  contract_id = var.contract_id
  group_id    = var.group_id
  product_id  = var.product.product_id
}

resource "akamai_datastream" "test" {
  active             = true
  contract_id        = var.contract_id
  group_id           = var.group_id

  delivery_configuration {
    format             = "JSON"
    frequency {
      interval_in_secs = 30
    }
  }
  dataset_fields = [
    1000, 1005, 1006, 1008, 1009, 1013, 1016, 1017, 1032, 1068, 2002, 2003, 2005, 2010, 2012, 2020
  ]
  notification_emails = [
    "me@company.com"
  ]
  properties = [
    akamai_property_bootstrap.test.id
  ]
  stream_name        = "test-akamai"
  splunk_connector {
    display_name          = "Our Token"
    event_collector_token = var.splunk_token
    endpoint              = "https://http-inputs-spring.splunkcloud.com/services/collector/raw"
  }
}

Debug Output

The resource resource "akamai_datastream" "test" creates this error message:

One or more properties (xxxxxx) are invalid. Provide properties that are authorized to be a part of this stream, and belong to the xxxx contract and xxxxx group ID."

(But the (empty) property is created, has the right group and the right contract)

Expected Behavior

The datastream should created, because the property and datastream are in the same contract/group.

mstojanowski commented 2 weeks ago

Hi @rolmo,

akamai_property_bootstrap resource does not solve circular dependency problem with property and datastream. It only enables walkaround of that issue. The limitation is that you can not simply use it with single apply. You need two applies:

  1. Create and apply configuration containing:

    • akamai_cp_code
    • akamai_edge_hostname
    • akamai_property_bootstrap
    • akamai_property (with references to akamai_property_bootstrap)
    • akamai_property_activation
    • akamai_datastream (commented out, with reference to akamai_property_bootstrap id)
    • akamai_property_rules_builder (commented out datastream part) (Resources: 5 added, 0 changed, 0 destroyed.)
  2. Uncomment what was commented above and apply again. (Resources: 1 added, 2 changed, 0 destroyed.)

At this point this is the only way to have property with datastream created.

Please don't hesitate to ask if you need further help with this case.

Regards, Marcin

rolmo commented 1 week ago

Hello Marcin,

Okay - I see. But the whole thing is very cumbersome!

It would be ideal if you had a documentation for this - akamai_property_bootstrap is offered when exporting a propery in the Akamai CLI, but you can't find out the correct usage anywhere