{"record":{"id":"ee1be2cf6a28fb5d","repo":"anomalyco/sst","slug":"cannot-access-the-created-function-because-it-is-r","errorCode":null,"errorMessage":"Cannot access the created function because it is referenced as an ARN.","messagePattern":"Cannot access the created function because it is referenced as an ARN\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/helpers/function-builder.ts","lineNumber":68,"sourceCode":"  return output(definition).apply((definition) => {\n    if (definition instanceof Workflow) {\n      return buildResult(definition.getFunction());\n    }\n\n    if (definition instanceof Function) {\n      return buildResult(definition);\n    }\n\n    if (typeof definition === \"string\") {\n      // Case 1: The definition is an ARN\n      if (definition.startsWith(\"arn:\")) {\n        const { unqualifiedArn, qualifier } = splitQualifiedFunctionArn(\n          definition,\n        );\n        const parts = definition.split(\":\");\n        return {\n          getFunction: () => {\n            throw new VisibleError(\n              \"Cannot access the created function because it is referenced as an ARN.\",\n            );\n          },\n          arn: output(unqualifiedArn),\n          targetArn: output(definition),\n          qualifier: output(qualifier),\n          targetInvokeArn: output(\n            `arn:${parts[1]}:apigateway:${parts[3]}:lambda:path/2015-03-31/functions/${definition}/invocations`,\n          ),\n          targetResponseStreamingInvokeArn: output(\n            `arn:${parts[1]}:apigateway:${parts[3]}:lambda:path/2021-11-15/functions/${definition}/response-streaming-invocations`,\n          ),\n        };\n      }\n\n      // Case 2: The definition is a handler\n      const fn = new Function(\n        ...transform(","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/helpers/function-builder.ts#L50-L86","documentation":"When a function is defined by an ARN string (an externally managed Lambda), SST only holds a reference to it and cannot resolve an inline Function resource. functionBuilder makes getFunction() throw a VisibleError because there is no locally created function to access.","triggerScenarios":"Defining a component value as a qualified ARN string (e.g. fn: \"arn:aws:lambda:...:function:x:1\") and then calling .getFunction() or otherwise treating it as a locally built function (via createFunction, createIssuer, fn, createServer, builder).","commonSituations":"Pointing an SST component at an existing Lambda by ARN and later trying to read function metadata (name, url, etc.) as if it were created by SST.","solutions":["Use the arn/targetArn/qualifier outputs instead of getFunction()","Create the function with SST (handler-based definition) if you need full function access","Split your config so ARN-referenced functions are only used for IAM/policy wiring"],"exampleFix":"// before\nconst fn = \"arn:aws:lambda:us-east-1:123:function:ext:1\"\nconst f = fn.getFunction()\n// after\nconst f = { arn: fn.arn, qualifier: fn.qualifier } // use arn outputs","handlingStrategy":"type-guard","validationCode":"function canGetFunction(fn: unknown): fn is { getFunction: () => unknown } {\n  return typeof fn === \"object\" && fn !== null && \"getFunction\" in fn && typeof (fn as any).arn !== \"string\";\n}","typeGuard":"const isArnReferenced = (fn: any) => typeof fn === \"string\" && fn.startsWith(\"arn:\");\n// if isArnReferenced(def) use def.arn/qualifier, never def.getFunction()","tryCatchPattern":"try { return fn.getFunction(); } catch { return { arn: fn.arn, qualifier: fn.qualifier }; }","preventionTips":["Never call getFunction() on ARN-defined functions","Document that ARN references expose only arn/targetArn/qualifier","Centralize function resolution in one helper"],"tags":["lambda","arn","external-resource"],"backgroundTag":"arn-referenced-resource-not-accessible","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}