Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

akamai_edge_hostname forces replacement without changes #258

Closed
henrytk opened this issue Oct 12, 2021 · 5 comments
Closed

akamai_edge_hostname forces replacement without changes #258

henrytk opened this issue Oct 12, 2021 · 5 comments

Comments

@henrytk
Copy link

henrytk commented Oct 12, 2021

The problem

When I run Terraform plan it says all of the configuration details of my edge hostname are incorrect and the resource needs replacing.

-/+ resource "akamai_edge_hostname" "dynamic" {
      ~ contract      = "ctr_C-000000" -> (known after apply)
      ~ edge_hostname = "some-other-host.example.com.edgekey.net" -> "my-correct-host.example.com.edgekey.net" # forces replacement
      ~ group         = "grp_000000" -> (known after apply)
      ~ id            = "ehn_000000" -> (known after apply)
      ~ product       = "prd_Site_Defender" -> (known after apply)
        # (5 unchanged attributes hidden)
    }

Nothing had changed. The state file still contains my-correct-host.example.com.edgekey.net and the correct group and contract ID.

The problem starts on line 349 of the function to read details of the edge hostname. It gets all of the edge hostnames from a particular group, but if it doesn't find the one it's looking for it just returns the first in the list!

This can happen when your credentials don't allow you to view the edge hostname, but also relates to which group the edge hostname is associated with. You use group ID to find edge hostnames, but the relationship between groups and edge hostnames seems indirect and unclear - especially when you've moved properties to a new group.

I can't submit a fix because there's a decision to be made about what it should do when it can't find the hostname. I don't know whether it should error or assume the hostname does not exist. It certainly should not, under no circumstances, return a completely different edge hostname, like it's doing now.

Terraform Version

$ terraform --version
Terraform v0.14.9

But I believe all versions would be affected.

Affected Resource(s)

akamai_edge_hostname

Expected Behavior

Either:

  • an error because the edge hostname cannot be found
  • the assumption the resource does not exist and needs to be created

The above expectation would be a design choice.

Actual Behavior

Terraform will show the edge hostname has a different configuration and forces replacement. This would involve incorrectly deleting a different edge hostname and trying to create the edge hostname which already exists.

Steps to Reproduce

  1. Create an edge hostname
  2. Load a set of credentials which do not have permission to view the edge hostname
  3. Run a Terraform plan

Alternatively (untested):

  1. Create an edge hostname
  2. Move it's associated property to a different group
  3. Run a Terraform plan
@kyrylyuk-andriy
Copy link

hello, i have similar issue, i have imported edge hostname into the state file, Import was successful but after that i run plan and it tires to replace resource, in my case its ip_behavior argument. I tried to set all available options but no one doesn't work.

Terraform v0.13.7

  • provider registry.terraform.io/akamai/akamai v1.7.1

@donaldpiret
Copy link

+1 facing the exact same issue as well. Did not move properties between groups.

@atalwar-sephora
Copy link

Any updates on this issue? Facing same issue, the first plan shows that the edge host will be created, but subsequent property resource fails to create as the hostname take sometime for edge hostname to move from Change Request status to active status. Once, edge hostname is active and running plan again forces replacement some random edgehost with the required hostname.

-/+ destroy and then create replacement

Terraform will perform the following actions:

  # akamai_edge_hostname.this["example.com"] must be replaced
-/+ resource "akamai_edge_hostname" "this" {
      ~ contract      = "ctr_" -> (known after apply)
      ~ edge_hostname = "random.com.edgesuite.net" -> "example.com.edgekey.net" # forces replacement
      ~ group         = "grp_" -> (known after apply)
      ~ id            = "ehn_" -> (known after apply)
      ~ product       = "prd_" -> (known after apply)
        # (5 unchanged attributes hidden)
    }

@lkowalsk-akamai-com
Copy link
Contributor

Hi, the fix (an error because the edge hostname cannot be found) will be introducend in next release. The date is not yet set, but it will be late November/early December.

@piotrpio piotrpio mentioned this issue Dec 6, 2021
@lkowalsk-akamai-com
Copy link
Contributor

Hi @henrytk, @kyrylyuk-andriy, @donaldpiret, @atalwar-sephora
This issue is now fixed with relese v1.9.0 of Akamai Terraform Provider. I'm closing this issue now. Plesae feel free to reaopen the issue if you find it not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants