Open bokuweb opened 5 years ago
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.
I see that this is an old issue, but it's still open and a bit misleading. I contacted AWS support and they pointed out that it is now possible to override the StreamingLambda function code as well
Something similar to
import { AmplifyApiGraphQlResourceStackTemplate } from '@aws-amplify/cli-extensibility-helper';
export function override(resources: AmplifyApiGraphQlResourceStackTemplate) {
resources.opensearch.OpenSearchStreamingLambdaFunction.runtime = 'python3.9';
resources.opensearch.OpenSearchStreamingLambdaFunction.functionName = 'python_streaming_function';
resources.opensearch.OpenSearchStreamingLambdaFunction.handler = 'index.lambda_handler';
resources.opensearch.OpenSearchStreamingLambdaFunction.code = {
zipFile: `
...
`
};
not sure if the override handler takes priority over CloudFormationStack parameters, so in the team-provider-info.json you may need to add
"api": {
"<api_name>": {
"OpenSearchInstanceType": "t3.small.elasticsearch",
"OpenSearchStreamingLambdaHandlerName": "index.lambda_handler"
},
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).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?