github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/processors/aws_lambda.md (about)

     1  ---
     2  title: aws_lambda
     3  type: processor
     4  status: stable
     5  categories: ["Integration"]
     6  ---
     7  
     8  <!--
     9       THIS FILE IS AUTOGENERATED!
    10  
    11       To make changes please edit the contents of:
    12       lib/processor/aws_lambda.go
    13  -->
    14  
    15  import Tabs from '@theme/Tabs';
    16  import TabItem from '@theme/TabItem';
    17  
    18  
    19  Invokes an AWS lambda for each message. The contents of the message is the
    20  payload of the request, and the result of the invocation will become the new
    21  contents of the message.
    22  
    23  Introduced in version 3.36.0.
    24  
    25  
    26  <Tabs defaultValue="common" values={[
    27    { label: 'Common', value: 'common', },
    28    { label: 'Advanced', value: 'advanced', },
    29  ]}>
    30  
    31  <TabItem value="common">
    32  
    33  ```yaml
    34  # Common config fields, showing default values
    35  label: ""
    36  aws_lambda:
    37    parallel: false
    38    function: ""
    39    region: eu-west-1
    40  ```
    41  
    42  </TabItem>
    43  <TabItem value="advanced">
    44  
    45  ```yaml
    46  # All config fields, showing default values
    47  label: ""
    48  aws_lambda:
    49    parallel: false
    50    function: ""
    51    rate_limit: ""
    52    region: eu-west-1
    53    endpoint: ""
    54    credentials:
    55      profile: ""
    56      id: ""
    57      secret: ""
    58      token: ""
    59      role: ""
    60      role_external_id: ""
    61    timeout: 5s
    62    retries: 3
    63  ```
    64  
    65  </TabItem>
    66  </Tabs>
    67  
    68  It is possible to perform requests per message of a batch in parallel by setting
    69  the `parallel` flag to `true`. The `rate_limit`
    70  field can be used to specify a rate limit [resource](/docs/components/rate_limits/about)
    71  to cap the rate of requests across parallel components service wide.
    72  
    73  In order to map or encode the payload to a specific request body, and map the
    74  response back into the original payload instead of replacing it entirely, you
    75  can use the [`branch` processor](/docs/components/processors/branch).
    76  
    77  ### Error Handling
    78  
    79  When Benthos is unable to connect to the AWS endpoint or is otherwise unable to invoke the target lambda function it will retry the request according to the configured number of retries. Once these attempts have been exhausted the failed message will continue through the pipeline with it's contents unchanged, but flagged as having failed, allowing you to use [standard processor error handling patterns](/docs/configuration/error_handling).
    80  
    81  However, if the invocation of the function is successful but the function itself throws an error, then the message will have it's contents updated with a JSON payload describing the reason for the failure, and a metadata field `lambda_function_error` will be added to the message allowing you to detect and handle function errors with a [`branch`](/docs/components/processors/branch):
    82  
    83  ```yaml
    84  pipeline:
    85    processors:
    86      - branch:
    87          processors:
    88            - aws_lambda:
    89                function: foo
    90          result_map: |
    91            root = if meta().exists("lambda_function_error") {
    92              throw("Invocation failed due to %v: %v".format(this.errorType, this.errorMessage))
    93            } else {
    94              this
    95            }
    96  output:
    97    switch:
    98      retry_until_success: false
    99      cases:
   100        - check: errored()
   101          output:
   102            reject: ${! error() }
   103        - output:
   104            resource: somewhere_else
   105  ```
   106  
   107  ### Credentials
   108  
   109  By default Benthos will use a shared credentials file when connecting to AWS
   110  services. It's also possible to set them explicitly at the component level,
   111  allowing you to transfer data across accounts. You can find out more
   112  [in this document](/docs/guides/cloud/aws).
   113  
   114  ## Examples
   115  
   116  <Tabs defaultValue="Branched Invoke" values={[
   117  { label: 'Branched Invoke', value: 'Branched Invoke', },
   118  ]}>
   119  
   120  <TabItem value="Branched Invoke">
   121  
   122  
   123  This example uses a [`branch` processor](/docs/components/processors/branch/) to map a new payload for triggering a lambda function with an ID and username from the original message, and the result of the lambda is discarded, meaning the original message is unchanged.
   124  
   125  ```yaml
   126  pipeline:
   127    processors:
   128      - branch:
   129          request_map: '{"id":this.doc.id,"username":this.user.name}'
   130          processors:
   131            - aws_lambda:
   132                function: trigger_user_update
   133  ```
   134  
   135  </TabItem>
   136  </Tabs>
   137  
   138  ## Fields
   139  
   140  ### `parallel`
   141  
   142  Whether messages of a batch should be dispatched in parallel.
   143  
   144  
   145  Type: `bool`  
   146  Default: `false`  
   147  
   148  ### `function`
   149  
   150  The function to invoke.
   151  
   152  
   153  Type: `string`  
   154  Default: `""`  
   155  
   156  ### `rate_limit`
   157  
   158  An optional [`rate_limit`](/docs/components/rate_limits/about) to throttle invocations by.
   159  
   160  
   161  Type: `string`  
   162  Default: `""`  
   163  
   164  ### `region`
   165  
   166  The AWS region to target.
   167  
   168  
   169  Type: `string`  
   170  Default: `"eu-west-1"`  
   171  
   172  ### `endpoint`
   173  
   174  Allows you to specify a custom endpoint for the AWS API.
   175  
   176  
   177  Type: `string`  
   178  Default: `""`  
   179  
   180  ### `credentials`
   181  
   182  Optional manual configuration of AWS credentials to use. More information can be found [in this document](/docs/guides/cloud/aws).
   183  
   184  
   185  Type: `object`  
   186  
   187  ### `credentials.profile`
   188  
   189  A profile from `~/.aws/credentials` to use.
   190  
   191  
   192  Type: `string`  
   193  Default: `""`  
   194  
   195  ### `credentials.id`
   196  
   197  The ID of credentials to use.
   198  
   199  
   200  Type: `string`  
   201  Default: `""`  
   202  
   203  ### `credentials.secret`
   204  
   205  The secret for the credentials being used.
   206  
   207  
   208  Type: `string`  
   209  Default: `""`  
   210  
   211  ### `credentials.token`
   212  
   213  The token for the credentials being used, required when using short term credentials.
   214  
   215  
   216  Type: `string`  
   217  Default: `""`  
   218  
   219  ### `credentials.role`
   220  
   221  A role ARN to assume.
   222  
   223  
   224  Type: `string`  
   225  Default: `""`  
   226  
   227  ### `credentials.role_external_id`
   228  
   229  An external ID to provide when assuming a role.
   230  
   231  
   232  Type: `string`  
   233  Default: `""`  
   234  
   235  ### `timeout`
   236  
   237  The maximum period of time to wait before abandoning an invocation.
   238  
   239  
   240  Type: `string`  
   241  Default: `"5s"`  
   242  
   243  ### `retries`
   244  
   245  The maximum number of retry attempts for each message.
   246  
   247  
   248  Type: `int`  
   249  Default: `3`  
   250  
   251