OpenControl
Reference doc for the `sst.aws.OpenControl` component.
The OpenControl
component lets you deploy your
OpenControl server to
AWS Lambda.
Create an OpenControl server
const server = new sst.aws.OpenControl("MyServer", { server: "src/server.handler"});
Link your AI API keys
const anthropicKey = new sst.Secret("AnthropicKey");
const server = new sst.aws.OpenControl("MyServer", { server: { handler: "src/server.handler", link: [anthropicKey] }});
Link your resources
If your tools are need access to specific resources, you can link them to the OpenControl server.
const bucket = new sst.aws.Bucket("MyBucket");
new sst.aws.OpenControl("MyServer", { server: { handler: "src/server.handler", link: [bucket] }});
Give AWS permissions
If you are using the AWS tool within OpenControl, you will need to give your OpenControl server permissions to access your AWS account.
new sst.aws.OpenControl("OpenControl", { server: { handler: "src/server.handler", policies: $dev ? ["arn:aws:iam::aws:policy/AdministratorAccess"] : ["arn:aws:iam::aws:policy/ReadOnlyAccess"] }});
Here we are giving it admin access in dev but read-only access in prod.
Define your server
Your server
function might look like this.
import { Resource } from "sst";import { create } from "opencontrol";import { tool } from "opencontrol/tool";import { handle } from "hono/aws-lambda";import { createAnthropic } from "@ai-sdk/anthropic";
const myTool = tool({ name: "my_tool", description: "Get the most popular greeting", async run() { return "Hello, world!"; }});
const app = create({ model: createAnthropic({ apiKey: Resource.AnthropicKey.value, })("claude-3-7-sonnet-20250219"), tools: [myTool],});
export const handler = handle(app);
Learn more in the OpenControl docs on how to configure
the server
function.
Constructor
new OpenControl(name, args, opts?)
Parameters
-
name
string
-
args
OpenControlArgs
-
opts?
ComponentResourceOptions
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.
import { handle } from "hono/aws-lambda";import { create } from "opencontrol";
const app = create({ // ...});
export const handler = handle(app);
Learn more in the OpenControl docs on how to
configure the server
function.
Properties
nodes
nodes.server
Type Output
<
Function
>
The Function component for the server.
password
Type Output
<
string
>
The password for the OpenControl 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 Tools
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 server by passing it to the tools
option when creating it.
import { create } from "opencontrol";import { tools } from "sst/opencontrol";
const app = create({ model: // ... tools: [...tools]});