aws-amplify / aws-amplify/docs

Best practices around exporting/import backend

Open
#7,603 2 comments 0 reactions 0 assignees View on GitHub
amplify/backend p3
Dominant language
MDX
Stars
506
Forks
1.1k
Avg merge
3h 14m
Merged PRs (30d)
1

Description

I'm building a project and the number of custom resources are growing. Most/all examples show custom resources added to `backend.ts`, and I wonder what the best approach would be if I were to extract resources into separate files. My question is mainly on how backend should be handled.

E.g. if I have a custom RestAPI construct, should I be doing this
```
new RestAPI(restApiStack, 'rest-api', {
functions: {
createCustomer: backend.createCustomerHandler.resources.lambda,
createEmployee: backend.createEmployeeHandler.resources.lambda,
},
});

vs

just importing backend from within the RestApi construct? Not sure if exporting backend would result in circular dependencies from a CDK perspective.

Contributor guide

Open the contributing guide

Research direction

Start with the examples that place custom resources in backend.ts and inspect how the RestAPI construct receives the handler resources. Compare the two organization patterns described in the issue, then document a decided recommendation for extracting resources and handling imports, including whether circular dependencies are a concern.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
backend, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.