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

aws_cloudsearch_domain tries to update in-place index_field on each run #23570

Closed
edwandr opened this issue Mar 8, 2022 · 8 comments · Fixed by #23687
Closed

aws_cloudsearch_domain tries to update in-place index_field on each run #23570

edwandr opened this issue Mar 8, 2022 · 8 comments · Fixed by #23687
Labels
bug Addresses a defect in current functionality. service/cloudsearch Issues and PRs that pertain to the cloudsearch service.
Milestone

Comments

@edwandr
Copy link

edwandr commented Mar 8, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

  • aws_cloudsearch_domain

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_cloudsearch_domain" "search" {
  provider = aws.cloudsearch_provider
  name     = "search"
  multi_az = false

  endpoint_options {
    enforce_https = true
  }

  scaling_parameters {
    desired_instance_type = "search.small"
  }

  index_field {
    name            = "address"
    type            = "text"
    search          = true
    return          = true
    sort            = true
    highlight       = true
    analysis_scheme = "_mul_default_"
  }

  index_field {
    name            = "city"
    type            = "text"
    search          = true
    return          = true
    sort            = true
    highlight       = true
    analysis_scheme = "_mul_default_"
  }

  index_field {
    name            = "country_code"
    type            = "text"
    search          = true
    return          = true
    sort            = true
    highlight       = true
    analysis_scheme = "_mul_default_"
  }

  index_field {
    name            = "geopoint"
    type            = "latlon"
    search          = true
    facet           = true
    return          = true
    sort            = true
    analysis_scheme = "_mul_default_"
  }

  index_field {
    name            = "name"
    type            = "text"
    search          = true
    return          = true
    sort            = true
    highlight       = true
    analysis_scheme = "_mul_default_"
  }

  index_field {
    name            = "zip_code"
    type            = "text"
    search          = true
    return          = true
    sort            = true
    highlight       = true
    analysis_scheme = "_mul_default_"
  }
}

Debug Output

https://gist.github.com/edwandr/9121463d2bd4b286be8227b22927165a

Panic Output

Expected Behavior

If there are no changes on aws_cloudsearch_domain resource, I don't expect any update on it in the plan

Actual Behavior

Each time I run a plan (to update something else or just launching a manual plan with no changes), terraform wants to update in-place the aws_cloudsearch_domain to remove all index_field and recreate them

Steps to Reproduce

  1. Create a aws_cloudsearch_domain ressource with index_fields
  2. Run terraform apply
  3. Run terraform plan and see that it wants to update aws_cloudsearch_domain in-place though there are no changes

Important Factoids

References

  • #0000
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/cloudsearch Issues and PRs that pertain to the cloudsearch service. labels Mar 8, 2022
@haavardw
Copy link

haavardw commented Mar 8, 2022

This is a huge problem for us. It delays the deploy pipeline unnecessary with ~2 hours every time.

@edwandr
Copy link
Author

edwandr commented Mar 9, 2022

@haavardw The workaround we use for the moment is to ignore changes on index_field in lifecycle (and remove that ignore if we want to change the index_fields which does not happen often)

lifecycle {
  ignore_changes = [
    # Remove that ignore if you do want to update index_field(s)
    index_field,
  ]
}

@ewbankkit
Copy link
Contributor

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
  ~ update in-place

Terraform will perform the following actions:

  # aws_cloudsearch_domain.search will be updated in-place
  ~ resource "aws_cloudsearch_domain" "search" {
        id                        = "search-production"
        name                      = "search-production"
        # (5 unchanged attributes hidden)


      - index_field {
          - facet     = true -> null
          - highlight = false -> null
          - name      = "geopoint" -> null
          - return    = true -> null
          - search    = true -> null
          - sort      = true -> null
          - type      = "latlon" -> null
        }
      - index_field {
          - analysis_scheme = "_mul_default_" -> null
          - facet           = false -> null
          - highlight       = true -> null
          - name            = "address" -> null
          - return          = true -> null
          - search          = false -> null
          - sort            = true -> null
          - type            = "text" -> null
        }
      - index_field {
          - analysis_scheme = "_mul_default_" -> null
          - facet           = false -> null
          - highlight       = true -> null
          - name            = "city" -> null
          - return          = true -> null
          - search          = false -> null
          - sort            = true -> null
          - type            = "text" -> null
        }
      - index_field {
          - analysis_scheme = "_mul_default_" -> null
          - facet           = false -> null
          - highlight       = true -> null
          - name            = "country_code" -> null
          - return          = true -> null
          - search          = false -> null
          - sort            = true -> null
          - type            = "text" -> null
        }
      - index_field {
          - analysis_scheme = "_mul_default_" -> null
          - facet           = false -> null
          - highlight       = true -> null
          - name            = "name" -> null
          - return          = true -> null
          - search          = false -> null
          - sort            = true -> null
          - type            = "text" -> null
        }
      - index_field {
          - analysis_scheme = "_mul_default_" -> null
          - facet           = false -> null
          - highlight       = true -> null
          - name            = "zip_code" -> null
          - return          = true -> null
          - search          = false -> null
          - sort            = true -> null
          - type            = "text" -> null
        }
      + index_field {
          + analysis_scheme = "_mul_default_"
          + facet           = true
          + name            = "geopoint"
          + return          = true
          + search          = true
          + sort            = true
          + type            = "latlon"
        }
      + index_field {
          + analysis_scheme = "_mul_default_"
          + highlight       = true
          + name            = "address"
          + return          = true
          + search          = true
          + sort            = true
          + type            = "text"
        }
      + index_field {
          + analysis_scheme = "_mul_default_"
          + highlight       = true
          + name            = "city"
          + return          = true
          + search          = true
          + sort            = true
          + type            = "text"
        }
      + index_field {
          + analysis_scheme = "_mul_default_"
          + highlight       = true
          + name            = "country_code"
          + return          = true
          + search          = true
          + sort            = true
          + type            = "text"
        }
      + index_field {
          + analysis_scheme = "_mul_default_"
          + highlight       = true
          + name            = "name"
          + return          = true
          + search          = true
          + sort            = true
          + type            = "text"
        }
      + index_field {
          + analysis_scheme = "_mul_default_"
          + highlight       = true
          + name            = "zip_code"
          + return          = true
          + search          = true
          + sort            = true
          + type            = "text"
        }

        # (2 unchanged blocks hidden)
    }

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 14, 2022
@ewbankkit
Copy link
Contributor

Relates: #17723.

@ewbankkit
Copy link
Contributor

ewbankkit commented Mar 14, 2022

It looks like we'll need a custom Set function for index_field incorporating only the applicable options based on type as described in the AWS documentation.

Also, we need to search search = true for text/text-array fields when refreshing as the AWS API does not return any value and text fields are always searchable.

@github-actions
Copy link

This functionality has been released in v4.6.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@edwandr
Copy link
Author

edwandr commented Mar 28, 2022

@ewbankkit After upgrading to v4.6.0 I still have the issue, should I reopen the issue ?

@github-actions
Copy link

github-actions bot commented May 5, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/cloudsearch Issues and PRs that pertain to the cloudsearch service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants