Skip to main content

Integration

Introduction

An Integration is a connection between two services, for example an AWS Step Function calling a Lambda Function, or a Lambda Function writing to a DynamoDB Table.

Integrations are a fundamental concept in building modern cloud applications. Cloud providers such as AWS have services that manage integrations on your behalf, relieving you from scaling, operational and compliance responsibilities encountered in more traditional server-based applications.

Integrations as Function Calls

Functionless makes configuring an Integrations as simple as calling a function, for example:

const split = new Function(this, "SplitString", (text: string) =>
text.split(",")
);

new StepFunction(this, "Integration", async (sentence: string) => {
const words = await split(sentence);
for (const word of words) {
// etc.
}
});

This code has two cloud services, an AWS Step Function and Lambda Function, and one integration where the Step Function invokes the stringSplit Lambda Function.

graph LR; Integration -->|lambda::Invoke| Split IAM_Policy[IAM Policy] -->|Allow lambda:Invoke| Integration IAM_Policy -.- Split

The Functionless compiler analyzes this code to: 1) automatically create a minimally permissive IAM Policy with access to invoke the stringSplit Lambda Function, and 2) generate the corresponding service configuration, in this case a Task State in Amazon States Language JSON (ASL).

All integrations in Functionless follow this same pattern. Using Functionless should feel like writing ordinary application code, no boiler-plate and no DSLs!

Supported Integrations

  • Function - the cloud's swiss army knife, an AWS Lambda Function. Functionless serializes in-line Function closures and automatically configures IAM Policies and Environment Variables, and initializes SDK clients (such as the AWS SDK) at runtime.
  • DynamoDB Table - a DynamoDB Table can be called from any functional integration, such as Function, Appsync Resolver, Step Function and Express Step Function.
  • Appsync Resolver - resolve fields in a GraphQL APi's Query, Mutation and Subscribe operations.
  • Step Function - orchestrate long-running asynchronous workflows with AWS Step Functions.
  • Express Step Function - short-running synchronous or asynchronous workflows. Express Step Functions can often be a great replacement for intermediate Lambda Functions in APIs.
  • Event Bus Rule - filter events flowing through an AWS Event Bridge Bus, optionally transform them and finally route them to a downstream integration, e.g. a Lambda Function, Step Function, SQS Queue, etc.
  • User Pool - manage user sign-up, sign-in, and access control for your application.
  • Secret - securely store and distribute sensitive data to parts of your application that require it.

Integration Context

An Integration can be called from various contexts, called an Integration Context. An Integration Context refers to how and where an API is called, for example from within a Lambda Function (called the Native context) or from within a Step Function (called the Amazon States Language context). Each Integration Context has its own constraints and domain-specific-language configurations that are compiled by Functionless from your TypeScript code.

All of the Integration Contexts supported by a particular Integration are provided by the Integration object. This object contains the following (below) properties. If a context is unsupported, then the corresponding property can be omitted and an error will be thrown during CDK synthesis.

NamePropertyDescriptionCaller ContextInterface
Amazon States LanguageaslIAM Policies and a Task definition in the Amazon States Language to invoke an Integration from within a Step Function or Express Step Function.StepFunction and ExpressStepFunctionNone
API Gateway Velocity TemplatesapiGWVtlIAM Policies, Velocity Templates (VTL) and REST API Gateway Integration to handle a HTTP request by calling an Integration.AwsMethodAppSyncVtlIntegration
App Sync Velocity TemplatesappSyncVtlIAM Policies, Velocity Templates (VTL) and App Sync Pipeline Resolver used with AWS App Sync to invoke the Integration.AppsyncResolverAppSyncVtlIntegration
Native FunctionnativeCreates IAM Policies, Environment Variables and initializes SDK clients for Integrations to be invoked within a lambda Function.FunctionNativeIntegration
Event BuseventBusCreate an Event Bridge Target to (asynchronously) forward events matched by an Event Bridge Rule to the Integration.EventBusEventBusTargetIntegration