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

Activation is executed, even without changes #139

Closed ericrichtert closed 3 years ago

ericrichtert commented 4 years ago

Terraform Version

Terraform v0.12.24

Affected Resource(s)

resource "akamai_property_activation" "tf-activate-staging" { property = akamai_property.tf-property-xxxx-yyy-nl.id network = "STAGING" activate = true contact = ["qwe@rty.uio"] }

Expected Behavior

When the terraform apply is executed and akamai_property.tf-property-xxxx-yyy-nl.id is not changed (no version update in akamai), the activation should not be started

Actual Behavior

The activation is started on an already activated propertyversion and the execution fails:

Error: API Error: 422 422 Unprocessable Entity Version 2 of property prp_123456 has already been activated. More Info https://problems.luna.akamaiapis.net/papi/v0/activation/already-activated on main.tf line 36, in resource "akamai_property_activation" "tf-activate-staging": 36: resource "akamai_property_activation" "tf-activate-staging" {

martinstibbe commented 4 years ago

@ericrichtert Does this issue still persist as we had made some changes to property activation in recent releases

ericrichtert commented 4 years ago

I did the test again with these versions: Terraform v0.12.26

still the same error: akamai_property_activation.tf-activate-production: Modifications complete after 2s [id=atv_8553312] Error: API Error: 422 Property version already activated Version 10 of property prp_xxxxxx has already been activated. More Info https://problems.luna.akamaiapis.net/papi/v0/activation/already-activated on main.tf line 46, in resource "akamai_property_activation" "tf-activate-staging": 46: resource "akamai_property_activation" "tf-activate-staging" {

ericrichtert commented 4 years ago

It seems like the staging activation is not added to the tfstate file.

martinstibbe commented 4 years ago

@ericrichtert I did a property create then a couple of back to back activations akamai_property_activation.dshafik_sandbox: Creation complete after 4m39s [id=atv_8558455] Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Second apply did an update without changing anything

    property = "prp_625352"
    status   = "ACTIVE"
  - version  = 1 -> null
}

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.

Enter a value: yes

akamai_property_activation.dshafik_sandbox: Modifying... [id=atv_8558455] akamai_property_activation.dshafik_sandbox: Modifications complete after 3s [id=atv_8558455]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

I think I would need a copy of tf files/rules you are using as I cannot replicate this issue using a property/activation test example

martinstibbe commented 4 years ago

@ericrichtert would you have a sanitized version of rules / property terraform file I could use to replicate this issue ?

Thanks

ericrichtert commented 4 years ago

I'll try to reproduce in a simple example.

ericrichtert commented 4 years ago

@martinstibbe How can I get the right example to you, without giving to much details on the internet? I'm trying to reproduce this, but don't want to publish our contract/ssl/group details.

ericrichtert commented 4 years ago

Version information: λ terraform version Terraform v0.12.26

First tf apply: λ terraform apply -auto-approve akamai_property.tf-property-gh139: Refreshing state... [id=prp_xxxxx] akamai_edge_hostname.tf-edgehost-gh139: Creating... akamai_property.tf-property-gh139: Modifying... [id=prp_xxxxx] akamai_edge_hostname.tf-edgehost-gh139: Creation complete after 3s [id=ehn_xxxxxxx] akamai_property.tf-property-gh139: Modifications complete after 6s [id=prp_xxxxx] akamai_property_activation.tf-activate-staging: Creating... akamai_property_activation.tf-activate-production: Creating... akamai_property_activation.tf-activate-staging: Still creating... [2m50s elapsed] akamai_property_activation.tf-activate-staging: Creation complete after 2m56s [id=atv_xxxxxxx]

Error: API Error: 0 More Info https://problems.luna.akamaiapis.net/papi/v0/toolkit/validation_failed.error.arlfile.exists

on akamai.tf line 28, in resource "akamai_property_activation" "tf-activate-production": 28: resource "akamai_property_activation" "tf-activate-production" {

tfstate contains: λ terraform state list akamai_edge_hostname.tf-edgehost-gh139 akamai_property.tf-property-gh139 akamai_property_activation.tf-activate-staging

tf apply, same config: λ terraform apply -auto-approve akamai_edge_hostname.tf-edgehost-gh139: Refreshing state... [id=ehn_xxxxxxx] akamai_property.tf-property-gh139: Refreshing state... [id=prp_xxxxx] akamai_property_activation.tf-activate-staging: Refreshing state... [id=atv_xxxxxxx] akamai_property_activation.tf-activate-production: Creating... akamai_property_activation.tf-activate-staging: Modifying... [id=atv_xxxxxxx] akamai_property_activation.tf-activate-staging: Modifications complete after 2s [id=atv_xxxxxxx] akamai_property_activation.tf-activate-production: Still creating... [12m0s elapsed]

akamai_property_activation.tf-activate-production: Creation complete after 12m8s [id=atv_xxxxxx] Apply complete! Resources: 1 added, 1 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. **tf state contains:** λ terraform state list akamai_edge_hostname.tf-edgehost-gh139 akamai_property.tf-property-gh139 akamai_property_activation.tf-activate-production akamai_property_activation.tf-activate-staging **tf apply, same config:** λ terraform apply -auto-approve akamai_edge_hostname.tf-edgehost-gh139: Refreshing state... [id=ehn_xxxxxxx] akamai_property.tf-property-gh139: Refreshing state... [id=prp_xxxxx] akamai_property_activation.tf-activate-staging: Refreshing state... [id=atv_xxxxxxx] akamai_property_activation.tf-activate-production: Refreshing state... [id=atv_xxxxxx] akamai_property_activation.tf-activate-staging: Modifying... [id=atv_xxxxxxx] akamai_property_activation.tf-activate-production: Modifying... [id=atv_xxxx] akamai_property_activation.tf-activate-production: Modifications complete after 1s [id=atv_xxxxxxxx] Error: API Error: 422 Property version already activated Version 1 of property `prp_xxxxx` has already been activated. More Info https://problems.luna.akamaiapis.net/papi/v0/activation/already-activated on akamai.tf line 35, in resource "akamai_property_activation" "tf-activate-staging": 35: resource "akamai_property_activation" "tf-activate-staging" { **Change in the rule, (name of origin server):** **tf apply:** λ terraform apply -auto-approve akamai_edge_hostname.tf-edgehost-gh139: Refreshing state... [id=ehn_4574138] akamai_property.tf-property-gh139: Refreshing state... [id=prp_632946] akamai_property_activation.tf-activate-staging: Refreshing state... [id=atv_8684222] akamai_property_activation.tf-activate-production: Refreshing state... [id=atv_8684225] akamai_property.tf-property-gh139: Modifying... [id=prp_632946] akamai_property.tf-property-gh139: Modifications complete after 8s [id=prp_632946] akamai_property_activation.tf-activate-staging: Creating... akamai_property_activation.tf-activate-production: Modifying... [id=atv_8684225] akamai_property_activation.tf-activate-staging: Still creating... [10s elapsed] akamai_property_activation.tf-activate-staging: Creation complete after 2m38s [id=atv_8684237] akamai_property_activation.tf-activate-production: Still modifying... [id=atv_8684225, 2m40s elapsed] akamai_property_activation.tf-activate-production: Still modifying... [id=atv_8684225, 8m50s elapsed] akamai_property_activation.tf-activate-production: Modifications complete after 8m59s [id=atv_8684238] Apply complete! Resources: 1 added, 2 changed, 0 destroyed. **tf state shows:** λ terraform state show akamai_property_activation.tf-activate-staging resource "akamai_property_activation" "tf-activate-staging" { activate = true contact = [ "ik@jij.com", ] id = "atv_8684237" network = "STAGING" property = "prp_632946" status = "PENDING" version = 2 } λ terraform state show akamai_property_activation.tf-activate-production resource "akamai_property_activation" "tf-activate-production" { activate = true contact = [ "ik@jij.com", ] id = "atv_8684238" network = "PRODUCTION" property = "prp_632946" status = "ACTIVE" version = 2 } **tf apply again, same config:** λ terraform apply -auto-approve akamai_edge_hostname.tf-edgehost-gh139: Refreshing state... [id=ehn_4574138] akamai_property.tf-property-gh139: Refreshing state... [id=prp_632946] akamai_property_activation.tf-activate-staging: Refreshing state... [id=atv_8684237] akamai_property_activation.tf-activate-production: Refreshing state... [id=atv_8684238] akamai_property_activation.tf-activate-production: Modifying... [id=atv_8684238] akamai_property_activation.tf-activate-staging: Modifying... [id=atv_8684237] akamai_property_activation.tf-activate-production: Modifications complete after 2s [id=atv_8684238] Error: API Error: 422 Property version already activated Version 2 of property `prp_632946` has already been activated. More Info https://problems.luna.akamaiapis.net/papi/v0/activation/already-activated on akamai.tf line 35, in resource "akamai_property_activation" "tf-activate-staging": 35: resource "akamai_property_activation" "tf-activate-staging" { ** tf state shows:** λ terraform state show akamai_property_activation.tf-activate-staging resource "akamai_property_activation" "tf-activate-staging" { activate = true contact = [ "ik@jij.com", ] id = "atv_8684237" network = "STAGING" property = "prp_632946" status = "ACTIVE" version = 0 } λ terraform state show akamai_property_activation.tf-activate-production resource "akamai_property_activation" "tf-activate-production" { activate = true contact = [ "ik@jij.com", ] id = "atv_8684238" network = "PRODUCTION" property = "prp_632946" status = "ACTIVE" version = 2 }
martinstibbe commented 4 years ago

@ericrichtert I am checking with Akamai internal team on this one as simultaneous Stage and Prod activations was an issue in the past I encountered with another customer

martinstibbe commented 4 years ago

@ericrichtert PR for branch AT-41 has a fix for this in QA for testing

ericrichtert commented 4 years ago

@martinstibbe my testcase is running fine for now. I will do some testing in our realenvironment.

ericrichtert commented 4 years ago

Still an error: Error: Post "https://akab-XXXXX.luna.akamaiapis.net/papi/v1/properties/prp_YYYY/activations?contractId=ctr_C-UUUUU&groupId=grp_PPPP": EOF on main.tf line 27, in resource "akamai_property_activation" "tf-activate-production": 27: resource "akamai_property_activation" "tf-activate-production" {

martinstibbe commented 4 years ago

@ericrichtert Do you have more detail on error message could you set export TF_LOG=DEBUG export TF_LOG_PATH=somefilename.log run this apply again and E-mail me the log file to martin@akava.io

zstlaw commented 3 years ago

Closing this issue due to lack of response.

The provider has been revamped in the 1.0.0 release, including improvements to activation. Please upgrade to 1.0.0 Please refer https://registry.terraform.io/providers/akamai/akamai/latest/docs/guides/1.0_migration for additional details.

If you encounter issues with the 1.0.0 release, and your particular scenario, please submit a new issue.