OpsLevel / terraform-provider-opslevel

Terraform provider for OpsLevel.com
https://registry.terraform.io/providers/OpsLevel/opslevel/latest/docs
MIT License
8 stars 5 forks source link

bug: `opslevel_serivce` tags update errors with the new provider upgrade #358

Closed vini-mw closed 2 months ago

vini-mw commented 2 months ago

provider version == "1.0.0" tf version == "1.5.7"

i got this error for 80+ services, where all of them are trying to update the list of tags only, nothing else.

Error:

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to opslevel_service.this["instant-messaging"],
│ provider "provider[\"registry.terraform.io/opslevel/opslevel\"]" produced
│ an unexpected new value: .tags[1]: was cty.StringVal("aws_account:legacy"),
│ but now cty.StringVal("type:ecs").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Unexpected exit code when applying changes: 1
Uploading the list of managed resources...

This run has succeeded however entity changes for this run will not visible in the UI due to an error parsing the state file in the initialization phase. This is most commonly caused by an upgrade to a new provider version. Please see the initialization phase logs for more information. If you are seeing this error consistently, please contact support

i can confirm that as the error message suggests, the tags for the services in question seem updated, however, the tf run always fails.

rocktavious commented 2 months ago

@vini-mw - Can you provide us the terraform configuration you use for this service so we can see the shape?

vini-mw commented 2 months ago

@rocktavious nothing really unusual here, just the basics.

resource "opslevel_service" "this" {
  for_each = local.apps

  name            = each.value.name
  lifecycle_alias = data.opslevel_lifecycle.motorway.alias
  tier_alias      = data.opslevel_tier.motorway.alias
  owner           = contains(local.squad_names, each.value.owner) ? opslevel_team.motorway[each.value.owner].id : null

  tags = each.value.type != "workload" ? compact(
    [
      "type:${each.value.type}",
      "aws_account:${each.value.account}",
      try("optimized:${each.value.optimized}", ""),
      try("architecture:${each.value.architecture}", "")
    ]
  ) : []

  depends_on = [opslevel_team.motorway]

  lifecycle {
    ignore_changes = [
      framework, lifecycle_alias, tier_alias, aliases,
      api_document_path, product, preferred_api_document_source,
    ]
  }
}
davidbloss commented 2 months ago

@vini-mw Thank you for reporting this issue! 🎉 This issue with service tags has been fixed and will be included in today's v1.0.1 release