To install the
magento-cloud CLI, see the Magento Cloud CLI reference. After you install the
magento-cloud CLI and set up SSH keys for remote access to your cloud infrastructure, you can use
magento-cloud CLI commands to manage the environments for your Adobe Commerce on cloud infrastructure projects. For information about the environment architecture, see Starter architecture or Pro architecture.
To manage the branches and environments with the Project Web Interface, see Manage branches with the Project Web Interface.
Use magento-cloud CLI commands
magento-cloud CLI commands are similar to Git commands. You can use them to connect to your Adobe Commerce on cloud infrastructure project and manage your Adobe Commerce on cloud infrastructure environments. Although you can run the commands from any directory, we recommend that you run them from a project directory. When run from a project directory, you can omit the
-p <project-ID> parameter. See the Magento Cloud CLI reference.
Get started creating branches
To begin, create a branch.
To get started with environment branches:
On your local workstation, change to your Cloud project directory.
Switch to the file system owner.
Log in to your project.
List your projects.
List environments in the project. Every environment includes an active Git branch that contains your code, database, environment variables, configurations, and services.
It is important to use the
magento-cloud environment:listcommand because it displays environment hierarchies, whereas the
git branchcommand does not.
Fetch origin branches to get the latest code.
git fetch origin
Checkout, or switch to, a specific branch and environment.
magento-cloud environment:checkout <environment-ID>
Git commands only checkout the Git branch. The
magento-cloud checkoutcommand checks out the branch and switches to the active environment.
You can create a new environment branch using the
magento-cloud environment:branch <environment-name> <parent-environment-ID>command syntax. It may take some additional time to create and activate a new environment branch.
Use the environment ID to pull any updated code to your local. This is not necessary if the environment branch is new.
git pull origin <environment-ID>
(Optional) Create a snapshot of the environment as a backup.
magento-cloud snapshot:create -e <environment-ID>
Merge a branch
After completing development, you can merge this branch to the parent:
Complete code in your local branch.
Add, commit, and push changes to the environment.
git add -A && git commit -m "Commit message" && git push origin <branch-name>
Merge with the parent environment:
magento-cloud environment:merge <environment-ID>
Delete an environment
Only delete an environment if you are certain that you no longer need it. You cannot recover an environment after you delete it.
You cannot delete the
master environment of any project.
You must be a project administrator, environment administrator, or Account Owner to perform this task. See Manage user access to Cloud projects.
When you delete an environment, the environment is set to inactive. The code is still available in the Git branch, but no longer contains the services or the database. To delete the environment completely, you must also delete the corresponding remote Git branch.
To delete an environment:
Open a terminal and navigate to your project.
Fetch updates from the remote server.
Delete the environment branch.
magento-cloud environment:delete <environment-ID>
Optionally, you can delete more than one environment at a time by adding multiple environment IDs to the delete command.
magento-cloud environment:delete <environment-1-ID> <environment-2-ID>
Respond to the prompts to delete the local environment and the corresponding remote environment.
The environment <environment-ID> is currently active: deleting it will delete all associated data. Are you sure you want to delete the environment <environment-ID>? [Y/n]
Deleting the environment places it in an inactive state.
Delete the remote Git branch too? [Y/n]
Deleting the remote Git branch removes the environment from the project.
Wait for the environment to delete.
1 2 3 4 5 6 7 8
Deleting environment <environment-ID> Waiting for the activity... Deleting environment <project-id>-<environment-ID>-xxxxxx [============================] 1 min (complete) Activity ID succeeded Deleted remote Git branch <environment-ID> Run git fetch --prune to remove deleted branches from your local cache.
To activate an inactive environment, use the
magento-cloud environment:activate command.
Interact with remote environments
After you set up SSH keys, you can connect from your local workspace to a remote environment and use
magento-cloud CLI commands to interact with your Adobe Commerce on cloud infrastructure project services and modify settings.
The following steps provide an example of accessing a database:
SSH to the integration environment.
Find the database login information:
php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"]))->database);'
Sample output follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Array (  => stdClass Object ( [username] => user [password] => [ip] => 192.0.2.60 [host] => database.internal [query] => stdClass Object ( [is_master] => 1 ) [path] => main [scheme] => mysql [port] => 3306 ) )
Use the following command to connect to the database:
mysql --host=<host> --user='<database username>' --password='<user password>' --port='<port>' --database='<path>'
You can also use SSH tunneling to connect to a service from your local development environment as if the service were local. Before tunneling, you need to have SSH configured.
Use a terminal application to log in and issue commands.
1 magento-cloud login
First, you may want to check if any tunnels are already open using the following command:
1 magento-cloud tunnel:list
To build a tunnel, you must know the name of the app to which to tunnel. Use the following commands to list those applications:
1 cd <project directory>
1 magento-cloud project:list
1 magento-cloud apps
For information on the command, you can enter
magento-cloud apps --help.
Set up the SSH tunnel
Use the following command:
1 magento-cloud tunnel:open -e <environment ID> --app <app name>
For example, to open a tunnel to the
sprint5 branch in a project with an app named
1 magento-cloud tunnel:open -e sprint5 --app mymagento
Messages similar to the following display:
1 2 3 4 5 6 7 8 SSH tunnel opened on port 30003 to relationship: solr SSH tunnel opened on port 30004 to relationship: redis SSH tunnel opened on port 30005 to relationship: database Logs are written to: /home/magento_user/.magento/tunnels.log List tunnels with: magento-cloud tunnels View tunnel details with: magento-cloud tunnel:info Close tunnels with: magento-cloud tunnel:close
Get tunnel information
To display information about your tunnel, enter:
1 magento-cloud tunnel:info -e <environment ID>
Connect to services
Now you can connect to services as if they were running locally.
For example, to connect to the database, use the following command:
1 mysql --host=127.0.0.1 --user='<database username>' --pass='<user password>' --database='<name>' --port='<port>'
Details about the service display if you use the
magento-cloud tunnel:info command.
Regional IP addresses
The following tables list the incoming and outgoing IP addresses used by Adobe Commerce on cloud infrastructure Integration environments. These IP addresses are stable, but might change. We always notify customers before making any IP address changes.
You can use the
ping command to retrieve the incoming IP address:
1 ping integration-abcd123-abcd78910.us-3.magentosite.cloud
1 2 3 4 PING integration-abcd123-abcd78910.us-3.magentosite.cloud (22.214.171.124): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2
If you have a corporate firewall that blocks outgoing SSH connections, you can add the inbound IP addresses to your allowlist.