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

DXE-4439 Provider produced inconsistent final plan for .version when using version akamai_property.latest_version in activation #594

Open
DhroovP opened this issue Nov 26, 2024 · 10 comments

Comments

@DhroovP
Copy link

DhroovP commented Nov 26, 2024

Seeing this bug (seems related to this) when I'm running terraform apply:

│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for
│ akamai_property_activation.prod-production[0] to
│ include new values learned so far during apply, provider
│ "registry.terraform.io/akamai/akamai" produced an invalid new value for
│ .version: was cty.NumberIntVal(33), but now cty.NumberIntVal(34).
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

This seems to happen when there are minor changes in the property, and a new version has to be created and then activated. My resource is:

resource "akamai_property_activation" prod-production" {
  count                          = var.env == "prod" ? 1 : 0
  property_id                    = akamai_property.property[count.index].id
  contact                        = var.contact
  version                        = var.activate_latest_on_production ? akamai_property.property[count.index].latest_version : akamai_property.property[count.index].production_version
  network                        = "PRODUCTION"
  note                           = "Latest version of property"
  auto_acknowledge_rule_warnings = true

  lifecycle {
    ignore_changes = [
      note,
    ]
  }
}

Terraform and Akamai Terraform Provider Versions

Initializing provider plugins...

  • Reusing previous version of akamai/akamai from the dependency lock file
  • Using previously-installed akamai/akamai v6.6.0
  • Terraform version 1.6.6

Affected Resource(s)

  • akamai_property_activation

Expected Behavior

Latest version should have been activated in production.

Actual Behavior

Inconsistent final plan error.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply with extra arguments: -var activate_latest_on_staging=false -var activate_latest_on_production=true with minor changes in the property itself (along with the version logic in the akamai_property_activation resource above)
@lsadlon lsadlon changed the title Provider produced inconsistent final plan for .version when using version akamai_property.latest_version in activation DXE-4439 Provider produced inconsistent final plan for .version when using version akamai_property.latest_version in activation Nov 27, 2024
@DhroovP
Copy link
Author

DhroovP commented Nov 27, 2024

Quick update, I reverted to 6.3.0 and did not face this error. Hope that helps to pin down where this issue is coming from.

@lsadlon
Copy link

lsadlon commented Nov 27, 2024

Hi @DhroovP

Thanks for reporting it. We are looking into that. Could you also tell us what other resource are you using in your configuration? Are you using akamai_property_rules_builder or json based rules?

BR,
Lukasz

@DhroovP
Copy link
Author

DhroovP commented Nov 27, 2024

Hi @lsadlon

I am using the akamai_property_rules_template resource with JSON files. Let me know if I can provide any other information.

Thanks,
DhroovP

@glenthomas

This comment was marked as resolved.

@chouraamine
Copy link

Hi @DhroovP ,

instead of :

akamai_property.property[count.index].latest_version

You can use :

sum([akamai_property.property[count.index].production_version,1])

There is an issue with .latest_version ...

@chouraamine
Copy link

chouraamine commented Nov 29, 2024

Hi @lsadlon,

Do we know why the production_version and staging_version values in the Tfstate are not the same as the latest_version? Please see the screenshot for reference.

image

Note : that both staging & production are activated on the latest version (so they should be equal to 1)

Regards,

@lsadlon
Copy link

lsadlon commented Nov 29, 2024

Hi @chouraamine

I created internal ticket to investigate this issue. We will come back after we investigation.

BR,
Lukasz

@artbookspirit
Copy link
Contributor

Hi @DhroovP,

We have difficulties to reproduce the problem you write about. Could you please provide more details about what exactly you are changing in the property? In particular, do the changes involve:

  1. hostnames,
  2. rule format,
  3. version notes (do you use them at all?)
  4. rules? In the rule templates, do your variables (the "variables" blocks) contain plain strings or maybe references to other resources/data sources?

Thanks,
Piotr

@artbookspirit
Copy link
Contributor

Hi @chouraamine,

What you are describing is unfortunately a well-known, although slightly different, problem. Please check out this thread with a broader discussion and possible workarounds: #560.

@DhroovP
Copy link
Author

DhroovP commented Dec 22, 2024

Hey @artbookspirit

We are just changing things like contact (under the property activation resource), and some of the JSONs that we reference in this property.

data "akamai_property_rules_template" "rules" {
  template_file = abspath("${path.module}/property-snippets/main.json")

 variables {
    name  = "note"
    value = var.note
    type  = "string"
  }
etc
}

This is referenced in the akamai_property resource using

rules       = data.akamai_property_rules_template.rules.json

Additionally, we use the variable

  version_notes = var.note

in the akamai_property resource, but that's basically it. We supply this via the Github commit message and pass it through our Github Actions pipeline.

So, to directly answer the question, we do not change the hostname or the rule format, but we use version_notes the way it's done shown above so those always involve a change (in a way, I guess), and we do indeed make changes in the rules. The variable blocks that are put into the rules template block don't reference other resources, they come directly from our variables.tf and dev/prod.tfvars files.

Hope this helps, let me know if I can provide any more information, and sorry for the late response.

Thanks,
Dhroov

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

No branches or pull requests

6 participants