Hero's backgroundHero's background
Connectors / aws-lambda

Orchestrating AWS Lambda Microservices

AWS Lambda is a serverless compute service from Amazon Web Services (AWS) that can be used to build a microservice architecture for backends. Connectors enables applications to securely coordinate Lambda microservices without needing a trigger (like an API Gateway) for every microservice - reduced API Gateway costs.

Try out the Connector!

  • Click ► GetFunction to run the operation. You just got back config information for a Lambda! Don't see GetFunction? Try closing the tab in Sandbox.

    Due to Sigv4, if you want to try this out with your lambdas you will need to run the Connector with your AWS keys. Scroll down for instructions.

  • Toggle the Response dropdown and select Query Plan. This is the strategy for executing an incoming operation efficiently.

  • Toggle the Query Plan dropdown to Connectors Debugger to click into the details of each request.

Get Started with Your Lambda Microservices

  • Create a new graph in GraphOS and follow the "Set up your local development environment" instructions.

  • Create a user in IAM with at least lambda:GetFunction and lambda:ListFunctions permissions (AWS docs) - create an Access Key for quick testing or see the Apollo docs for IAM roles configuration.

  • Update your local router.yaml file to configure Sigv4 authentication:

authentication:
  connector:
    sources:
      products.lambda:
      aws_sig_v4:
        default_chain:
          region: "us-east-1"
          service_name: "lambda"
        # assume_role: # <- 
        #   role_arn: "arn:aws:iam::{accountId}:role/{roleName}"
        #   session_name: "connector"
  • Modify your local schema to reflect the shape of your AWS Lambda response. Make sure to modify the baseURL in the @source directive to reflect the region your AWS Lambda is deployed to (example).

  • Run rover dev with your IAM user Access Key for Sigv4 authentication.

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
rover dev \
  --supergraph-config supergraph.yaml \
  --router-config router.yaml

Connectors resources