terraform-provider-algolia icon indicating copy to clipboard operation
terraform-provider-algolia copied to clipboard

Changing algolia keys results in apply running indefinitely

Open dotSource-bke opened this issue 1 year ago • 11 comments

Terraform Version

  • Terraform version: v~>1.3.0
  • Provider version: v0.5.6

Affected Resource(s)

  • algolia_api_key

Terraform Configuration Files

##in main:
module "ds_api_key" {
  source = "../../modules/algolia_api_key"

  description = "DS API key for indexing contentful entries"

  acl     = ["search", "browse", "addObject", "deleteObject", "deleteIndex", "listIndexes"]
  indexes = flatten([
    module.corp_document_indexes[*].name,
    module.corp_page_indexs[*].name,
    values(module.document_indexes)[*].name,
    values(module.page_indexes)[*].name,
    values(module.event_indexes)[*].name,
    values(module.course_indexes)[*].name
  ])

  max_queries_per_ip_per_hour = 0
}

##example of referenced module
module "product_indexes" {
  for_each = {for k, v in local.cep_oba_config : k => v if contains(v.applicable_indices, "product")}
  source   = "../../modules/algolia_index"

  deletion_protection = local.main_deletion_protection_switch

  project          = "cep"
  type             = "product"
  country          = each.key
  config           = local.product_index_config
  languages_config = (local.cep_oba_config[each.key]).languages_config
}

##in algolia_api_key:
resource "algolia_api_key" "main" {
  description = var.description

  acl     = toset(var.acl)
  indexes = toset(var.indexes)

  max_hits_per_query          = var.max_hits_per_query
  max_queries_per_ip_per_hour = var.max_queries_per_ip_per_hour
}

##in algolia_index
resource "algolia_index" "index" {
  name                = "${var.project}-${var.country}-${var.type}"
  deletion_protection = var.deletion_protection

  attributes_config {
    searchable_attributes = concat(var.config.searchable_attributes, flatten([
      for attr in var.languages_config.attribute_languages :
      formatlist("%s_${attr}", var.config.localized_searchable_attributes)
    ]))

    attributes_to_retrieve = concat(var.config.attributes_to_retrieve, flatten([
      for attr in var.languages_config.attribute_languages :
      formatlist("%s_${attr}", var.config.localized_attributes_to_retrieve)
    ]))

    attributes_for_faceting = concat(var.config.attributes_for_faceting, flatten([
      for attr in var.languages_config.attribute_languages :
      formatlist("%s_${attr}", var.config.localized_attributes_for_faceting)
    ]))
  }

  ranking_config { ranking = var.config.ranking }

  languages_config {
    camel_case_attributes = toset(var.languages_config.camel_case_attributes)
    custom_normalization  = var.languages_config.custom_normalization
    decompound_query      = var.languages_config.decompound_query
    ignore_plurals        = var.languages_config.ignore_plurals
    index_languages       = toset(var.languages_config.index_languages)
    query_languages       = toset(var.languages_config.query_languages)
    remove_stop_words     = var.languages_config.remove_stop_words
  }
}

Expected Behavior

  • when adding or removing or changing the config of the api key, the apply is executed quickly

Actual Behavior

  • when changing the config of the api key, the apply will not finish, although the key has been changed in algolia

Steps to Reproduce

  • add a key to algolia
  • apply the change
  • reconfigure the key (eg. additional index)
  • apply the change

Important Factoids

this did not happen on earlier versions of this provider

References

none

dotSource-bke avatar Mar 03 '23 13:03 dotSource-bke