Share resources across branches
In some instances you may not want to deploy new resources for every branch. For example, you might want all your feature
branches to point to the backend resources deployed by the dev
branch so you can reuse seed data, users, and groups.
You can update your app build settings to share resources across branches. In the Amplify console, navigate to your build settings from the App overview.
Update the build settings for the backend
phase to run npx amplify generate config --branch dev app-id $AWS_APP_ID
to generate the amplifyconfiguration.json
file for all branches other than main
or dev
. After this update, any new deployed branches will not deploy backend resources as part of the build and instead will use the deployed backend resources from the dev
branch.
1version: 12backend:3 phases:4 build:5 commands:6 - nvm use 187 - npm ci8 - |9 if [ "${AWS_BRANCH}" = "main" ] || [ "${AWS_BRANCH}" = "dev" ]; then 10 npx amplify pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID 11 else12 npx amplify generate config --branch dev --app-id $AWS_APP_ID 13 fi14frontend:15 phases:16 preBuild:17 commands:18 - npm ci19 build:20 commands:21 - npm run build22 artifacts:23 baseDirectory: .next24 files:25 - '**/*'26 cache:27 paths:28 - node_modules/**/*