Skip to content

[Bug] elasticstack_fleet_integration_policy redeploys the integration package even if it already exists. #1299

@santhoshza

Description

@santhoshza

Describe the bug
elasticstack_fleet_integration_policy resource tries to redeploy the integration package even though the specified version is already installed.
And can't seems to replicate the successful policy creation even using the example shown in the provider resource documentation.

To Reproduce
Steps to reproduce the behavior:

  1. Install "tcp" integration in kibana and add policies manually.
  2. Now follow the steps in the elasticstack_fleet_integration_policy terraform resource documentation to create a new integration policy. https://registry.terraform.io/providers/elastic/elasticstack/0.11.17/docs/resources/fleet_integration_policy
  3. You will see that the package is reinstalled and existing policies are removed. Also it throws error to create new policy.
  4. If you have already used the manually created policy in any agents, then the terraform will fail to redeploy the package.

Expected behavior
The resource should not deploy the integration package and just complain if it doesn't exists. And then the new policy to be created successfully.
And documentation update to list out more examples to provision the integration policies.

Debug output
Run terraform command with TF_LOG=trace and provide extended information on TF operations. Please ensure you redact any base64 encoded credentials from your output.
eg

module.tenants.elasticstack_fleet_integration_policy.sample: Creating...

│ Error: Unexpected status code from server: got HTTP 400

│ with module.tenants.elasticstack_fleet_integration_policy.sample,
│ on ../module/tenants/fleet.tf line 84, in resource "elasticstack_fleet_integration_policy" "sample":
│ 84: resource "elasticstack_fleet_integration_policy" "sample" {

│ {"statusCode":400,"error":"Bad Request","message":"Stream not found tcp-tcp: tcp.generic"}

Another error for reinstalling the integration package,

{"statusCode":400,"error":"Bad Request","message":"Unable to remove package filestream:1.2.0 with existing package policy(s) in use by agent(s)"}

[DEBUG] provider.terraform-provider-elasticstack_v0.11.0: Authorization: Basic xxxxx==

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • OS: RHEL 9
  • Terraform Version 1.13.2
  • Provider version 0.11.17
  • Elasticsearch Version 9.1.3

Additional context
Add any other context about the problem here. Links to specific affected code files and paths here are also extremely useful (if known).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions