Skip to content

Switch the instance over to green.

POST
/v1/projects/{projectId}/db/instances/{dbInstanceId}/blue-green-deployments/{blueGreenDeploymentId}/actions/switchover
Code sample: Shell / cURL
curl --request POST \
--url https://stratum.example.com/v1/projects/example/db/instances/example/blue-green-deployments/example/actions/switchover \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "timeoutSeconds": 300 }'

Seconds of downtime: the reconciler fences the instance (no client network in pg_hba, read-only default, every client session terminated) and records the WAL position; waits for green to apply everything up to it (bounded by timeoutSeconds — past it the instance is unfenced and the deployment reports switchover-failed, nothing moved); green copies the sequence values (logical replication does not carry them) and drops its subscriptions; the instance’s endpoint address is re-pointed at green’s engine (one OVN transaction; the DNS name does not change) and the two rows swap backends — the instance’s id, ARN, endpoint, master credential, windows and tags stay; its engine, class, storage, parameters, snapshots and backups are green’s from here on. The former blue is retained read-only under greenInstanceId (<name>-old, oldEndpoint) for blueRetentionDays. Audited as db.blue_green.switched_over with the downtime.

Cedar-gated on db:SwitchoverBlueGreenDeployment on the instance. 409 unless the deployment is available (or switchover-failed), the lag is under the threshold, and the instance is available and idle (no backup open, no failover, no pending modifications).

projectId
required
string
/^p-[a-z0-9-]+$/
dbInstanceId
required
string
/^db-[a-z0-9]+$/
blueGreenDeploymentId
required
string
/^bg-[a-z0-9]+$/
Media typeapplication/json
object
timeoutSeconds

How long the fence and the catch-up may take. Past it the instance is unfenced and the deployment reports switchover-failed with nothing moved; once green has every commit the switchover completes regardless.

integer
default: 300 >= 30 <= 3600

Accepted — the deployment is switchover-in-progress.

Media typeapplication/json

A blue/green deployment of a database instance: a GREEN copy of the instance is built beside it — restored from a base snapshot at the target version and class, its own endpoint, fed by logical replication from the instance (blue) — inspected, and switched to in seconds; blue is retained read-only for a rollback.

Statuses: pending-reboot (wal_level = logical waits for the instance’s engine to restart — its maintenance window, or applyImmediately) → provisioning (preconditions checked and reported; the publication and replication slots created on the instance; the base snapshot taken; green created and replaying) → replicating (green streams, replicationLagBytes above the threshold) → available (under it: switchover when ready) → switchover-in-progress → switchover-completed (the instance IS green now: its id, endpoint address and credentials unchanged, its engine, class and storage the target’s; the former blue is retained under greenInstanceId as <name>-old, read-only, at oldEndpoint, until blueRetainedUntil or DELETE) | switchover-failed (reverted, nothing moved; switchover again or DELETE) | abandoned (DELETE before the switchover: green gone, the instance untouched) | rolled-back (actions/rollback after the switchover: the endpoint serves the former blue again; the writes green accepted since the switchover are in green’s final snapshot and nowhere else).

While a deployment lives, the instance’s class, version, storage, parameter group, Multi-AZ, deletion and credential rotation are refused (409); dynamic fields (tags, windows, security groups, retention) still apply. Green and the retained old blue are real instances in the project — connectable, backed up — changed only through the deployment.

object
id
required
string
/^bg-[a-z0-9]+$/
arn
required
string
projectId
required
string
dbInstanceId
required

The customer’s instance — the id that keeps its identity across the switchover.

string
greenInstanceId

The second row — green before the switchover, the retained former blue after it. Absent until green is created, and once the former blue is torn down.

string
target
required

What green differs in from blue. An omitted field keeps the instance’s value; at least one must change. engineVersion is a published version of the same or a newer major (a bare major resolves to its newest published minor; never a downgrade, never the preview major); a major upgrade runs pg_upgrade on green before it starts. parameterGroupName must be of the target’s family — omitted on a major upgrade, the family’s default group is used.

object
engineVersion
string
instanceClass
string
parameterGroupName
string
allocatedStorage

GiB; never smaller than the instance’s.

integer
storageClass
string
status
required
string
Allowed values: pending-reboot provisioning replicating available switchover-in-progress switchover-completed switchover-failed abandoned rolled-back
statusReason
required

What the deployment waits on, what it is doing, or why the last switchover failed.

string
nullable
preconditions
required

Empty when clean. Nothing is built while any remain; they are re-checked every pass.

Array<object>

One thing the instance must satisfy before green is built (re-checked every pass until clean).

object
code
required
string
Allowed values: TABLE_WITHOUT_REPLICA_IDENTITY LARGE_OBJECTS WAL_LEVEL_NOT_LOGICAL
detail
required

The offender: <database>: <schema.table>, or the count of large objects.

string
replicationLagBytes
required

How far green is behind the instance (the largest slot lag); null until green streams.

integer format: int64
nullable
switchoverLagThresholdBytes
required

The deployment is available when the lag is at or under this; the switchover refuses above it.

integer format: int64
greenEndpoint
required

Green’s own endpoint while it is green (read/write — your tests; its writes are your own risk).

object
address

db-<id>.db.<region>.<parentDomain>, resolving to ip inside the VPC; empty until the name is published.

string
ip

The VPC-internal VIP — an address in the subnet group’s subnet that follows the primary across failover and blue/green.

string
port
integer
oldEndpoint
required

The retained former blue’s endpoint after the switchover (read-only), until it is torn down.

object
address

db-<id>.db.<region>.<parentDomain>, resolving to ip inside the VPC; empty until the name is published.

string
ip

The VPC-internal VIP — an address in the subnet group’s subnet that follows the primary across failover and blue/green.

string
port
integer
switchover
required

The switchover’s timing. downtimeSeconds is fence → endpoint move.

object
startedAt
required
string format: date-time
nullable
completedAt
required
string format: date-time
nullable
downtimeSeconds
required
integer
nullable
timeoutSeconds
required

How long the fence and the catch-up may take before the switchover is reverted (switchover-failed, nothing moved).

integer
blueRetentionDays
required
integer
>= 1 <= 30
blueRetainedUntil
required
string format: date-time
nullable
applyImmediately
required

Whether the wal_level restart was applied at once rather than in the maintenance window.

boolean
tags
required
object
key
additional properties
string
createdBy
required
string
createdAt
required
string format: date-time
updatedAt
required
string format: date-time

Example

{
"status": "pending-reboot",
"preconditions": [
{
"code": "TABLE_WITHOUT_REPLICA_IDENTITY"
}
]
}

Bad request.

Media typeapplication/problem+json
object
type
required
string format: uri
title
required
string
status
required
integer
>= 400 <= 599
detail
string
instance
string format: uri-reference
requestId
required
string
code
required
string
issues

The findings of a rejected IAM policy document (custom and resource policies).

Array<object>

One finding of a rejected IAM policy document. A rejection lists every finding, so the author fixes the document in one round trip.

object
code
required

The finding, e.g. INVALID_DOCUMENT, UNKNOWN_ACTION, ACTION_NOT_APPLICABLE.

string
statement
required

Index of the statement at fault; -1 for the document as a whole.

integer
>= -1
detail
required
string
action

The offending action, where one is at fault (ACTION_NOT_APPLICABLE).

string
errors

Field errors, for codes that carry them: each problem at its field (see FieldError). Documented on the responses that set it, e.g. approveNodeJoin’s INVALID_INPUT and JOIN_APPROVAL_REFUSED. Absent otherwise.

Array<object>

One field’s problem, the stage-2 installer API’s shape. field is the field’s path, message what is wrong with it.

object
field
required

The field’s path, e.g. links[0].interface, disks[1].confirm, mgmt.address or role; empty for the whole request.

string
message
required
string
details

Structured facts about the refusal, for codes that carry them. The shape is fixed per code and documented on the response that answers it, e.g. IMAGE_POOL_MISMATCH (see ImagePoolMismatchDetails) and IMAGE_IN_USE. Absent for codes that carry none.

object
key
additional properties
any

Example

{
"issues": [
{
"code": "ACTION_NOT_APPLICABLE",
"action": "compute:CreateVpc"
}
]
}

Authenticated but not authorized.

Media typeapplication/problem+json
object
type
required
string format: uri
title
required
string
status
required
integer
>= 400 <= 599
detail
string
instance
string format: uri-reference
requestId
required
string
code
required
string
issues

The findings of a rejected IAM policy document (custom and resource policies).

Array<object>

One finding of a rejected IAM policy document. A rejection lists every finding, so the author fixes the document in one round trip.

object
code
required

The finding, e.g. INVALID_DOCUMENT, UNKNOWN_ACTION, ACTION_NOT_APPLICABLE.

string
statement
required

Index of the statement at fault; -1 for the document as a whole.

integer
>= -1
detail
required
string
action

The offending action, where one is at fault (ACTION_NOT_APPLICABLE).

string
errors

Field errors, for codes that carry them: each problem at its field (see FieldError). Documented on the responses that set it, e.g. approveNodeJoin’s INVALID_INPUT and JOIN_APPROVAL_REFUSED. Absent otherwise.

Array<object>

One field’s problem, the stage-2 installer API’s shape. field is the field’s path, message what is wrong with it.

object
field
required

The field’s path, e.g. links[0].interface, disks[1].confirm, mgmt.address or role; empty for the whole request.

string
message
required
string
details

Structured facts about the refusal, for codes that carry them. The shape is fixed per code and documented on the response that answers it, e.g. IMAGE_POOL_MISMATCH (see ImagePoolMismatchDetails) and IMAGE_IN_USE. Absent for codes that carry none.

object
key
additional properties
any

Example

{
"issues": [
{
"code": "ACTION_NOT_APPLICABLE",
"action": "compute:CreateVpc"
}
]
}

Resource not found.

Media typeapplication/problem+json
object
type
required
string format: uri
title
required
string
status
required
integer
>= 400 <= 599
detail
string
instance
string format: uri-reference
requestId
required
string
code
required
string
issues

The findings of a rejected IAM policy document (custom and resource policies).

Array<object>

One finding of a rejected IAM policy document. A rejection lists every finding, so the author fixes the document in one round trip.

object
code
required

The finding, e.g. INVALID_DOCUMENT, UNKNOWN_ACTION, ACTION_NOT_APPLICABLE.

string
statement
required

Index of the statement at fault; -1 for the document as a whole.

integer
>= -1
detail
required
string
action

The offending action, where one is at fault (ACTION_NOT_APPLICABLE).

string
errors

Field errors, for codes that carry them: each problem at its field (see FieldError). Documented on the responses that set it, e.g. approveNodeJoin’s INVALID_INPUT and JOIN_APPROVAL_REFUSED. Absent otherwise.

Array<object>

One field’s problem, the stage-2 installer API’s shape. field is the field’s path, message what is wrong with it.

object
field
required

The field’s path, e.g. links[0].interface, disks[1].confirm, mgmt.address or role; empty for the whole request.

string
message
required
string
details

Structured facts about the refusal, for codes that carry them. The shape is fixed per code and documented on the response that answers it, e.g. IMAGE_POOL_MISMATCH (see ImagePoolMismatchDetails) and IMAGE_IN_USE. Absent for codes that carry none.

object
key
additional properties
any

Example

{
"issues": [
{
"code": "ACTION_NOT_APPLICABLE",
"action": "compute:CreateVpc"
}
]
}

Conflicting state.

Media typeapplication/problem+json
object
type
required
string format: uri
title
required
string
status
required
integer
>= 400 <= 599
detail
string
instance
string format: uri-reference
requestId
required
string
code
required
string
issues

The findings of a rejected IAM policy document (custom and resource policies).

Array<object>

One finding of a rejected IAM policy document. A rejection lists every finding, so the author fixes the document in one round trip.

object
code
required

The finding, e.g. INVALID_DOCUMENT, UNKNOWN_ACTION, ACTION_NOT_APPLICABLE.

string
statement
required

Index of the statement at fault; -1 for the document as a whole.

integer
>= -1
detail
required
string
action

The offending action, where one is at fault (ACTION_NOT_APPLICABLE).

string
errors

Field errors, for codes that carry them: each problem at its field (see FieldError). Documented on the responses that set it, e.g. approveNodeJoin’s INVALID_INPUT and JOIN_APPROVAL_REFUSED. Absent otherwise.

Array<object>

One field’s problem, the stage-2 installer API’s shape. field is the field’s path, message what is wrong with it.

object
field
required

The field’s path, e.g. links[0].interface, disks[1].confirm, mgmt.address or role; empty for the whole request.

string
message
required
string
details

Structured facts about the refusal, for codes that carry them. The shape is fixed per code and documented on the response that answers it, e.g. IMAGE_POOL_MISMATCH (see ImagePoolMismatchDetails) and IMAGE_IN_USE. Absent for codes that carry none.

object
key
additional properties
any

Example

{
"issues": [
{
"code": "ACTION_NOT_APPLICABLE",
"action": "compute:CreateVpc"
}
]
}