segmentio / terraform-provider-segment

Terraform provider for Segment, using the Public API
https://registry.terraform.io/providers/segmentio/segment/latest
MIT License
25 stars 3 forks source link

insert_function_instance resource does not work with ID output from segment_function resource for insert functions #85

Closed backjo closed 5 months ago

backjo commented 5 months ago

Description The segment_insert_function_instance resource does not work with the ID being output from the segmentfunction resource as show in the documents. This appears to be due to the ifnd prefix being output from segment_function, which causes a 404 not found on the insert-function-instances API because it expects the prefix to be trimmed / not be present

To Reproduce

Example Terraform code that triggers the issue:

resource "segment_function" "amplitude_insert_function" {
  code          = <<EOF
EOF
  display_name  = "Amplitude Insert Function"
  logo_url      = "https://placekitten.com/200/138"
  resource_type = "INSERT_DESTINATION"
  description   = "This is function to insert context into amplitude events"
  settings      = []
}
resource "segment_insert_function_instance" "amplitude_instance" {
  integration_id = segment_destination.my_amplitude_instance.id
  function_id    = segment_function.amplitude_insert_function.id
  name           = "Amplitude Destination Function"
  enabled        = true
  settings       = jsonencode({})
}
cv commented 5 months ago

Thank you for the report, @backjo! You're right, the prefix needs to be stripped from the ID. You can use the built-in https://developer.hashicorp.com/terraform/language/functions/trimprefix for this.

We'll update the documentation shortly to reflect that.

backjo commented 5 months ago

hey @cv - that's totally what we're doing to workaround. Ideally, it'd behave like the other TF resources and I'd be able to take the output ID from the insert_function as the argument for function_id

deanhuynh commented 5 months ago

Hi @backjo this has been fixed in v0.10.0. Thanks for waiting!