Repository navigation
chore: the Lambda, EC2 and Secrets Manager sinks can do more than one operation, Translate can detect the language and use terminologies, Polly can use lexicons (#3170) - #3235
Merged
Conversation
… operation, Translate can detect the language and use terminologies, Polly can use lexicons (apache#3170) - aws-lambda-sink: `operation`, to read the settings, versions or aliases of the function, list the functions of the region, or publish a new version, instead of calling the function. Unset, the function is called as before. - aws-ec2-sink: `operation` (default describeInstancesStatus, as before): also describeInstances, startInstances, stopInstances and rebootInstances, which act on the instances of the instanceIds header. Creating and terminating instances is not offered. - aws-secrets-manager-sink: `operation` (default createSecret, as before): also updateSecret and getSecret, which work on the secret in the new `secretId` option (name or ARN) and fail when it is not set; createSecret names the secret as before. And `binaryPayload`, to store the body as the binary value of a secret. - aws-translate-action: `autodetectSourceLanguage`, so `sourceLanguage` is no longer required, and `terminologyNames`, set as the terminology names header only when the option is set. - aws-polly-sink: `lexiconNames`. With the new options unset, the endpoint URIs are the same as on main. Asynchronous Lambda invocation and paging of aws-timestream-query-sink need a change in Camel first, so they are left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3170:
aws-lambda-sink,aws-ec2-sinkandaws-secrets-manager-sinkcan do more than their one operation,aws-translate-actioncan detect the language of each message and apply custom terminologies, andaws-polly-sinkcan apply pronunciation lexicons.The options
aws-lambda-sinkoperationoperation: "{{?operation}}"invokeFunction(what it does today),getFunction,getFunctionConfiguration,listVersions,listAliases,publishVersion,listFunctions. Each acts on the function infunction; onlyinvokeFunctionuses the body.aws-ec2-sinkoperationoperation: "{{operation}}",default: describeInstancesStatusdescribeInstancesStatus(today's),describeInstances,startInstances,stopInstances,rebootInstances, on the instances of theinstanceIdsheader.aws-secrets-manager-sinkoperationoperation: "{{operation}}",default: createSecretcreateSecret(today's),updateSecret(the body becomes the new value of the secret insecretId, as a new version),getSecret(the value of the secret insecretIdgoes into the body).aws-secrets-manager-sinksecretIdchoiceon the operation: forupdateSecretandgetSecret,setHeaderCamelAwsSecretsManagerSecretIdto the constant{{?secretId}}, orthrowExceptionwhen it is emptyupdateSecretandgetSecretwork on; required for them, not used bycreateSecret.aws-secrets-manager-sinkbinaryPayloadbinaryPayload: "{{?binaryPayload}}"createSecretandupdateSecretstore the bytes of the body asSecretBinaryinstead ofSecretString.aws-translate-actionautodetectSourceLanguage&autodetectSourceLanguage={{?autodetectSourceLanguage}}SourceLanguageCode: auto).aws-translate-actionterminologyNameschoicethat, only when the option is set, setsCamelAwsTranslateTerminologyNamesto${split('{{?terminologyNames}}',',')}aws-polly-sinklexiconNameslexiconNames: "{{?lexiconNames}}"operationhas adefaultonly for EC2 and Secrets Manager, where the component has none and the template pinned the operation in the URI; the default is that same operation, so the URI does not change. For Lambda the component defaults toinvokeFunction, so the option has nodefaultand drops out of the URI when unset. With all the new options unset, the endpoint URIs are byte-identical tomain's (see below).deleteFunctionare left out.instanceIds/ce-instanceids. The template's steps are unchanged; only its comment is updated for the new option.createAndRunInstances,createTagsanddeleteTagsneed input (image, instance type, tags) that the Kamelet has no options or headers for, andterminateInstancescannot be undone, so they are left out. Start, stop and reboot without the header fail withInstances Ids must be specified; they never act on all instances.createSecretnames the new secret as before: from thesecret-nameheader, elsece-secret-name, else the message ID.updateSecretandgetSecretwork on the secret in the newsecretIdoption (name or ARN, with apattern:). The template now starts with achoiceon the operation:createSecretruns the naming steps ofmain, unchanged; the other two setCamelAwsSecretsManagerSecretIdfromsecretId, or, when it is not set, fail the message withIllegalArgumentException: The secretId option must be set for the updateSecret operation(orgetSecret) before anything is sent to AWS.CamelAwsSecretsManagerSecretVersionIdis declared as an output header ofgetSecret.sourceLanguageis no longerrequired, since withautodetectSourceLanguageit is not used. Its mapping is now{{?sourceLanguage}}; when it is set, the URI is as before. With neither option, the Kamelet starts, and a message fails withThe source language is missing: ...unless it carries theCamelAwsTranslateSourceLanguageheader; onmainthe Kamelet did not start.CamelAwsTranslateTerminologyNamesheader, which it reads as aCollection.${split(...)}gives aString[], which converts to one. Thechoicesets the header only when the option is set, so with the option unset the template does the same as onmain.pattern::terminologyNamesfollows the name pattern of Amazon Translate (^([A-Za-z0-9-]_?)+$), andlexiconNamesthat of Polly ([0-9A-Za-z]{1,20}), both as comma-separated lists.Left out, as they need a change in Camel first:
InvocationType=Event): camel-aws2-lambda has no option or header for the invocation type; it always calls the function synchronously. The only way ispojoRequestwith anInvokeRequestbody built in Java, which a Kamelet cannot do. The Lambda description says that each call waits until the function ends. A Camel change could add aninvocationTypeoption (and header).aws-timestream-query-sink: the query operation of camel-aws2-timestream reads onlyCamelAwsTimestreamQueryStringandCamelAwsTimestreamQueryMaxRows. It takes no next token and sets none, so the next page of a result cannot be asked for. Setting only the maximum number of rows does not give paging, soaws-timestream-query-sinkis unchanged. A Camel change could add a next-token header in and out, or fetch all the pages.Verification
Tested with Camel JBang 4.24.0-SNAPSHOT:
floci/floci(2.5.0). Floci runs the Lambda functions (a Python function that sleeps 5 seconds and echoes its event) and the EC2 instances as Docker containers.aws-lambda-sink,aws-secrets-manager-sinkandaws-translate-actionhave no endpoint override option, so they were pointed at the stand-in with the AWS SDK'sAWS_ENDPOINT_URLenvironment variable.mainand this branchcamel get endpoint --jsonshows identical endpoint URIsoperationunset{"echo": {"orderId": "A-1"}, "slept": 5}after 5 s,CamelAwsLambdaStatusCode200invokeFunctiongetFunctionGetFunctionResponse: namew6svc-echo, runtimepython3.12, code locationgetFunctionConfigurationGetFunctionConfigurationResponse: timeout 30, memory 128, handlerhandler.handlerpublishVersion, withCamelAwsLambdaVersionDescription: release onePublishVersionResponse: version1, descriptionrelease onelistVersionsafter thatListVersionsByFunctionResponsewith 2 versions ($LATEST,1)listAliasesListAliasesResponse(Aliases=[])listFunctionsListFunctionsResponsewith 1 function,w6svc-echooperationunset,instanceIds= one instanceDescribeInstanceStatusResponsefor that instance:running, checksokdescribeInstancesDescribeInstancesResponse, instance typet2.microstopInstancesStopInstancesResponserunning->stopping; Floci then reportsstoppedand its container exitsstartInstanceson that stopped instanceStartInstancesResponsestopped->pending; Floci then reportsrunningand its container runsrebootInstancesRebooted EC2 container, and the container's start time changes; the body is left as it wasstopInstanceswithoutinstanceIdsInstances Ids must be specifiedstopInstanceson Camel 4.23.0StopInstancesResponse(StoppingInstances=[]): no instance is stopped (the description says so)operationunset,secret-name: w6svc/db-password, bodyfirst-valueCreateSecretResponseoperationunset,ce-secret-name: w6svc/ce-namedw6svc/ce-namedoperationunsetResourceExistsException, as onmainupdateSecret,secretId: w6svc/db-password, bodysecond-valueUpdateSecretResponsewith a new version IDgetSecret,secretId: w6svc/db-passwordsecond-value(aString),CamelAwsSecretsManagerSecretVersionId= the new version IDgetSecret,secretId= the ARN of that secretsecond-valueupdateSecret,secretId: w6svc/db-password, message withsecret-name: w6svc/otherw6svc/db-passwordgets the new value;w6svc/otherkeeps its valueupdateSecretwithoutsecretIdIllegalArgumentException: The secretId option must be set for the updateSecret operation; no secret changesgetSecretwithoutsecretIdIllegalArgumentException: The secretId option must be set for the getSecret operationgetSecret,secretIdof a missing secretResourceNotFoundExceptioncreateSecretwithsecretIdset and no name headersecretIdis not usedbinaryPayload: true,createSecret, bodybinary-bytesSecretBinary(YmluYXJ5LWJ5dGVz) and noSecretString;getSecretgives abyte[]binaryPayload: true,updateSecretwithsecretId, bodynew-binary, thengetSecretbyte[]withnew-binarysourceLanguage: itSourceLanguageCode: it, noTerminologyNamesautodetectSourceLanguage: true, nosourceLanguageSourceLanguageCode: autoautodetectSourceLanguage: trueandsourceLanguage: deSourceLanguageCode: autoThe source language is missing: ...terminologyNames: product-namesTerminologyNames: ["product-names"]terminologyNames: product-names,brand_namesTerminologyNames: ["product-names", "brand_names"]lexiconNamesunsetLexiconNames; body is the audio,CamelAwsPollyContentTypeaudio/mpeglexiconNames: w3cLexiconNames: ["w3c"]lexiconNames: w3c,acronymsLexiconNames: ["w3c", "acronyms"]./mvnw clean verify -DskipTestsand then./mvnw clean verifypassed from the root. Before building, the library copies of the five Kamelets were refreshed with./mvnw -pl library/camel-kamelets resources:copy-resources@copy-resource-one. The build regeneratedkamelets-index.json. No option counts inKameletsCatalogTestneeded changing.Claude Code on behalf of Claus Ibsen
🤖 Generated with Claude Code