Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Implementation Plan for elasticsearch_script Import Support

  • Add ImportState method to the script resource
  • Add interface assertion for ResourceWithImportState
  • Add import test to the acceptance test suite
  • Test the import functionality - All tests pass
  • Run code review - No blocking issues
  • Run security checks - No vulnerabilities found
  • Add CHANGELOG entry with PR reference

Summary

Successfully implemented import functionality for the elasticstack_elasticsearch_script resource. The implementation:

  • Uses the import ID format <cluster_uuid>/<script_id> consistent with other resources
  • Includes comprehensive acceptance tests
  • Follows the project's coding standards
  • All tests pass (including manual verification)
  • No security vulnerabilities detected
  • CHANGELOG entry added with PR Add import support for elasticsearch_script resource #1637 reference
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] elasticstack_elasticsearch_script: Error: Resource Import Not Implemented</issue_title>
<issue_description>Describe the bug
The elasticstack_elasticsearch_script resource does not support the terraform import command, preventing users from importing existing Elasticsearch scripts into the state. The provider documentation indicates that import should be supported for this resource: documentation

To Reproduce
Steps to reproduce the behavior:

  1. TF configuration used:
resource "elasticstack_elasticsearch_script" "search_template" {
  for_each = {for search_template in local.search_templates_var : search_template.name => search_template}
  
  script_id = each.key
  lang      = "mustache"
  source    = each.value.source
}
  1. TF operations to execute to get the error:
terraform import 'module.elk.module.pipelines.elasticstack_elasticsearch_script.search_template["my_search_template"]' 'cluster01/my_search_template'

The resource address format attempted was <cluster_id>/<script_id> based on typical Elasticstack provider patterns.

  1. See the error in the output:
Error: Resource Import Not Implemented

This resource does not support import. Please contact the provider developer for additional information.

Expected behavior
The terraform import command should successfully import the existing Elasticsearch script/search template into the Terraform state, allowing users to manage existing resources with Terraform without recreating them.

Debug output

│ Error: Resource Import Not Implemented
│ 
│ This resource does not support import. Please contact the provider developer for additional information.

Versions :

  • OS: Linux amd 64
  • Terraform Version: v1.14.3
  • Provider version: v0.13.1
  • Elasticsearch Version: v9.2.3</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix import support for elasticstack_elasticsearch_script resource Add import support for elasticsearch_script resource Jan 23, 2026
Copilot AI requested a review from tobio January 23, 2026 23:31
@tobio
Copy link
Member

tobio commented Jan 24, 2026

@copilot add a change of entry for this PR

Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot add a change of entry for this PR

Added CHANGELOG entry in commit 71ae2cf

CHANGELOG.md Outdated

### Changes

- Add import support for `elasticstack_elasticsearch_script` resource
Copy link
Member

Choose a reason for hiding this comment

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

@copilot update the changelog to reference this PR.

Suggested change
- Add import support for `elasticstack_elasticsearch_script` resource
- Add import support for `elasticstack_elasticsearch_script` resource ([#1637](https://github.com/elastic/terraform-provider-elasticstack/pull/1637))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in commit 17c6126

Copilot AI requested a review from tobio January 25, 2026 22:44
@tobio tobio marked this pull request as ready for review January 27, 2026 10:20
@tobio tobio requested review from Copilot and dimuon January 27, 2026 10:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds import functionality to the elasticstack_elasticsearch_script resource, resolving a bug where users could not import existing Elasticsearch scripts into Terraform state.

Changes:

  • Implements ImportState method using the standard <cluster_uuid>/<script_id> format
  • Adds comprehensive acceptance tests for the import functionality
  • Updates CHANGELOG with the new feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/elasticsearch/cluster/script/resource.go Adds ImportState method and interface assertions to enable import functionality
internal/elasticsearch/cluster/script/acc_test.go Adds acceptance test validating import behavior with proper cluster ID resolution
CHANGELOG.md Documents the new import support feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] elasticstack_elasticsearch_script: Error: Resource Import Not Implemented

3 participants