Skip to content
23K
Console

OpenControl

Reference doc for the `sst.aws.OpenControl` component.

The OpenControl component lets you create centralized OpenControl servers on AWS. It deploys OpenControl to AWS Lambda.

Create an OpenControl server

sst.config.ts
const server = new sst.aws.OpenControl("MyServer", {
server: "src/server.handler"
});

Where the server function might look like this.

src/server.ts
import { handle } from "hono/aws-lambda";
import { create } from "opencontrol";
import { tool } from "opencontrol/tool";
const myTool = tool({
name: "my_tool",
description: "Get the most popular greeting",
async run() {
return "Hello, world!";
},
});
const app = create({
key: process.env.OPENCONTROL_KEY,
tools: [myTool],
});
export const handler = handle(app);

Learn more on the OpenControl docs on how to configure the server function.


Constructor

new OpenControl(name, args, opts?)

Parameters

OpenControlArgs

server

Type Input<string | FunctionArgs>

The function that’s running your OpenControl server.

{
server: "src/server.handler"
}

You can also pass in the full FunctionArgs.

{
server: {
handler: "src/server.handler",
link: [table]
}
}

Since the server function is a Hono app, you want to export it with the Lambda adapter.

src/server.ts
import { handle } from "hono/aws-lambda";
import { create } from "opencontrol";
const app = create({
// ...
});
export const handler = handle(app);

Learn more on the OpenControl docs on how to configure the server function.

Properties

nodes

Type Object

The underlying resources this component creates.

nodes.server

Type Output<Function>

The Function component for the server.

url

Type Output<string>

The URL of the OpenControl server.

SDK

Use the SDK in your runtime to interact with your infrastructure.


tools

Type Tool[]

A list of OpenControl tools provided by SST. Currently, it includes tools that can

  • Lists the resources in your SST app.
  • Access the resources in your AWS account.

You can add this tool to your OpenControl app by passing it to the tools option when creating an OpenControl app.

src/app.ts
import { create } from "opencontrol";
import { tools } from "sst/opencontrol";
const app = create({
key: process.env.OPENCONTROL_KEY,
tools: [...tools],
});