Stack Locking

Atmos Pro supports locking your Atmos stacks to ensure only one process in running on a particular stack at a time.


How it Works

Atmos pro supports locking your Atmos stacks to ensure only one process in running on a particular stack at a time.

Lock a Stack

Atmos CLI

By far, the easiest way to lock a stack is to use the Atmos CLI. The Atmos CLI supports locking a stack by running the following command:

atmos pro lock <key> --ttl <ttl> --message <message>

API Call

Locking a stack can also be performed by calling the POST /api/locks endpoint.

This endpoint takes a key and ttl as required parameters and optionally supports properties and message as optional parameters. The key is used to identify the stack that you want to lock. The ttl is the time in milliseconds that the lock should be valid for. The properties is an array of key/value pairs that will be stored with the lock. The message is a string that will be stored with the lock and displayed to anyone trying to lock an already locked stack. If the lock already exists, the API will return a 409 status code.

Request

POST /api/locks

{
  "key": "my-org/my-repo/my-stack/my-component",
  "ttl": 172800,
  "properties": [
    {
      "key": "environment",
      "value": "production"
    }
  ],
  "message": "This stack is locked for production deployments until Monday"
}

Response (201)

{
  "request": "627366c9-2223-4788-a661-0d32c76a4cf7",
  "success": true,
  "data": {
    "id": "lock_3Ac4tgT3JZZS7vZvPi3RvwL4832B",
    "workspaceId": "ws_0000000000000000000000000000",
    "key": "matt",
    "lockMessage": "This stack is locked for production deployments until Monday",
    "expiresAt": "2024-08-19T15:53:34.583Z",
    "createdAt": "2024-08-19T15:52:34.583Z",
    "updatedAt": "2024-08-19T15:52:34.587Z",
    "deletedAt": null,
    "properties": [
      {
        "id": "lockProp_3Ac4u5Grkaj2bawsgJPTHdQqCyph",
        "lockId": "lock_3Ac4tgT3JZZS7vZvPi3RvwL4832B",
        "key": "environment",
        "value": "production",
        "createdAt": "2024-08-19T15:52:34.625Z",
        "updatedAt": "2024-08-19T15:52:34.627Z",
        "deletedAt": null
      }
    ]
  }
}

Response (409)

{
  "request": "0b4908d0-3ad3-406a-a64e-9a0f047c0605",
  "success": false,
  "data": {},
  "errorMessage": "Lock with key my-org/my-repo/my-stack/my-component already exists",
  "context": {
    "lockMessage": "This stack is locked for production deployments until Monday",
    "expiresAt": "2024-08-19T15:53:34.583Z",
    "environment": "production"
  }
}

Unlock a Stack

Atmos CLI

The Atmos CLI is also the easiest way to unlock a stack that has been previously locked. The Atmos CLI supports locking a stack by running the following command:

atmos pro unlock <key>

API Call

Unlocking a stack can also be performed by calling the DELETE /api/locks endpoint.

This endpoint takes a key as input and the API will return a 200 status code.

Request

DELETE /api/locks

{
  "key": "my-org/my-repo/my-stack/my-component"
}

Response (200)

{
  "request": "3332a62e-d1ab-47f9-bbae-dd2f3a5887d1",
  "success": true,
  "data": {}
}

Cloud Posse Atmos Pro Logo

Copyright ©2024 Cloud Posse, LLC. All rights reserved.