MultiPaaS

Environments

An environment is a separate copy of how an application is used. Each environment holds its own app-tenants, its own app-wide records and its own imports. Working in one environment doesn't read or change another's. Three things span environments. Deleting the application deletes the app-tenants of all its environments at once, and its data in every environment is destroyed starting 30 days later. A role granted to someone in every environment holds in each of them. And app-tenants you hold a role at directly are listed whatever environment they are in, in the console and, without --env, in tenants list and init. Your app's sign-in screen lists one environment's app-tenants, so it offers such an app-tenant only on a sign-in to its environment, the default one when the sign-in names none.

What an environment separates and what it shares

An environment separates:

All environments of an application share its model, its API versions and the roles declared for the whole application. Changing the model changes it for every environment.

Think of a bakery that tests a new menu. The recipes it writes down are the model, and every kitchen uses them. Each kitchen keeps its own orders. A practice kitchen can fill its orders with test data and never mix them into the real kitchen's.

The default environment

Every application has one default environment, named Default. It is protected, and it is the environment an application already used before environments existed.

A sign-in chooses an environment with environment on the authorize request, and leaving it out means the default environment. Add end-user sign-in covers it. A command that acts in an environment chooses it as "Working inside an environment" below describes. Your app-tenants and app-wide records from before environments existed are in the default environment.

Creating, listing and renaming environments

Creating, renaming, protecting, unprotecting or deleting an environment needs the environment.manage permission, apart from the exceptions under who can manage environments. A person who creates one becomes its App manager in that environment; a deployer does not.

In the web app, the Environments page lists an application's environments, creates and renames them, turns their deletion protection on and off, and deletes them. The environment menu in the top bar switches the environment the application pages show.

With the CLI:

multipaas envs list --app APP_ID
multipaas envs create --app APP_ID --name test
multipaas envs rename --app APP_ID --env ENV_ID --name staging
multipaas envs protect --app APP_ID --env ENV_ID
multipaas envs unprotect --app APP_ID --env ENV_ID
multipaas envs delete --app APP_ID --env ENV_ID

envs list prints each environment's name, id, whether it is the default, whether it is protected and its site URL; the site URL needs CLI 1.16.0 or later. Environment names are unique within an application. envs protect, envs unprotect and envs remove need CLI 1.4.0 or later; envs delete needs 1.7.0 or later. envs remove is the deprecated name for envs delete and still works.

Who can manage environments

The environment.manage permission counts only from a role granted in every environment. App manager is the default role that carries it. A role granted in one environment, even App manager in the environment you created, doesn't let you create, rename, protect, unprotect or delete an environment. The person who creates an application is App manager in every environment, so they can manage them all. model.edit, which lets you change the model, counts the same way: only from a role granted in every environment.

A role defined for the whole application is shared by every environment. Creating, editing or deleting one needs access.manage.application from a role granted in every environment, and you must hold everything the role carries from such a role. A client admin needs neither, only access.manage.application in the environment they act in: the one picked in the web app, or the application's default environment for roles create and roles update, which send no environment. To grant a role in every environment you must be a client admin or hold access.manage.application from a role granted in every environment, and the person receiving it must be a person, not an app identity. Unless you are a client admin granting it to someone else, you must also hold every permission the role carries from a role granted in every environment. Granting a role in one environment needs only what that environment gives you.

Registering, changing or deleting the shared sign-in client needs application.manage_oauth from a role granted in every environment. Updating or deleting the application needs access.manage.application from a role granted in every environment, and so does creating or deleting a deployer, which a client admin may also do if they hold access.manage.application in the application's default environment.

A CI deployer needs no environment.manage to create an environment, and can rename, protect, unprotect or delete the environments it created. A deployer never holds or grants a role that carries model.edit or environment.manage. A client admin can delete an environment without environment.manage, sees every environment, and manages other people's role assignments.

URL names and site URLs

Your client, each application and each environment has a URL name as well as its name. URL names build the address an environment's site is served at, so they use only lowercase letters, digits and single hyphens, start with a letter and don't end with a hyphen. MultiPaaS generates one from the name when something is created, and you can rename it.

An environment's site URL is https://APP--CLIENT.multipaas.app for the default environment and https://ENV--APP--CLIENT.multipaas.app for any other, built from the three URL names. Publish a static site puts a site there.

Renaming an application's or an environment's URL name needs environment.manage, counted as who can manage environments describes. Renaming the client's needs client.access.manage in the client, which a client admin has. A CI deployer can't rename URL names.

In the web app, the Application settings, Environment settings and Client settings pages show the URL name, its earlier names and, for an environment, the site URL, and rename it. With the CLI:

multipaas url-name show --app APP_ID
multipaas url-name show --app APP_ID --env ENV_ID
multipaas url-name show --app APP_ID --client
multipaas url-name rename --app APP_ID --env ENV_ID --name staging
multipaas url-name rename --app APP_ID --client --name acme-labs

--client acts on the client of the app named by --app. Renaming to a name another application or environment held before is refused with URL_NAME_TAKEOVER_UNCONFIRMED, which names the previous holder; run the command again with --confirm-takeover to take it. --confirm-takeover can't be combined with --client. url-name needs CLI 1.16.0 or later.

Deletion protection

An environment can be protected against deletion. While it is protected, deleting it is refused. Turn protection on with envs protect or on the Environments page, and off with envs unprotect or the same page. A new environment starts unprotected.

The default environment starts protected. You can unprotect it, but it can still never be deleted.

A refused deletion says why in a reason:

reason Meaning
environment_default The environment is the application's default one. It can't be deleted, protected or not.
environment_protected The environment has deletion protection on. Unprotect it first, then delete it.

With --json, the CLI prints the refusal as {"error": {"code": "FORBIDDEN", "reason": "environment_protected", ...}}.

Deleting an environment

Deleting an environment can't be undone.

envs delete asks for no confirmation, so that scripts and CI can run it. Protection is the guard. Deleting the same environment a second time is refused with NOT_FOUND.

multipaas envs delete --app APP_ID --env ENV_ID

With --json it prints {"deleted": true, "id": "ENV_ID", "destroysAt": "…"}; destroysAt is when the 7 days end; the erase usually starts within about an hour after it, and later if it is held up. If the server doesn't say when the 7 days end, destroysAt is null and the plain output says the server did not say when its data is erased.

envs remove is the old name for envs delete. It still works, prints a deprecation notice, and its output is unchanged.

If your project's multipaas.json has an environmentId for a deleted environment, every CLI command that uses that environment, whether from --env or from the file, exits with NOT_FOUND, because the environment is no longer in envs list. A command that acts in the file's testAppTenantId, such as records, never looks at environmentId. With access at the client or the application it is refused with UNAUTHORIZED. If your access is at that app-tenant, it no longer appears for you and the command exits with NOT_FOUND. If envs list also exits with NOT_FOUND, your access to this application doesn't include a live environment, and someone who manages the application needs to give you access to an app-tenant in one. If envs list works, use a live app-tenant of yours. A sign-in that passes the environment is refused, and your app's API calls with a token from it fail with HTTP 401. Run multipaas envs list --app APP_ID to find a live environment, then run multipaas init --app APP_ID --env ENV_ID --tenant APP_TENANT_ID --api-version API_VERSION, with an app-tenant of that environment and the apiVersion already in the file, to point the project at it.

Working inside an environment

Pass --env ENV_ID to tenants list, tenants create, init, records, import and app-identity to run the command in that environment. records and app-identity role take it only with --app-wide; at an app-tenant, they act in that app-tenant's environment. Without it, they use the default environment, except that, from CLI 1.2.0, when multipaas.json has an environmentId for the same application, every one of them but tenants list and init uses that (records and app-identity role only with --app-wide). From the same CLI, init saves the environment of the app-tenant it pins as that environmentId, and --env works on app-identity. With --env, tenants list and init see only that environment's app-tenants. Without it, they see the default environment's app-tenants, plus any app-tenant you hold a role at directly, whatever environment it is in. The environment must belong to the application named by --app.

multipaas tenants create --app APP_ID --env ENV_ID --name "Test team"
multipaas records list --app APP_ID --env ENV_ID --app-wide --entity ENTITY_ID

To use an app-tenant in a non-default environment as your project's test app-tenant, run multipaas init --app APP_ID --env ENV_ID --tenant APP_TENANT_ID. If you only use the default environment, init needs no --env.

records takes --env only together with --app-wide. records refuses --env together with --tenant, because an app-tenant already belongs to one environment.

In an environment where you can't view an entity's app-wide records, records list --app-wide for that entity is refused with UNAUTHORIZED rather than returning an empty list.

App-wide data belongs to one environment

An app-wide record belongs to the environment it was written in. A person working in one environment reads and writes that environment's app-wide records only. An app-wide token, which a job uses, works in its app identity's environment. An app-tenant reads the app-wide records of its own environment beside its own records, and never another environment's.