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

Unable to destroy a property #573

Open csaenz888 opened 1 month ago

csaenz888 commented 1 month ago

Hi there,

When I try to destroy a property resource, via terraform Akamai provider I get an error about the property still being active. I found a workaround for this, what I do is to first destroy the activation resource in production, which takes about 45 mins. Then I do the same destroy for the staging activation resource, that takes only a few minutes, and finally I 'm able to destroy the property resource. Is this the way you recommend I destroy resources or is there a better way via terraform?

dawiddzhafarov commented 1 month ago

Hi @csaenz888,

Thanks for contacting us.

This is an expected behavior. In order to delete the property, it must not be active on any of the networks. From your description of actions you are taking to destroy the property, it seems like you are manually deleting each of the resources. There is an easier way to achieve the desired outcome. If you would have a .tfstate file that contained akamai_property resource together with akamai_property_activation resources and the config file .tf with the configuration for those 3 resources, running single terraform destroy should handle all the relations and perform the deletions in the correct order. However, you need to take care of the dependencies between those resources. In this case, for the activation resources it usually should be done like this:

resource "akamai_property" "my_property" {
    name        = "MyProperty"
    other attributes...
}

resource "akamai_property_activation" "my_activation" {
     property_id                    = akamai_property.my_property.id
     other attributes...
}

Notice that the activation resource relates to property id via the reference to property's resource. Running terraform destory on such configuration would result in destroying the activation resource before destroying the property resource.

Let me know if that helps,

With regards, Dawid