Skip to content

[Bug] Not possible to set inactivity_timeout in a Fleet policyΒ #641

@joeafari

Description

@joeafari

Describe the bug
I want to create a Fleet policy using the provider using resource https://registry.terraform.io/providers/elastic/elasticstack/latest/docs/resources/fleet_agent_policy and set the inactivity_timeout as allowed by the Fleet API: https://www.elastic.co/guide/en/fleet/8.13/fleet-apis.html#agent_policy_create_request

But inactivity_timeout is not available.

To Reproduce
Steps to reproduce the behavior:

  1. Use the provider to create a Fleet policy

Expected behavior
I want to be able to use inactivity_timeout to set a custom timeout

Actual behavior
inactivity_timeout is not available

Versions

  • OS: Any
  • Terraform Version: Any
  • Provider version: 0.11.3

Additional context
As a workaround it's possible to set the inactivity_timeout after the policy has been created using a null_resource

resource "null_resource" "update_elastic_agent_policy" {
   count = local.oss_addons.enable_elastic ? 1 : 0
   # Use a trigger that changes only when the agent policy changes.
   triggers = {
      policy = jsonencode(elasticstack_fleet_agent_policy.eks_policy[0])
   }
   
   provisioner "local-exec" {
      command = <<-EOT
      curl --location --request PUT '${var.elastic_kb_url}/api/fleet/agent_policies/${elasticstack_fleet_agent_policy.eks_policy[0].id}' \
      --header 'Authorization: Basic ${data.vault_kv_secret_v2.kibana[0].data.apikey}' \
      --header 'kbn-xsrf: kibana' \
      --header 'agentPolicyId: ${elasticstack_fleet_agent_policy.eks_policy[0].id}' \
      --header 'Content-Type: application/json' \
      --data '{
         "name": "${elasticstack_fleet_integration_policy.eks[0].name}",
         "namespace": "eks",
         "description": "eks policy",
         "inactivity_timeout": 120
      }'
      EOT
   }
}

Additional context:

  • The existing resource is located in internal/fleet/agent_policy
  • You'll need to add a new optional inactivity_timeout attribute to the schema and ensure this is passed through to the create/update requests within the resource
  • Make sure to add an entry to the changelog referencing the PR fixing this issue
  • Make sure the inactivity_timeout attribute is covered by the acceptance tests, also make sure the existing configurations continues to work by having at least one test without an inactivity_timeout configured.
  • Make sure all the acceptance tests pass, there are Elastic stack instances running within the Copilot environment, run the tests with make testacc.

Metadata

Metadata

Assignees

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