Amazon Lambda · Arazzo Workflow

Amazon Lambda Deploy and Invoke Function

Version 1.0.0

Create a Lambda function, wait for it to become Active, then invoke it.

1 workflow 1 source API 1 provider
View Spec View on GitHub ComputeEvent-DrivenFaaSFunctionsServerlessArazzoWorkflows

Provider

amazon-lambda

Workflows

deploy-and-invoke-function
Create a function, poll until Active, and invoke it.
Creates a Lambda function, polls GetFunction until the State reported by Lambda is Active, branches on the terminal Failed state, and then invokes the function with a sample payload.
4 steps inputs: Description, FunctionName, Handler, MemorySize, Role, Runtime, Timeout, invocationPayload outputs: failedState, functionArn, invocationResult
1
createFunction
CreateFunction
Create the Lambda function from the supplied runtime, role, and handler. The function is typically returned in the Pending state.
2
waitForActive
GetFunction
Poll the function until Lambda reports it has finished provisioning. A State of Active continues to invocation; a State of Failed branches to the failure handler.
3
invokeFunction
InvokeFunction
Invoke the now-Active function with the supplied event payload and capture the response.
4
reportFailure
GetFunction
Re-read the function configuration when it has entered the Failed state so the caller can surface the terminal state.

Source API Descriptions

Arazzo Workflow Specification

amazon-lambda-deploy-and-invoke-function-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Amazon Lambda Deploy and Invoke Function
  summary: Create a Lambda function, wait for it to become Active, then invoke it.
  description: >-
    The canonical Lambda deployment flow. A new function is created from a
    deployment package, the workflow then polls GetFunction until the function
    leaves the Pending state and reports Active, branching to a failure path if
    the function ends up in the Failed state, and finally invokes the function to
    confirm it is working. Every step spells out its request inline so the flow
    can be read and executed without opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: amazonLambdaApi
  url: ../openapi/amazon-lambda-openapi.yml
  type: openapi
workflows:
- workflowId: deploy-and-invoke-function
  summary: Create a function, poll until Active, and invoke it.
  description: >-
    Creates a Lambda function, polls GetFunction until the State reported by
    Lambda is Active, branches on the terminal Failed state, and then invokes the
    function with a sample payload.
  inputs:
    type: object
    required:
    - FunctionName
    - Runtime
    - Role
    - Handler
    properties:
      FunctionName:
        type: string
        description: The name of the Lambda function to create (e.g. my-function).
      Runtime:
        type: string
        description: The function's runtime identifier (e.g. python3.12).
      Role:
        type: string
        description: The execution role ARN the function assumes when invoked.
      Handler:
        type: string
        description: The handler Lambda calls to begin execution.
      Description:
        type: string
        description: An optional description for the function.
      Timeout:
        type: integer
        description: The number of seconds Lambda allows the function to run.
      MemorySize:
        type: integer
        description: The amount of memory (in MB) available to the function.
      invocationPayload:
        type: object
        description: The JSON event payload to send to the function on invocation.
  steps:
  - stepId: createFunction
    description: >-
      Create the Lambda function from the supplied runtime, role, and handler.
      The function is typically returned in the Pending state.
    operationId: CreateFunction
    requestBody:
      contentType: application/json
      payload:
        FunctionName: $inputs.FunctionName
        Runtime: $inputs.Runtime
        Role: $inputs.Role
        Handler: $inputs.Handler
        Description: $inputs.Description
        Timeout: $inputs.Timeout
        MemorySize: $inputs.MemorySize
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      functionArn: $response.body#/FunctionArn
      initialState: $response.body#/State
  - stepId: waitForActive
    description: >-
      Poll the function until Lambda reports it has finished provisioning. A
      State of Active continues to invocation; a State of Failed branches to the
      failure handler.
    operationId: GetFunction
    parameters:
    - name: FunctionName
      in: path
      value: $inputs.FunctionName
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      state: $response.body#/State
    onSuccess:
    - name: functionActive
      type: goto
      stepId: invokeFunction
      criteria:
      - context: $response.body
        condition: $.State == "Active"
        type: jsonpath
    - name: functionFailed
      type: goto
      stepId: reportFailure
      criteria:
      - context: $response.body
        condition: $.State == "Failed"
        type: jsonpath
    onFailure:
    - name: retryGet
      type: retry
      retryAfter: 5
      retryLimit: 20
      stepId: waitForActive
  - stepId: invokeFunction
    description: >-
      Invoke the now-Active function with the supplied event payload and capture
      the response.
    operationId: InvokeFunction
    parameters:
    - name: FunctionName
      in: path
      value: $inputs.FunctionName
    requestBody:
      contentType: application/json
      payload: $inputs.invocationPayload
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      invocationResult: $response.body
    onSuccess:
    - name: done
      type: end
  - stepId: reportFailure
    description: >-
      Re-read the function configuration when it has entered the Failed state so
      the caller can surface the terminal state.
    operationId: GetFunction
    parameters:
    - name: FunctionName
      in: path
      value: $inputs.FunctionName
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      failedState: $response.body#/State
  outputs:
    functionArn: $steps.createFunction.outputs.functionArn
    invocationResult: $steps.invokeFunction.outputs.invocationResult
    failedState: $steps.reportFailure.outputs.failedState