{"record":{"id":"b31b062fd089e3b4","repo":"anomalyco/sst","slug":"cannot-access-nodes-service-in-dev-mode-b31b06","errorCode":null,"errorMessage":"Cannot access `nodes.service` in dev mode.","messagePattern":"Cannot access `nodes\\.service` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service.ts","lineNumber":2882,"sourceCode":"        return this.dev\n          ? interpolate`dev.${namespace}`\n          : interpolate`${service!.name}.${namespace}`;\n      },\n    );\n  }\n\n  /**\n   * The underlying [resources](/docs/components/#nodes) this component creates.\n   */\n  public get nodes() {\n    const self = this;\n    return {\n      /**\n       * The Amazon ECS Service.\n       */\n      get service() {\n        if (self.dev)\n          throw new VisibleError(\"Cannot access `nodes.service` in dev mode.\");\n        return self._service!;\n      },\n      /**\n       * The Amazon ECS Execution Role.\n       */\n      executionRole: this.executionRole,\n      /**\n       * The Amazon ECS Task Role.\n       */\n      taskRole: this.taskRole,\n      /**\n       * The Amazon ECS Task Definition.\n       */\n      get taskDefinition() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.taskDefinition` in dev mode.\",\n          );","sourceCodeStart":2864,"sourceCodeEnd":2900,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service.ts#L2864-L2900","documentation":"In `sst dev` (dev mode) the Service does not run as an ECS service on AWS — it runs locally via DevCommand — so the underlying `nodes.service` (the Amazon ECS Service resource) does not exist. Accessing `nodes.service` in dev mode throws this VisibleError to prevent referencing a resource that was never created.","triggerScenarios":"Reading `myService.nodes.service` while running `sst dev` on a Service configured for local development. It only succeeds in deploy mode where the ECS service resource exists.","commonSituations":"Shared IAM/policy code that references the ECS service node being executed during local dev; writing exports or grants that unconditionally read `nodes.service` and then running the dev session; tests that run against dev infrastructure.","solutions":["Only access `nodes.service` in deploy mode; branch on the dev flag (or run the code only during `sst deploy`).","Use `nodes.executionRole` or other resources that are available in dev if that's what you actually need.","If you need the ECS service reference in dev, skip it — there is no ECS service during dev by design."],"exampleFix":"// before\nexport const ecsService = svc.nodes.service; // throws in sst dev\n// after\nexport const ecsService = $dev ? null : svc.nodes.service;","handlingStrategy":"type-guard","validationCode":"if (isDev() && needEcsServiceNode) {\n  throw new Error(\"nodes.service is only available in deploy mode\");\n}","typeGuard":"function hasEcsServiceNode(svc: { nodes: { service?: unknown } }): boolean {\n  return svc.nodes.service != null;\n}","tryCatchPattern":"let ecsService;\ntry {\n  ecsService = svc.nodes.service;\n} catch (e) {\n  if (e instanceof VisibleError && e.message.includes(\"Cannot access `nodes.service` in dev mode\")) {\n    ecsService = null; // no ECS service exists during sst dev\n  } else {\n    throw e;\n  }\n}","preventionTips":["Gate `nodes.service` access behind a deploy-mode check (e.g. `$dev ? null : svc.nodes.service`).","Use `nodes.executionRole` or other dev-available resources when possible.","Never export ECS service nodes unconditionally from stack files that also run in dev.","Structure IAM/policy code so ECS-only references live in deploy-only code paths."],"tags":["aws","ecs","dev-mode","sst-dev","resource-access"],"backgroundTag":"resource-unavailable-in-dev-mode","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}