{"record":{"id":"4ef693f70d268949","repo":"anomalyco/sst","slug":"type-service-you-cannot-provide-both-con","errorCode":null,"errorMessage":"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\".`","messagePattern":"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\"\\.`","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/fargate.ts","lineNumber":865,"sourceCode":"}\n\nexport function normalizeContainers(\n  type: \"service\" | \"task\",\n  args: Omit<ServiceArgs, \"public\">,\n  name: string,\n  architecture: ReturnType<typeof normalizeArchitecture>,\n) {\n  if (\n    args.containers &&\n    (args.image ||\n      args.logging ||\n      args.environment ||\n      args.environmentFiles ||\n      args.volumes ||\n      args.health ||\n      args.ssm)\n  ) {\n    throw new VisibleError(\n      type === \"service\"\n        ? `You cannot provide both \"containers\" and \"image\", \"logging\", \"environment\", \"environmentFiles\", \"volumes\", \"health\" or \"ssm\".`\n        : `You cannot provide both \"containers\" and \"image\", \"logging\", \"environment\", \"environmentFiles\", \"volumes\" or \"ssm\".`,\n    );\n  }\n\n  // Standardize containers\n  const containers = args.containers ?? [\n    {\n      name: name,\n      cpu: undefined,\n      memory: undefined,\n      image: args.image,\n      logging: args.logging,\n      environment: args.environment,\n      environmentFiles: args.environmentFiles,\n      ssm: args.ssm,\n      volumes: args.volumes,","sourceCodeStart":847,"sourceCodeEnd":883,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/fargate.ts#L847-L883","documentation":"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.","triggerScenarios":"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\").","commonSituations":"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.","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"],"exampleFix":"// before\nnew sst.aws.Fargate(\"App\", {\n  containers: { app: { image: \"...\" } },\n  environment: { FOO: \"bar\" }\n});\n// after\nnew sst.aws.Fargate(\"App\", {\n  containers: { app: { image: \"...\", environment: { FOO: \"bar\" } } }\n});","handlingStrategy":"validation","validationCode":"const hasShorthands = !!(args.image || args.logging || args.environment || args.environmentFiles || args.volumes || args.health || args.ssm);\nif (args.containers && hasShorthands) throw new Error(\"Cannot combine containers with single-container shorthand options\");","typeGuard":null,"tryCatchPattern":"try {\n  new sst.aws.Fargate(\"App\", fargateArgs);\n} catch (e) {\n  if ((e as Error).message.includes(\"cannot provide both\")) {\n    console.error(\"Move shorthand options into the containers map\");\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["aws","fargate","config-conflict","validation"],"backgroundTag":"mutually-exclusive-config-options","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}