Note: If your question is regarding the AWS Amplify Console service, please log it in the
official AWS Amplify Console forum
* Which Category is your question related to? *
AppSync with @searchable
* What AWS Services are you utilizing? *
appsync elasticsearch service
* Provide additional details e.g. code snippets *
Hi :) I would like to customize ElasticSearchStreamingLambda?When I add following schema, lambda was created with python code (ElasticSearchStreamingLambdaFunction.zip).
type Test @model @searchable {
id: ID!
}
So I would like to use nodejs or golang and customize lambda code.
Is it possible now?? I can not find better way yet...
Should I edit cloudformation-template.json in the manual?
Should I create another function by myself then overwrite ElasticsearchStreamingFunctionName (https://aws-amplify.github.io/docs/cli/graphql#elasticsearchstreamingfunctionname) ?
@bokuweb Yes, you could probably do that as mentioned in https://aws-amplify.github.io/docs/cli/graphql#elasticsearchstreamingfunctionname
@kaustavghosh06 Thanks for your quick response :) I'll try it
Can I overwrite ElasticSearchStreamingLambdaHandlerName and ElasticSearchStreamingLambdaRuntime too ? It seems that it is not documented.
@bokuweb Were you able to overwrite the parameters?
@kaustavghosh06 Sorry, I did not do it yet. I'll try it and write result here :)
@bokuweb setting https://aws-amplify.github.io/docs/cli/graphql#elasticsearchstreamingfunctionname will only change the name of the Lambda, but you can not override the code, it will still use the same zip containing the Python code, here is a piece of the template definition
"ElasticSearchStreamingLambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "S3DeploymentBucket"
},
"S3Key": {
"Fn::Join": [
"/",
[
{
"Ref": "S3DeploymentRootKey"
},
"functions",
{
"Fn::Join": [
".",
[
"ElasticSearchStreamingLambdaFunction",
"zip"
]
]
}
]
]
}
},
Right now, I don't see any doc that references how to use a custom Lambda instead of the auto-generated one.
You can still copy the autogenerated stack SearchableStack.json from the build folder of another project, copy it to the _amplify\backend\api\pgaplatform\stacks_ inside yours, then customize the Lambda. It will require to edit a few files in the process, but it will be ideal that amplify support it out of the box.
@kstro21 Thanks for your reply :)
will only change the name of the Lambda, but you can not override the code, it will still use the same zip containing the Python code,
Hmmm.It is very disappointing... 馃槩
You can still copy the autogenerated stack SearchableStack.json from the build folder of another project, copy to the _amplify\backend\api\pgaplatform\stacks_ inside yours, the customize the Lambda. It will require to edit a few files in the process, but it will be ideal that amplify support it out of the box.
Thanks 馃憤 I'll try and do some investigation.
@kaustavghosh06 @mikeparisstuff Do you have any idea??
@bokuweb This is currently not possible although I agree that this is useful and it would not be too difficult to implement. Currently the ElasticSearchStreamingLambdaFunctionName argument changes the name of the function deployed by Amplify but this is only partially useful. We can add a parameter "ElasticSearchStreamingLambdaFunctionArn" parameter that you could use to point to an existing function. Once adding that we need to make a few tweaks to the EventSourceMapping resource here https://github.com/aws-amplify/amplify-cli/blob/767f3a6edce9f8c4109e18afacf648c6d4c7be56/packages/graphql-elasticsearch-transformer/src/resources.ts#L164-L168
I have added this to the backlog and would be happy to review a PR.
@mikeparisstuff Thanks for your reply :) What should I do specifically? I will try to fix it if possible.
I have added this to the backlog and would be happy to review a PR.
馃帀
@mikeparisstuff and @kaustavghosh06 wouldn't be easy to allow for stacks in amplify\backend\api\amplifytest\stacks\ to update stacks with the exact same name in amplify\backend\api\amplifytest\build\stacks\ by doing a deep merge? That will be interesting to see. Just thinking.
Most helpful comment
@bokuweb This is currently not possible although I agree that this is useful and it would not be too difficult to implement. Currently the ElasticSearchStreamingLambdaFunctionName argument changes the name of the function deployed by Amplify but this is only partially useful. We can add a parameter "ElasticSearchStreamingLambdaFunctionArn" parameter that you could use to point to an existing function. Once adding that we need to make a few tweaks to the EventSourceMapping resource here https://github.com/aws-amplify/amplify-cli/blob/767f3a6edce9f8c4109e18afacf648c6d4c7be56/packages/graphql-elasticsearch-transformer/src/resources.ts#L164-L168
I have added this to the backlog and would be happy to review a PR.