{"record":{"id":"a7c54a23c77b4945","repo":"anomalyco/sst","slug":"cannot-access-nodes-taskdefinition-in-dev-mode","errorCode":null,"errorMessage":"Cannot access `nodes.taskDefinition` in dev mode.","messagePattern":"Cannot access `nodes\\.taskDefinition` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service-v1.ts","lineNumber":824,"sourceCode":"       * The Amazon ECS Service.\n       */\n      get service() {\n        if ($dev)\n          throw new VisibleError(\"Cannot access `nodes.service` in dev mode.\");\n        return self.service!;\n      },\n      /**\n       * The Amazon ECS Task Role.\n       */\n      get taskRole() {\n        return self.taskRole;\n      },\n      /**\n       * The Amazon ECS Task Definition.\n       */\n      get taskDefinition() {\n        if ($dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.taskDefinition` in dev mode.\",\n          );\n        return self.taskDefinition!;\n      },\n      /**\n       * The Amazon Elastic Load Balancer.\n       */\n      get loadBalancer() {\n        if ($dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` in dev mode.\",\n          );\n        if (!self.loadBalancer)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` when no public ports are exposed.\",\n          );\n        return self.loadBalancer;\n      },","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service-v1.ts#L806-L842","documentation":"The `nodes.taskDefinition` getter on the v1 `Service` component returns the ECS Task Definition resource. In `sst dev` mode the task definition is not deployed (the app runs through the dev proxy), so SST raises a `VisibleError` explaining that the property cannot be accessed in dev mode.","triggerScenarios":"Reading `service.nodes.taskDefinition` while `sst dev` is active, e.g. to reference the task definition ARN, add task role policies, or inspect container definitions.","commonSituations":"Granting extra IAM permissions to the task role or attaching the service to other AWS resources in shared code that executes during the dev loop.","solutions":["Guard the access with `if (!$dev)` so it only executes on deploy.","Access the task role via `nodes.taskRole` only in non-dev branches, or use component-level APIs that work in dev.","Move resource-wiring code into the component constructor arguments (e.g. `permissions` prop) which supports dev mode."],"exampleFix":"// before\nbucket.grantRead(myService.nodes.taskDefinition.taskRole);\n\n// after\nif (!$dev) {\n  bucket.grantRead(myService.nodes.taskDefinition.taskRole);\n} else {\n  // use myService.nodes.taskRole or the permissions prop\n}","handlingStrategy":"validation","validationCode":"if (!$dev) {\n  const td = myService.nodes.taskDefinition;\n}","typeGuard":"const isDeploy = (): boolean => !($dev as boolean);","tryCatchPattern":"try {\n  return myService.nodes.taskDefinition;\n} catch (e) {\n  if (e instanceof VisibleError && e.message.includes(\"taskDefinition\")) return undefined;\n  throw e;\n}","preventionTips":["Use the `permissions` prop on the Service instead of mutating the task role via nodes.","Grep your stack for `nodes.taskDefinition` and confirm each is dev-guarded.","Test stacks with `sst dev` regularly to catch dev-incompatible accesses early."],"tags":["aws","ecs","dev-mode","sst"],"backgroundTag":"resource-unavailable-in-dev-mode","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}