0

When I will create the AppSync resolver with linked function by the terraform, everything is created and it works.

But error will arise, If I will rename the function in terraform file, which is linked to some resolver and then I execute terraform apply again. Terraform cannot apply changes, because It wants to re-create function, which is linked to resolver. I was thinking, that If I will add depends_on field into resolver, it will solve this problem, but It didn't helped. it won't do anything and still I have the same problem.

Error deleting AppSync Function... BadRequestException: Cannot delete a function which is currently used by a resolver. Resolver type: Test, field: testField

Therefore I was trying opposite way. I added "depends_on" field into function pointing to resolver, but after that, I get an "Circular dependency" error during terraform apply.

Error: Cycle: module..., module..., module..., ....

How can I correctly use the terraform dependencies to solve this problem?

Short example:


resource "aws_appsync_resolver" "TestResolver" {
  api_id            = var.app-sync-id
  field             = "testField"
  type              = "Query"
  request_template  = "{}"
  response_template = "$util.toJson($context.result)"
  kind              = "PIPELINE"

  pipeline_config {
    functions = [
      aws_appsync_function.TestFunction.function_id
    ]
  }
}

resource "aws_appsync_function" "TestFunction" {
  api_id                   = var.app-sync-id
  data_source              = local.table-name
  name                     = "TestFunction"
  request_mapping_template = <<EOF
    ...whatever
EOF

  response_mapping_template = <<EOF
...whatever
EOF
}
klaucode
  • 180
  • 1
  • 10
  • 2
    Please add the relevant code to the question. – Marko E Jan 10 '23 at 20:00
  • @MarkoE Hi, thanks a lot for your response. I updated the question, you can check. Its simple resolver with pipeline and single function. Nothing special... – klaucode Jan 10 '23 at 21:26
  • 1
    It seems there is an open issue for the AWS terraform provider: https://github.com/hashicorp/terraform-provider-aws/issues/15480. Also, when you say you changed the name, was it the logical name or the `name` argument? Also which provider and terraform version are you using? – Marko E Jan 10 '23 at 21:49
  • TF 1.3.4 and aws provider 4.38.0 – klaucode Jan 10 '23 at 22:43
  • ...I updated to latest versions of TF and providers, and It doesn't helped – klaucode Jan 11 '23 at 09:50

0 Answers0