Use Amplify backends across apps (Gen 1 apps only)
Note
The information in this section is for Gen 1 apps only. If you want to share backend
resources for a Gen 2 app, see Share resources across branches
Amplify enables you to reuse existing backend environments across all of your Gen 1 apps in a given region. You can do this when you create a new app, connect a new branch to an existing app, or update an existing frontend to point to a different backend environment.
Reuse backends when creating a new app
To reuse a backend when creating a new Amplify app
-
Sign in to the AWS Management Console and open the Amplify console
. -
To create a new backend to use for this example, do the following:
-
In the navigation pane, choose All apps.
-
Choose New app, Build an app.
-
Enter a name for your app, such as
Example-Amplify-App
. -
Choose Confirm deployment.
-
-
To connect a frontend to your new backend, choose the Hosting environments tab.
-
Choose your git provider, and then choose Connect branch.
-
On the Add repository branch page, for Recently updated repositories, choose your repository name. For Branch, select the branch from your repository to connect.
-
On the Build settings, page do the following:
-
For App name, select the app to use for adding a backend environment. You can choose the current app or any other app in the current region.
-
For Environment, select the name of the backend environment to add. You can use an existing environment or create a new one.
-
By default, full-stack CI/CD is turned off. Turning off full-stack CI/CD causes the app to run in pull only mode. At build time, Amplify will automatically generate the
aws-exports.js
file only, without modifying your backend environment. -
Select an existing service role to give Amplify the permissions it requires to make changes to your app backend. If you need to create a service role, choose Create new role. For more information about creating a service role, see Adding a service role.
-
Choose Next.
-
-
Choose Save and deploy.
Reuse backends when connecting a branch to an existing app
To reuse a backend when connecting a branch to an existing Amplify app
-
Sign in to the AWS Management Console and open the Amplify console
. -
Choose the app to connect a new branch to.
-
In the navigation pane, choose App Settings, General.
-
In the Branches section, choose Connect a branch.
-
On the Add repository branch page, for Branch, select the branch from your repository to connect.
-
For App name, select the app to use for adding a backend environment. You can choose the current app or any other app in the current region.
-
For Environment, select the name of the backend environment to add. You can use an existing environment or create a new one.
-
If you need to set up a service role to give Amplify the permissions it requires to make changes to your app backend, the console prompts you to perform this task. For more information about creating a service role, see Adding a service role.
-
By default, full-stack CI/CD is turned off. Turning off full-stack CI/CD causes the app to run in pull only mode. At build time, Amplify will automatically generate the
aws-exports.js
file only, without modifying your backend environment. -
Choose Next.
-
Choose Save and deploy.
Edit an existing frontend to point to a different backend
To edit a frontend Amplify app to point to a different backend
-
Sign in to the AWS Management Console and open the Amplify console
. -
Choose the app to edit the backend for.
-
Choose the Hosting environments tab.
-
Locate the branch to edit and choose Edit.
-
On the Select a backend environment to use with this branch page, for App name, select the frontend app that you want to edit the backend environment for. You can choose the current app or any other app in the current region.
-
For Backend environment, select the name of the backend environment to add.
-
By default, full-stack CI/CD is enabled. Uncheck this option to turn off full-stack CI/CD for this backend. Turning off full-stack CI/CD causes the app to run in pull only mode. At build time, Amplify will automatically generate the
aws-exports.js
file only, without modifying the backend environment. -
Choose Save. Amplify applies these changes the next time you build the app.