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

CloudSearch Domain Resource Support #17723

Merged
merged 50 commits into from
Jan 19, 2022

Conversation

celestialorb
Copy link
Contributor

@celestialorb celestialorb commented Feb 19, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment 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 pull request followers and do not help prioritize the request

Closes #7833

Output from acceptance testing:

make testacc TESTARGS="-run TestAccAWSCloudSearchDomain"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run TestAccAWSCloudSearchDomain -timeout 120m
=== RUN   TestAccAWSCloudSearchDomain_basic
=== PAUSE TestAccAWSCloudSearchDomain_basic
=== RUN   TestAccAWSCloudSearchDomain_textAnalysisScheme
=== PAUSE TestAccAWSCloudSearchDomain_textAnalysisScheme
=== RUN   TestAccAWSCloudSearchDomain_badName
=== PAUSE TestAccAWSCloudSearchDomain_badName
=== RUN   TestAccAWSCloudSearchDomain_badInstanceType
=== PAUSE TestAccAWSCloudSearchDomain_badInstanceType
=== RUN   TestAccAWSCloudSearchDomain_badIndexFieldNames
=== PAUSE TestAccAWSCloudSearchDomain_badIndexFieldNames
=== RUN   TestAccAWSCloudSearchDomain_badIndexFieldType
=== PAUSE TestAccAWSCloudSearchDomain_badIndexFieldType
=== CONT  TestAccAWSCloudSearchDomain_basic
=== CONT  TestAccAWSCloudSearchDomain_badIndexFieldNames
=== CONT  TestAccAWSCloudSearchDomain_badIndexFieldType
=== CONT  TestAccAWSCloudSearchDomain_badName
=== CONT  TestAccAWSCloudSearchDomain_badInstanceType
=== CONT  TestAccAWSCloudSearchDomain_textAnalysisScheme
--- PASS: TestAccAWSCloudSearchDomain_badInstanceType (2.85s)
--- PASS: TestAccAWSCloudSearchDomain_badIndexFieldType (3.01s)
--- PASS: TestAccAWSCloudSearchDomain_badName (3.04s)
--- PASS: TestAccAWSCloudSearchDomain_badIndexFieldNames (4.18s)
--- PASS: TestAccAWSCloudSearchDomain_textAnalysisScheme (41.59s)
--- PASS: TestAccAWSCloudSearchDomain_basic (60.54s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       60.616s

@celestialorb celestialorb requested a review from a team as a code owner February 19, 2021 22:21
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/cloudsearch Issues and PRs that pertain to the cloudsearch service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 19, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Feb 19, 2021
@github-actions
Copy link

Thank you for your contribution! 🚀

Please note that typically Go dependency changes are handled in this repository by dependabot or the maintainers. This is to prevent pull request merge conflicts and further delay reviews of contributions. Remove any changes to the go.mod or go.sum files and commit them into this pull request.

Additional details:

  • Check open pull requests with the dependencies label to view other dependency updates.
  • If this pull request includes an update the AWS Go SDK (or any other dependency) version, only updates submitted via dependabot will be merged. This pull request will need to remove these changes and will need to be rebased after the existing dependency update via dependabot has been merged for this pull request to be reviewed.
  • If this pull request is for supporting a new AWS service:
    • Ensure the new AWS service changes are following the Contributing Guide section on new services, in particular that the dependency addition and initial provider support are in a separate pull request from other changes (e.g. new resources). Contributions not following this item will not be reviewed until the changes are split.
    • If this pull request is already a separate pull request from the above item, you can ignore this message.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome @celestialorb 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@celestialorb celestialorb changed the title CloudSearch Domain Resource Support [WIP] CloudSearch Domain Resource Support Feb 19, 2021
@celestialorb celestialorb changed the title [WIP] CloudSearch Domain Resource Support CloudSearch Domain Resource Support Feb 20, 2021
@celestialorb
Copy link
Contributor Author

celestialorb commented Feb 20, 2021

Only question I have at the moment from someone more intimately familiar with Terraform resource/provider design, is should an index in a CloudSearch domain be a separate resource? I feel as if it should be due to its complexity, but perhaps the initial approach taken by @Mi3-14159 is perfectly fine.

@austinkelleher
Copy link

Nice work @celestialorb! This would be extremely helpful to our team! Is there something blocking the review of this PR?

@celestialorb
Copy link
Contributor Author

celestialorb commented Mar 30, 2021

@austinkelleher Not sure, haven't seen anyone official pop into the PR yet. Don't know what can be done to get it noticed; I'm sure there's a ton of PRs to review on their end. I've gone ahead and updated the code and docs so that all the checks pass again for this PR.

In the meantime I've published this custom version of the provider under my own namespace, celestialorb/aws. If you use that as your source in your Terraform it should pull this version you'll be able to use it for CloudSearch domains.

@hallsamuel90
Copy link
Contributor

Awesome job @celestialorb !! It's working great and couldn't have come at a better time for our team!

@vsharma29
Copy link

@celestialorb Thanks for the provider. I am getting an issue even if i dont change the index elements still the plan shows me changes if i do terraform plan and it recreates all of the index everytime.

resource "aws_cloudsearch_domain" "domain" {
name = var.domain_name
instance_type = var.instance_type
multi_az = true

dynamic "index" {
for_each = var.indexes
content {
name = index.value["name"]
type = index.value["type"]
search = lookup(index, "search", true)
facet = lookup(index, "facet", true)
return = lookup(index, "return", true)
sort = lookup(index, "sort", true)
highlight = lookup(index, "highlight", true)
analysis_scheme = lookup(index, "analysis_scheme", "en_default")
}
}
tags = var.tags

service_access_policies = data.aws_iam_policy_document.cloudsearch_access_policy.json
}

Value from vars file

indexes = [
{
name = "abstract"
type = "text"
},
{
name = "analystname"
type = "text-array"
},
{
name = "htmtext"
type = "text"
},
{
name = "issuername"
type = "text"
},
{
name = "organizationid"
type = "text"
},
{
name = "pdftext"
type = "text"
},
{
name = "reporttype"
type = "text"
},
{
name = "sectorlevel1"
type = "text"
},
{
name = "sectorlevel2"
type = "text"
},
{
name = "subtitle"
type = "text"
},
{
name = "ticker"
type = "text"
},
{
name = "title"
type = "text"
},
{
name = "url"
type = "text"
}
]

@celestialorb
Copy link
Contributor Author

celestialorb commented May 24, 2021

@celestialorb Thanks for the provider. I am getting an issue even if i dont change the index elements still the plan shows me changes if i do terraform plan and it recreates all of the index everytime.

resource "aws_cloudsearch_domain" "domain" {
  name = var.domain_name
  instance_type = var.instance_type
  multi_az = true

  dynamic "index" {
    for_each = var.indexes
    content {
      name = index.value["name"]
      type = index.value["type"]
      search = lookup(index, "search", true)
      facet = lookup(index, "facet", true)
      return = lookup(index, "return", true)
      sort = lookup(index, "sort", true)
      highlight = lookup(index, "highlight", true)
      analysis_scheme = lookup(index, "analysis_scheme", "_en_default_")
    }
  }

  tags = var.tags

  service_access_policies = data.aws_iam_policy_document.cloudsearch_access_policy.json
}

Value from vars file

indexes = [
{
  name = "abstract"
  type = "text"
},
{
  name = "analystname"
  type = "text-array"
},
{
  name = "htmtext"
  type = "text"
},
{
  name = "issuername"
  type = "text"
},
{
  name = "organizationid"
  type = "text"
},
{
  name = "pdftext"
  type = "text"
},
{
  name = "reporttype"
  type = "text"
},
{
  name = "sectorlevel1"
  type = "text"
},
{
  name = "sectorlevel2"
  type = "text"
},
{
  name = "subtitle"
  type = "text"
},
{
  name = "ticker"
  type = "text"
},
{
  name = "title"
  type = "text"
},
{
  name = "url"
  type = "text"
}
]

@vsharma29 The issue here is that you're setting an analysis_scheme for indices where one doesn't make sense (and can't be set). Analysis schemes are only valid for text and text-array fields, but in your Terraform configuration you're setting the analysis_scheme for all indices via the lookup function:

analysis_scheme = lookup(index, "analysis_scheme", "_en_default_")

There's still some work to done surrounding indices, given that they aren't exactly straight-forward and I think the approach originally taken can be improved upon.

@vsharma29
Copy link

@celestialorb All the fields which i have set up are text or text array so it can be set . I am not sure whats driving the plan to
Misbehave but something wierd going on

@celestialorb
Copy link
Contributor Author

celestialorb commented May 24, 2021

@celestialorb All the fields which i have set up are text or text array so it can be set . I am not sure whats driving the plan to
Misbehave but something wierd going on

My mistake, I thought I had spotted an int in there somewhere. I was able to reproduce the issue earlier when using non-text fields like int, but not with only text fields. I'll go back and take another look later.

@celestialorb
Copy link
Contributor Author

@celestialorb All the fields which i have set up are text or text array so it can be set . I am not sure whats driving the plan to
Misbehave but something wierd going on

Including a copy of the plan would help to debug the issue.

@celestialorb
Copy link
Contributor Author

@celestialorb All the fields which i have set up are text or text array so it can be set . I am not sure whats driving the plan to
Misbehave but something wierd going on

Yeah, I'll need to see what your plan looks like. I can't reproduce the issue on my end.

@vsharma29
Copy link

Sorry about late reply. Copy of my plan.`
pipelineLog-10.txt

@celestialorb
Copy link
Contributor Author

celestialorb commented Jun 1, 2021

Sorry about late reply. Copy of my plan.`
pipelineLog-10.txt

Looks like it's because you're changing the search attribute from false to true on a lot of these indices, if not all, so it's recreating them. This is expected behavior.

@breathingdust breathingdust added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 4, 2021
@zhelding
Copy link
Contributor

Pull request #21306 has significantly refactored the AWS Provider codebase. As a result, most PRs opened prior to the refactor now have merge conflicts that must be resolved before proceeding.

Specifically, PR #21306 relocated the code for all AWS resources and data sources from a single aws directory to a large number of separate directories in internal/service, each corresponding to a particular AWS service. This separation of code has also allowed for us to simplify the names of underlying functions -- while still avoiding namespace collisions.

We recognize that many pull requests have been open for some time without yet being addressed by our maintainers. Therefore, we want to make it clear that resolving these conflicts in no way affects the prioritization of a particular pull request. Once a pull request has been prioritized for review, the necessary changes will be made by a maintainer -- either directly or in collaboration with the pull request author.

For a more complete description of this refactor, including examples of how old filepaths and function names correspond to their new counterparts: please refer to issue #20000.

For a quick guide on how to amend your pull request to resolve the merge conflicts resulting from this refactor and bring it in line with our new code patterns: please refer to our Service Package Refactor Pull Request Guide.

…d make configurable) to reach Active state.

Acceptance test output:

% make testacc TESTARGS='-run=TestAccCloudSearchDomainServiceAccessPolicy_' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomainServiceAccessPolicy_ -timeout 180m
=== RUN   TestAccCloudSearchDomainServiceAccessPolicy_basic
=== PAUSE TestAccCloudSearchDomainServiceAccessPolicy_basic
=== RUN   TestAccCloudSearchDomainServiceAccessPolicy_update
=== PAUSE TestAccCloudSearchDomainServiceAccessPolicy_update
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_basic
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_update
--- PASS: TestAccCloudSearchDomainServiceAccessPolicy_basic (1613.17s)
--- PASS: TestAccCloudSearchDomainServiceAccessPolicy_update (2419.09s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch	2422.751s
@ewbankkit ewbankkit mentioned this pull request Jan 2, 2022
% make testacc TESTARGS='-run=TestAccCloudSearchDomain_indexFields' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomain_indexFields -timeout 180m
=== RUN   TestAccCloudSearchDomain_indexFields
=== PAUSE TestAccCloudSearchDomain_indexFields
=== CONT  TestAccCloudSearchDomain_indexFields
--- PASS: TestAccCloudSearchDomain_indexFields (1083.01s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        1086.866s
% make testacc TESTARGS='-run=TestAccCloudSearchDomain_indexFields' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomain_indexFields -timeout 180m
=== RUN   TestAccCloudSearchDomain_indexFields
=== PAUSE TestAccCloudSearchDomain_indexFields
=== CONT  TestAccCloudSearchDomain_indexFields
--- PASS: TestAccCloudSearchDomain_indexFields (1565.71s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        1570.444s
% make testacc TESTARGS='-run=TestAccCloudSearchDomain_update' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomain_update -timeout 180m
=== RUN   TestAccCloudSearchDomain_update
=== PAUSE TestAccCloudSearchDomain_update
=== CONT  TestAccCloudSearchDomain_update
--- PASS: TestAccCloudSearchDomain_update (1264.26s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        1267.577s
…ate'.

% make testacc TESTARGS='-run=TestAccCloudSearchDomain_update' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomain_update -timeout 180m
=== RUN   TestAccCloudSearchDomain_update
=== PAUSE TestAccCloudSearchDomain_update
=== CONT  TestAccCloudSearchDomain_update
--- PASS: TestAccCloudSearchDomain_update (1570.32s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        1574.295s
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

Commercial
% make testacc TESTARGS='-run=TestAccCloudSearchDomain_' PKG=cloudsearch 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomain_ -timeout 180m
=== RUN   TestAccCloudSearchDomain_basic
=== PAUSE TestAccCloudSearchDomain_basic
=== RUN   TestAccCloudSearchDomain_disappears
=== PAUSE TestAccCloudSearchDomain_disappears
=== RUN   TestAccCloudSearchDomain_indexFields
=== PAUSE TestAccCloudSearchDomain_indexFields
=== RUN   TestAccCloudSearchDomain_update
=== PAUSE TestAccCloudSearchDomain_update
=== CONT  TestAccCloudSearchDomain_basic
=== CONT  TestAccCloudSearchDomain_indexFields
=== CONT  TestAccCloudSearchDomain_disappears
=== CONT  TestAccCloudSearchDomain_update
--- PASS: TestAccCloudSearchDomain_disappears (662.90s)
--- PASS: TestAccCloudSearchDomain_basic (679.61s)
--- PASS: TestAccCloudSearchDomain_indexFields (1588.94s)
--- PASS: TestAccCloudSearchDomain_update (1789.34s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        1792.704s
% make testacc TESTARGS='-run=TestAccCloudSearchDomainServiceAccessPolicy_' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomainServiceAccessPolicy_ -timeout 180m
=== RUN   TestAccCloudSearchDomainServiceAccessPolicy_basic
=== PAUSE TestAccCloudSearchDomainServiceAccessPolicy_basic
=== RUN   TestAccCloudSearchDomainServiceAccessPolicy_update
=== PAUSE TestAccCloudSearchDomainServiceAccessPolicy_update
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_basic
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_update
--- PASS: TestAccCloudSearchDomainServiceAccessPolicy_basic (1807.86s)
--- PASS: TestAccCloudSearchDomainServiceAccessPolicy_update (2546.93s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        2550.273s
GovCloud
% make testacc TESTARGS='-run=TestAccCloudSearchDomain_' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomain_ -timeout 180m
=== RUN   TestAccCloudSearchDomain_basic
=== PAUSE TestAccCloudSearchDomain_basic
=== RUN   TestAccCloudSearchDomain_disappears
=== PAUSE TestAccCloudSearchDomain_disappears
=== RUN   TestAccCloudSearchDomain_indexFields
=== PAUSE TestAccCloudSearchDomain_indexFields
=== RUN   TestAccCloudSearchDomain_update
=== PAUSE TestAccCloudSearchDomain_update
=== CONT  TestAccCloudSearchDomain_basic
=== CONT  TestAccCloudSearchDomain_indexFields
=== CONT  TestAccCloudSearchDomain_disappears
=== CONT  TestAccCloudSearchDomain_update
=== CONT  TestAccCloudSearchDomain_basic
    acctest.go:608: skipping tests; partition aws-us-gov does not support cloudsearch service
=== CONT  TestAccCloudSearchDomain_indexFields
    acctest.go:608: skipping tests; partition aws-us-gov does not support cloudsearch service
--- SKIP: TestAccCloudSearchDomain_indexFields (1.47s)
--- SKIP: TestAccCloudSearchDomain_basic (1.47s)
=== CONT  TestAccCloudSearchDomain_disappears
    acctest.go:608: skipping tests; partition aws-us-gov does not support cloudsearch service
--- SKIP: TestAccCloudSearchDomain_disappears (1.47s)
=== CONT  TestAccCloudSearchDomain_update
    acctest.go:608: skipping tests; partition aws-us-gov does not support cloudsearch service
--- SKIP: TestAccCloudSearchDomain_update (1.47s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        4.968s
% make testacc TESTARGS='-run=TestAccCloudSearchDomainServiceAccessPolicy_' PKG=cloudsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudsearch/... -v -count 1 -parallel 20 -run=TestAccCloudSearchDomainServiceAccessPolicy_ -timeout 180m
=== RUN   TestAccCloudSearchDomainServiceAccessPolicy_basic
=== PAUSE TestAccCloudSearchDomainServiceAccessPolicy_basic
=== RUN   TestAccCloudSearchDomainServiceAccessPolicy_update
=== PAUSE TestAccCloudSearchDomainServiceAccessPolicy_update
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_basic
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_update
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_basic
    acctest.go:608: skipping tests; partition aws-us-gov does not support cloudsearch service
--- SKIP: TestAccCloudSearchDomainServiceAccessPolicy_basic (1.30s)
=== CONT  TestAccCloudSearchDomainServiceAccessPolicy_update
    acctest.go:608: skipping tests; partition aws-us-gov does not support cloudsearch service
--- SKIP: TestAccCloudSearchDomainServiceAccessPolicy_update (1.30s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cloudsearch        4.651s

@ewbankkit
Copy link
Contributor

@celestialorb Thanks for the contribution 🎉 👏.
I made some effectively cosmetic changes (index -> index_field and added some additional configuration options) to aws_cloudsearch_domain and split the policy into its own resource aws_cloudsearch_domain_service_access_policy.

@ewbankkit ewbankkit merged commit 899470e into hashicorp:main Jan 19, 2022
@github-actions github-actions bot modified the milestones: Roadmap, v3.73.0 Jan 19, 2022
@celestialorb celestialorb deleted the feature/cloudsearch branch January 19, 2022 22:37
@github-actions
Copy link

This functionality has been released in v3.73.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!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/cloudsearch Issues and PRs that pertain to the cloudsearch service. size/XL Managed by automation to categorize the size of a PR. size/XXL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Managing Amazon CloudSearch Domains
8 participants