Skip to content

Commit 02d51a9

Browse files
Pranav-Dakshinapranav-chefman
authored andcommitted
Changed: use try to simplify code
1 parent d30ee23 commit 02d51a9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ resource "aws_appsync_resolver" "this" {
191191
}
192192

193193
# code is required when runtime is APPSYNC_JS
194-
code = lookup(each.value, "kind", null) == "PIPELINE" && lookup(each.value, "runtime", null) == "APPSYNC_JS" ? lookup(each.value, "code") : null
194+
code = try(each.value.kind == "PIPELINE" && each.value.runtime == "APPSYNC_JS", false) ? each.value.code : null
195195

196-
request_template = lookup(each.value, "request_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_request_template : lookup(each.value, "kind", null) == "PIPELINE" && lookup(each.value, "runtime", null) == "APPSYNC_JS" ? null : "{}")
197-
response_template = lookup(each.value, "response_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_response_template : lookup(each.value, "kind", null) == "PIPELINE" && lookup(each.value, "runtime", null) == "APPSYNC_JS" ? null : "{}")
196+
request_template = lookup(each.value, "request_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_request_template : try(each.value.kind == "PIPELINE" && each.value.runtime == "APPSYNC_JS", false) ? null : "{}")
197+
response_template = lookup(each.value, "response_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_response_template : try(each.value.kind == "PIPELINE" && each.value.runtime == "APPSYNC_JS", false) ? null : "{}")
198198

199199
data_source = lookup(each.value, "data_source", null) != null ? aws_appsync_datasource.this[each.value.data_source].name : lookup(each.value, "data_source_arn", null)
200200

0 commit comments

Comments
 (0)