Skip to main content
The Service component lets you deploy a containerized service to Amazon ECS Fargate.

Constructor

sst.config.ts
const service = new sst.aws.Service("MyService", {
  cluster,
  vpc,
  loadBalancer: {
    ports: [{ listen: "80/http" }]
  }
});

Parameters

cluster

cluster
Cluster
required
The cluster to deploy this service in.
{
  cluster: myCluster
}

vpc

vpc
Vpc
required
The VPC to deploy this service in.
{
  vpc: myVpc
}

image

image
string | object
The Docker image or Dockerfile to use for the service.
{
  image: "nginx:latest"
}
Or use a Dockerfile:
{
  image: {
    context: "./app",
    dockerfile: "Dockerfile"
  }
}

cpu

cpu
string
default:"0.25 vCPU"
The CPU units for the task.
{
  cpu: "1 vCPU"
}

memory

memory
string
default:"0.5 GB"
The memory for the task.
{
  memory: "2 GB"
}
Link resources to the service.
{
  link: [bucket, database]
}

Properties

url

nodes

Examples

Deploy a service

sst.config.ts
const vpc = new sst.aws.Vpc("MyVpc");
const cluster = new sst.aws.Cluster("MyCluster", { vpc });

new sst.aws.Service("MyService", {
  cluster,
  vpc,
  loadBalancer: {
    ports: [{ listen: "80/http" }]
  }
});

Use a Dockerfile

sst.config.ts
new sst.aws.Service("MyService", {
  cluster,
  vpc,
  image: {
    context: "./app",
    dockerfile: "Dockerfile"
  },
  loadBalancer: {
    ports: [{ listen: "80/http" }]
  }
});

Build docs developers (and LLMs) love