Open vicary opened 2 years ago
I've just encountered the same issue. Is there any progress on the above or at least is it correct that Appsync does not support ndjson?
I would also love to hear any updates on this.
Another temporary solution may be to create a HTTP Resolver with Opensearch as the endpoint as HTTP Resolvers support ndjson.
However, I cannot create a working request mapping template to prove that this approach can work, debugging is difficult.
@benmcp AppSync API has a method evalucate-mapping-template
which you can quickly generates an output with a manually crafted input JSON as its context.
See the Testing section here https://github.com/aws/aws-appsync-community/issues/147#issuecomment-1231754613 for more information, you may call that via aws-sdk
programmatically or via AWS CLI.
HTTP resolver comes with the question of security, because AppSync neither uses dedicated IP range for domain level access control in Opensearch, nor a trivial method to do IAM v4 signing inside VTL.
I am still curious about your test results on the HTTP resolver, it's nice to know at least it works.
Thanks for the heads up on the evalucate-mapping-template
method, I did not know this existed.
Also, very good point about security. I was going to say we lock down opensearch via IP and IAM Role conditions but to your point, HTTP Resolvers don't actually have a method of associating a role (I read your comment and thought "what, you can totally associate a role to a HTTP Resolver...", but turns out that is indeed not true) and as you mentioned, neither does it have a trivial method to do IAM v4 signing inside VTL.
But yes I'll report back with my findings when I get back around to it if I find (a non secure) method. I feel like documentation is getting a bit sparse around these areas. Fingers crossed support for bulk API is coming in the near future!
I have a pipeline resolver for an AppSync Mutation. It contains two functions, the first one is a Lambda sending updates to RDS, the second one should take the result from
$ctx.prev.result
and index it via OpenSearch datasource.In the request resolver mapping template of the second one, I am composing the bulk body in NDJSON similar to the following mannar:
Lacking proper debugging tools, I have been using
$util.error
as a logging method to get my$bulk
contents. And it looks like the following format, which seems correct.But when I actually runs the mutation via AppSync, I got a
MappingTemplate
errorUnable to transform for the body: $[params][body].
.I took a look at [re:Post] Appsync HTTP resolver supported content types, which inspired me to take another look at Resolver Mappping Template for OpenSearch (params). It seems that POST body only accepts a single JSON object.