Skip to content

Cannot import aws_opensearch_domain_policy resources #42289

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

Open
gmyers-aiq opened this issue Apr 18, 2025 · 3 comments
Open

Cannot import aws_opensearch_domain_policy resources #42289

gmyers-aiq opened this issue Apr 18, 2025 · 3 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. resource-import Pertains to issues importing resources. service/opensearch Issues and PRs that pertain to the opensearch service. waiting-response Maintainers are waiting on response from community or contributor.

Comments

@gmyers-aiq
Copy link

gmyers-aiq commented Apr 18, 2025

Description

Currently the aws_opensearch_domain_policy resource does not support importing. This seems like a huge oversight. It makes it extremely difficult to work with Terraform that includes this resource, particularly when refactoring into modular structures, as you are either forced to delete and recreate the whole OpenSearch cluster or do manual state hacking.

Affected Resource(s) or Data Source(s)

  • aws_opensearch_domain_policy

Potential Terraform Configuration

References

No response

Would you like to implement the enhancement?

No

@gmyers-aiq gmyers-aiq added the enhancement Requests to existing resources that expand the functionality or scope. label Apr 18, 2025
Copy link

Community Guidelines

This comment is added to every new Issue to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Issue and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/opensearch Issues and PRs that pertain to the opensearch service. labels Apr 18, 2025
@gmyers-aiq
Copy link
Author

Related: it seems the aws_elasticsearch_domain_policy resource also suffers from the same issue of not being importable.

@justinretzolk
Copy link
Member

Hey @gmyers-aiq 👋 Thank you for taking the time to raise this! While my initial thought is that there probably should be a method for importing these resources, I did want to touch on a couple of things that may help while this awaits prioritization.

The first thing that comes to mind is that rather than importing the resource(s) to the new location, you could utilize either terraform state mv or a moved block (more information on the latter in the Refactoring documentation) to move the resource(s) within the Terraform state. That would mean that support for import was unnecessary, since you're essentially just telling Terraform that the existing state file should be updated to match the new configuration.

I also noticed that the create/update function for the aws_opensearch_domain_policy resource is named "upsert". With that in mind, I created a sample configuration where I initially created an aws_opensearch_domain and aws_opensearch_domain_policy. Once the initial creation was complete, I moved the resources into a module and imported the aws_opensearch_domain. After import, I ran an apply and noted that the aws_opensearch_domain_policy resource was created again, but since the domain already had the policy applied in AWS prior to this new creation of the aws_opensearch_domain_policy, it didn't seem to have any impact on the domain -- the apply went through just fine, and further applied yielded no changes. Unless I've missed something, I'm not sure I'm following why you would need to destroy and recreate the domain itself as you mentioned in your initial report. Are you seeing behavior that differs from what I saw?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. resource-import Pertains to issues importing resources. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. resource-import Pertains to issues importing resources. service/opensearch Issues and PRs that pertain to the opensearch service. waiting-response Maintainers are waiting on response from community or contributor.
Projects
None yet
Development

No branches or pull requests

2 participants