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

Traffic filter association gets removed on second terraform apply #510

Closed
4 tasks done
Jacendb opened this issue Jun 28, 2022 · 2 comments
Closed
4 tasks done

Traffic filter association gets removed on second terraform apply #510

Jacendb opened this issue Jun 28, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Jacendb
Copy link

Jacendb commented Jun 28, 2022

ec provider 0.4.1

traffic_filter_association resource gets deleted when doing plan/apply after being applied the first time.

Readiness Checklist

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I am reporting the issue to the correct repository (for multi-repository projects)

Expected Behavior

If no changes to terraform code have been made, terraform should NOT delete a resource in a following plan/apply run.

Current Behavior

I spun up a managed EC deployment with a traffic_filter and traffic_filter_association resources. Everything deploys ok.
When I do plan/apply a second time, the association gets removed. Apply again and it gets added.
I already destroyed and created everything on GCE and ES sides to reproduce the issue.

First plan:

  # module.elasticsearch.ec_deployment_traffic_filter_association.elasticsearch will be created
  + resource "ec_deployment_traffic_filter_association" "elasticsearch" {
      + deployment_id     = (known after apply)
      + id                = (known after apply)
      + traffic_filter_id = (known after apply)
    }

Second plan:

  # module.elasticsearch.ec_deployment.elasticsearch will be updated in-place
  ~ resource "ec_deployment" "elasticsearch" {
        id                     = "04add8bddea98dbac26a80e4ef579b97"
        name                   = "fox2-elasticsearch"
        tags                   = {}
      ~ traffic_filter         = [
          - "c02b53bc30a34b2db9017426fdccb28a",
        ]
        # (6 unchanged attributes hidden)


        # (2 unchanged blocks hidden)
    }

Third plan:

Terraform will perform the following actions:

  # module.elasticsearch.ec_deployment_traffic_filter_association.elasticsearch will be created
  + resource "ec_deployment_traffic_filter_association" "elasticsearch" {
      + deployment_id     = "04add8bddea98dbac26a80e4ef579b97"
      + id                = (known after apply)
      + traffic_filter_id = "c02b53bc30a34b2db9017426fdccb28a"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

I wonder if something gets updated in the traffic filter association after it is created by terraform.

## Terraform definition

data "ec_stack" "elasticsearch" {
  version_regex = "latest"
  region        = "gcp-us-east-4"
}

resource "ec_deployment" "elasticsearch" {
  name = "fox2-elasticsearch"

  region                 = data.ec_stack.elasticsearch.region
  version                = data.ec_stack.elasticsearch.version
  deployment_template_id = "gcp-storage-optimized"

  elasticsearch {}
  kibana {}
}

resource "ec_deployment_traffic_filter" "gcp_psc" {
  name        = "fox2-psc"
  region      = data.ec_stack.elasticsearch.region
  type        = "gcp_private_service_connect_endpoint"
  description = "Endpoint for fox2 in GCP"

  rule {
    source = google_compute_forwarding_rule.elasticsearch.psc_connection_id
  }
}

resource "ec_deployment_traffic_filter_association" "elasticsearch" {
  traffic_filter_id = ec_deployment_traffic_filter.gcp_psc.id
  deployment_id     = ec_deployment.elasticsearch.id
}

Steps to Reproduce

  1. Create an EC deployment
  2. Create a traffic rule and traffic rule association for above deployment
  3. terraform plan/apply
  4. Repeat plan/apply and see how association gets destroyed

Context

This issue currently prevents automating a managed ES deployment.

Possible Solution

Your Environment

  • Provider version used: 0.4.1
  • ES version: 8.2.3 (latest)
  • Running against Elastic Cloud SaaS or Elastic Cloud Enterprise and version: 8.2.3
@Jacendb Jacendb added the bug Something isn't working label Jun 28, 2022
@thomasisaacsibille
Copy link

Hi,
We have same problem,
To fix it, you can add this code to resource "ec_deployment" "elasticsearch"

  lifecycle {
    ignore_changes = [
      traffic_filter,
    ]
  }

@tobio
Copy link
Member

tobio commented Jul 19, 2022

Duplicate of #419

@tobio tobio marked this as a duplicate of #419 Jul 19, 2022
@tobio tobio closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants