anomalyco/sst · error · VisibleError
type === "service" ? `You cannot provide both "containers" a
Error message
type === "service" ? `You cannot provide both "containers" and "image", "logging", "environment", "environmentFiles", "volumes", "health" or "ssm".` : `You cannot provide both "containers" and "image", "logging", "environment", "environmentFiles", "volumes" or "ssm".`
What it means
normalizeContainers() in the Fargate component rejects configurations that define `containers` while also providing any of the service-level shorthands (image, logging, environment, environmentFiles, volumes, health, ssm). The shorthands are mutually exclusive with the explicit `containers` map because they are just sugar for a single implicit container.
Source
Thrown at platform/src/components/aws/fargate.ts:865
}
export function normalizeContainers(
type: "service" | "task",
args: Omit<ServiceArgs, "public">,
name: string,
architecture: ReturnType<typeof normalizeArchitecture>,
) {
if (
args.containers &&
(args.image ||
args.logging ||
args.environment ||
args.environmentFiles ||
args.volumes ||
args.health ||
args.ssm)
) {
throw new VisibleError(
type === "service"
? `You cannot provide both "containers" and "image", "logging", "environment", "environmentFiles", "volumes", "health" or "ssm".`
: `You cannot provide both "containers" and "image", "logging", "environment", "environmentFiles", "volumes" or "ssm".`,
);
}
// Standardize containers
const containers = args.containers ?? [
{
name: name,
cpu: undefined,
memory: undefined,
image: args.image,
logging: args.logging,
environment: args.environment,
environmentFiles: args.environmentFiles,
ssm: args.ssm,
volumes: args.volumes,View on GitHub (pinned to a0bd20f762)
Solutions
- Remove the top-level shorthand properties and move them into the relevant container inside `containers`
- Or remove `containers` and keep the single-container shorthand style
- For shared settings across multiple containers, repeat them per container or use the low-level awsx/CDK constructs
Example fix
// before
new sst.aws.Fargate("App", {
containers: { app: { image: "..." } },
environment: { FOO: "bar" }
});
// after
new sst.aws.Fargate("App", {
containers: { app: { image: "...", environment: { FOO: "bar" } } }
}); Defensive patterns
Strategy: validation
Validate before calling
const hasShorthands = !!(args.image || args.logging || args.environment || args.environmentFiles || args.volumes || args.health || args.ssm);
if (args.containers && hasShorthands) throw new Error("Cannot combine containers with single-container shorthand options"); Try / catch
try {
new sst.aws.Fargate("App", fargateArgs);
} catch (e) {
if ((e as Error).message.includes("cannot provide both")) {
console.error("Move shorthand options into the containers map");
}
throw e;
} Prevention
- Pick one style: either containers map or single-container shorthands, never both
- When migrating to multi-container, delete the old top-level keys in the same commit
- Keep a shared config object you spread into each container
When it happens
Trigger: Calling new sst.aws.Fargate("App", { containers: {...}, environment: {...} }) or FargateService with both containers and image/logging/volumes/ssm. The "health" option is only flagged for the FargateService variant (type === "service").
Common situations: Incrementally migrating a single-container config to multi-container by adding `containers` while leaving the old top-level `environment` or `image` keys in place; copy-pasting an example that mixes both styles.
Related errors
- Unsupported storage: ${v}. The supported value for storage i
- The listen protocol "${v.listen}" must match the forward pro
- Only one of function, queue, or topic is allowed for the "${
- Lifecycle rule at index ${index} has an empty or whitespace-
- The DNS record "${partial.name}" cannot be created because t
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/4ef693f70d268949.
Report an issue: GitHub.