Deploy a revision¶
What happens
The creator takes a revision, a frozen snapshot of the API, and deploys it to one or more gateway environments. APIM:
- copies the API's resources, scopes and policies under a new
REVISION_UUID, and builds the ready-to-run gateway artifact straight away, - records which environment the revision should run on,
- records each gateway's confirmation once it has deployed the artifact.
Who: API creator (Publisher), then each Gateway · Tables written: AM_REVISION, AM_API_REVISION_METADATA, revision copies in AM_API_URL_MAPPING / AM_API_RESOURCE_SCOPE_MAPPING / …, AM_GW_PUBLISHED_API_DETAILS, AM_GW_API_ARTIFACTS, AM_DEPLOYMENT_REVISION_MAPPING, AM_GW_API_DEPLOYMENTS, AM_GW_REVISION_DEPLOYMENT · Tables read: AM_GATEWAY_ENVIRONMENT, AM_GW_VHOST, AM_GW_INSTANCES
The flow at a glance¶
This diagram shows a revision going from "snapshot" to "running on a gateway".
sequenceDiagram
actor Creator as API creator
participant Pub as Publisher
participant DB as APIM DB
participant GW as Gateway
Creator->>Pub: Create revision 1
Pub->>DB: insert AM_REVISION + copy child rows
Pub->>DB: save AM_GW_PUBLISHED_API_DETAILS + AM_GW_API_ARTIFACTS
Creator->>Pub: Deploy to Default environment
Pub->>DB: insert AM_DEPLOYMENT_REVISION_MAPPING + AM_GW_API_DEPLOYMENTS
Pub-->>GW: event "revision deployed"
GW->>Pub: fetch artifact, then report success
Pub->>DB: insert AM_GW_REVISION_DEPLOYMENT (SUCCESS)
- The gateway pulls the artifact through an internal REST API on the control plane rather than reading the database directly.
AM_DEPLOYMENT_REVISION_MAPPINGmeans "deployment was requested".AM_GW_REVISION_DEPLOYMENTmeans "this gateway confirmed it".
Step by step¶
-
Create the revision. A new row goes into
AM_REVISION.IDis the revision number (1, 2, 3 …) per API, so the primary key is(ID, API_UUID).REVISION_UUIDis the global identifier that every copied row points to.AM_API.REVISIONS_CREATEDgoes up by one (for example, 0 → 1). An API can keep only a limited number of revisions (5 by default).
ID API_UUID REVISION_UUID DESCRIPTION CREATED_BY 1 b41b…4b45…first revision (null) -
Snapshot the child rows. The working copy's rows are copied with the new
REVISION_UUIDfilled in. For a simple API that's its URL mappings and scope mappings. Operation-policy mappings, client certificates and GraphQL complexity are copied the same way when they exist.AM_API_REVISION_METADATAstores the API-level tier at snapshot time (API_UUID,REVISION_UUID,API_TIER = 'Unlimited').- The registry artifact is also copied, into a revision path.
URL_MAPPING_ID API_ID HTTP_METHOD URL_PATTERN REVISION_UUID 1 1 GET /menu (null = working copy) 5 1 GET /menu 4b45…Logical link (no foreign key)
Most copied tables point at the revision through a plain
REVISION_UUIDcolumn with no FK. The value'Current API'(inAM_API_ENDPOINTS,AM_API_PRIMARY_EP_MAPPINGandAM_BACKEND) or NULL (inAM_API_URL_MAPPING) means "the working copy, not a revision". -
Build the gateway artifact (still at revision creation).
AM_GW_PUBLISHED_API_DETAILSgets one row per API. ItsAPI_IDholds the API UUID string, plusTENANT_DOMAIN,API_NAME,API_VERSIONandAPI_TYPE. In the testAPI_PROVIDERwasNULLandAPI_TYPEwashttp.AM_GW_API_ARTIFACTSstores the built artifact, a zip file in theARTIFACTblob, keyed by(REVISION_ID, API_ID), whereREVISION_IDis the revision UUID.- Updating the API also queues a new governance check (
GOV_REQUEST), because the default policy governsAPI_UPDATEtoo. See Governance check.
AM_GW_API_ARTIFACTS.API_ID REVISION_ID ARTIFACT b41b…4b45…(zip blob) -
Choose where to deploy. Gateway environments created in the Admin Portal live in
AM_GATEWAY_ENVIRONMENT(UUID,NAME,GATEWAY_TYPE,ORGANIZATION). Their hostnames live inAM_GW_VHOST, whereGATEWAY_ENV_IDis an FK toAM_GATEWAY_ENVIRONMENT.ID.Environments from the config file
The environments defined in
deployment.toml, such as the built-in Default environment, are not stored inAM_GATEWAY_ENVIRONMENT. For those environments, both tables stay empty. -
Request the deployment. One row per environment goes into
AM_DEPLOYMENT_REVISION_MAPPING.NAMEis the environment name andVHOSTis the chosen host. For the config-fileDefaultenvironment it's stored asNULL.REVISION_STATUSisAPPROVED, orCREATEDwhile a revision-deployment workflow is pending.DISPLAY_ON_DEVPORTALcontrols whether the Dev Portal shows this gateway URL.
AM_GW_API_DEPLOYMENTSalso gets a row saying which environment label each revision targets (API_ID= API UUID,REVISION_ID,LABEL = 'Default',VHOST).NAME VHOST REVISION_UUID REVISION_STATUS DISPLAY_ON_DEVPORTAL Default (null) 4b45…APPROVED true Logical link (no foreign key)
NAMEmatches an environment by name, eitherAM_GATEWAY_ENVIRONMENT.NAMEor adeployment.tomlenvironment. There's no FK. -
Gateway confirms. Each gateway registers itself in
AM_GW_INSTANCESand updates a heartbeat there. After it deploys the artifact, APIM records its per-API state inAM_GW_REVISION_DEPLOYMENT.- Only one revision of an API can be deployed to a given environment at a time. Deploying revision 2 replaces revision 1 there.
GATEWAY_ID API_ID ORGANIZATION STATUS ACTION REVISION_UUID 1 b41b…carbon.super SUCCESS DEPLOY 4b45…AM_DEPLOYED_REVISIONstays emptyThe schema also has
AM_DEPLOYED_REVISION(NAME,VHOST,REVISION_UUID,DEPLOYED_TIME). In 4.7.0, deployments to the built-in gateway don't write to it. To see which gateways have acknowledged a deployment, useAM_GW_REVISION_DEPLOYMENT.
Federated and third-party gateways
For external gateways such as AWS, Azure or Kong:
- AM_API_EXTERNAL_API_MAPPING links the APIM API to its ID on the external gateway.
- AM_GATEWAY_TOKEN and the AM_GW_PLATFORM_* tables support gateways that register themselves.
What gets cleaned up¶
- Undeploying removes the environment's row from
AM_DEPLOYMENT_REVISION_MAPPING. The gateways' state inAM_GW_REVISION_DEPLOYMENTis expected to change too, though undeploying wasn't tested. - Deleting a revision cascades to
AM_DEPLOYMENT_REVISION_MAPPING,AM_DEPLOYED_REVISIONandAM_API_REVISION_METADATA. The copied URL mappings and so on are removed by code. - Deleting the API cascades to
AM_REVISION, and from there to everything above. APIM refuses to delete an API that still has subscriptions, though (see Revoke & delete). - Deleting an environment cascades to its VHosts, permissions and gateway tokens.
Try it¶
This query shows where each revision of an API is requested, and what each gateway reported.
SELECT a.API_NAME, a.API_VERSION, r.ID AS REVISION_NO,
m.NAME AS ENVIRONMENT, m.REVISION_STATUS,
g.STATUS AS GATEWAY_STATUS, g.ACTION
FROM AM_API a
JOIN AM_REVISION r ON r.API_UUID = a.API_UUID
JOIN AM_DEPLOYMENT_REVISION_MAPPING m ON m.REVISION_UUID = r.REVISION_UUID
LEFT JOIN AM_GW_REVISION_DEPLOYMENT g
ON g.REVISION_UUID = r.REVISION_UUID AND g.API_ID = a.API_UUID
WHERE a.API_NAME = 'PizzaShackAPI';
Different in 3.x
3.x has no revisions. Publishing an API pushes it to the gateway environments in deployment.toml, and every change to a published API goes live immediately. The optional database sync writes AM_GW_API_ARTIFACTS keyed by a gateway label, with a Publish or Remove instruction. It's off by default, so those tables are usually empty. See 3.x: Publish to the gateway.
Related domains: Revisions & deployment · API definition