diff --git a/src/pages/[platform]/build-a-backend/functions/custom-functions/index.mdx b/src/pages/[platform]/build-a-backend/functions/custom-functions/index.mdx index 66117c8e1b7..41a6ec0516e 100644 --- a/src/pages/[platform]/build-a-backend/functions/custom-functions/index.mdx +++ b/src/pages/[platform]/build-a-backend/functions/custom-functions/index.mdx @@ -110,15 +110,15 @@ You're now ready to deploy your python function. Next is the same process as the To get started, Create a new directory and a resource file, `amplify/functions/say-hello/resource.ts`. Then, define the function with `defineFunction`: ```ts title="amplify/functions/say-hello/resource.ts" -import { defineFunction } from "@aws-amplify/backend"; -import { DockerImage, Duration } from "aws-cdk-lib"; -import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda"; import { execSync } from "node:child_process"; import * as path from "node:path"; import { fileURLToPath } from "node:url"; import { defineFunction } from "@aws-amplify/backend"; import { DockerImage, Duration } from "aws-cdk-lib"; import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda"; +import { defineFunction } from "@aws-amplify/backend"; +import { DockerImage, Duration } from "aws-cdk-lib"; +import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda"; export const sayHelloFunctionHandler = defineFunction( (scope) => new Function(scope, "say-hello", { @@ -193,6 +193,7 @@ You're now ready to deploy your golang function. Next is the same process as the ## Common steps for all languages Regardless of the language used, your function needs to be added to your backend. +```ts title="amplify/backend.ts" // highlight-next-line import { sayHelloFunctionHandler } from './functions/say-hello/resource'; @@ -204,10 +205,9 @@ defineBackend({ Now when you run `npx ampx sandbox` or deploy your app on Amplify, it will include your Function. -To invoke your Function, we recommend adding your [Function as a handler for a custom query with your Amplify Data resource](/[platform]/build-a-backend/data/custom-business-logic/). This will enable you to strongly type Function arguments and the return statement, and use this to author your Function's business logic. To get started, open your `amplify/data/resource.ts` file and specify a new query in your schema: +To invoke your function, we recommend adding your [function as a handler for a custom query with your Amplify Data resource](/[platform]/build-a-backend/data/custom-business-logic/). To get started, open your `amplify/data/resource.ts` file and specify a new query in your schema: ```ts title="amplify/data/resource.ts" -Now when you run `npx ampx sandbox` or deploy your app on Amplify, it will include your function. import { sayHelloFunctionHandler } from "../functions/say-hello/resource" const schema = a.schema({