aws-appsyncvtl

How can I reuse/import code in vtl appsync resolvers?


I want to avoid duplication of certain declarations in my vtl templates and share them between vtl resolvers.

Let's say I have a sample dict in mapping_templates/shared.vtl

#set($sample_mappings = {
    "KEY1": "VALUE1",
    "KEY2": "KEY2"
})

which I want to use in mapping_templates/sample_request_mapping_template.vtl, for example to do:

$sample_mappings.get("KEY1")

I tried the following with no success:

#parse("shared.vtl")
OR
#include("shared.vtl")

$sample_mappings.get("KEY1")

Really seems like a very basic feature, but I don't see it documented on aws' resolver guide, and I'm thinking this might not be supported as AppSync vtl doesn't even support all standard features of vtl.


Solution

  • Unfortunately this feature is not supported currently.

    I will +1 this request to the team on your behalf.