Page updated Jan 16, 2024

Share single environment

You have two independent environments (main & dev) in the cloud and have corresponding Git branches with your Amplify backend infrastructure code on Git. Suppose all team members want to work on the same Amplify project and push backend related changes to the same dev environment to test their changes. Each team member would run the following:

1cd <project-dir>
2amplify init

Ensure the root of your project has the amplify folder set up in order to be able to re-use existing environments.

If the team-provider-info.json file is missing:

  1. Backup and remove the amplify folder
  2. Pull the environment from the root of your project folder using the amplify pull --appId <app-id> --envName <env-name> command displayed in the Amplify Console for your application
1Do you want to use an existing environment? Yes
2Choose the environment you would like to use:
3❯ dev
4main
5# The rest of init steps
6# amplify add/update
7amplify push

Since the team is sharing the same dev backend, periodically team members would need to pull in changes which their team members pushed for the dev environment to be in sync. Let's pull in the changes from the dev branch & environment.

1amplify pull

Sharing projects within the team

Team members will only be able to push to a stack only if they have the correct credentials (access key/secret keys) to do so.

Inside the amplify directory file-structure, you will observe a team-provider-info.json file which contains a structure similar to the following:

1{
2 "dev": {
3 "awscloudformation": {
4 "AuthRoleName": "multenvtest-20181115101929-authRole",
5 "UnauthRoleArn": "arn:aws:iam::132393967379:role/multenvtest-20181115101929-unauthRole",
6 "AuthRoleArn": "arn:aws:iam::132393967379:role/multenvtest-20181115101929-authRole",
7 "Region": "us-east-1",
8 "DeploymentBucketName": "multenvtest-20181115101929-deployment",
9 "UnauthRoleName": "multenvtest-20181115101929-unauthRole",
10 "StackName": "multenvtest-20181115101929",
11 "StackId": "arn:aws:cloudformation:us-east-1:132393967379:stack/multenvtest-20181115101929/fc7b1010-e902-11e8-a9bd-50fae97e0835"
12 }
13 },
14 "main": {
15 "awscloudformation": {
16 "AuthRoleName": "multenvtest-20181115102119-authRole",
17 "UnauthRoleArn": "arn:aws:iam::345090917734:role/multenvtest-20181115102119-unauthRole",
18 "AuthRoleArn": "arn:aws:iam::345090917734:role/multenvtest-20181115102119-authRole",
19 "Region": "us-east-1",
20 "DeploymentBucketName": "multenvtest-20181115102119-deployment",
21 "UnauthRoleName": "multenvtest-20181115102119-unauthRole",
22 "StackName": "multenvtest-20181115102119",
23 "StackId": "arn:aws:cloudformation:us-east-1:345090917734:stack/multenvtest-20181115102119/3e907b70-e903-11e8-a18b-503acac41e61"
24 }
25 }
26}

This file is to be shared between team members, so that they have the ability to push/provision resources to the same CloudFormation stack and that way teams can work in a push/pull way and can always be in sync with the latest state of the project in the cloud.

If you want to share a project publicly and open source your serverless infrastructure, you should remove or put the amplify/team-provider-info.json file in the .gitignore file.