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
}