Resolver mapping template reference for RDS - AWS AppSync

Resolver mapping template reference for RDS

The AWS AppSync RDS resolver mapping templates allow developers to send SQL queries to a Data API for Amazon Aurora Serverless and get back the result of these queries.

Request mapping template

The RDS request mapping template is fairly simple:

{ "version": "2018-05-29", "statements": [], "variableMap": {} }

Here is the JSON schema representation of the RDS request mapping template, once resolved.

{ "definitions": {}, "$schema": "", "$id": "", "type": "object", "title": "The Root Schema", "required": [ "version", "statements", "variableMap" ], "properties": { "version": { "$id": "#/properties/version", "type": "string", "title": "The Version Schema", "default": "", "examples": [ "2018-05-29" ], "enum": [ "2018-05-29" ], "pattern": "^(.*)$" }, "statements": { "$id": "#/properties/statements", "type": "array", "title": "The Statements Schema", "items": { "$id": "#/properties/statements/items", "type": "string", "title": "The Items Schema", "default": "", "examples": [ "SELECT * from BOOKS" ], "pattern": "^(.*)$" } }, "variableMap": { "$id": "#/properties/variableMap", "type": "object", "title": "The Variablemap Schema" } } }

The following is an example of the request mapping template with a static query:

{ "version": "2018-05-29", "statements": [ "select title, isbn13 from BOOKS where author = 'Mark Twain'" ] }


Common to all request mapping templates, the version field defines the version that the template uses. The version field is required. The value “2018-05-29” is the only version supported for the Amazon RDS mapping templates.

"version": "2018-05-29"


The statements array is a placeholder for the developer provided queries. Currently, up to two queries per request mapping template are supported. The following is possible:

{ "version": "2018-05-29", "statements": [ $util.toJson("insert into BOOKS VALUES ('$', '$ctx.args.newBook.title', '$ctx.args.newBook.ISBN13')"), $util.toJson("select * from BOOKS WHERE isbn13 = '$ctx.args.newBook.isbn13'") ] }

AWS AppSync supports up to two statements per request mapping template.


The variableMap is an optional field which contains aliases that can be used to make the SQL statements shorter and more readable. For example the following is possible:

{ "version": "2018-05-29", "statements": [ "insert into BOOKS VALUES (:AUTHOR, :TITLE, :ISBN13)", "select * from BOOKS WHERE isbn13 = :ISBN13" ], "variableMap": { ":AUTHOR": $util.toJson($, ":TITLE": $util.toJson($ctx.args.newBook.title), ":ISBN13": $util.toJson($ctx.args.newBook.isbn13) } }

AWS AppSync will use the variable map value to construct the queries that are sent to the Amazon Aurora Serverless Data API. For example the two queries that AWS AppSync will send to Amazon RDS will be (assuming “$"='Mark Twain', "$ctx.args.newBook.title"='Adventures of Huckleberry Finn' and "$ctx.args.newBook.isbn13"='978-1948132817'):

INSERT INTO BOOKS VALUES ('Mark Twain', 'Adventures of Huckleberry Finn', '978-1948132817');


SELECT from BOOKS where isbn13='978-1948132817';