Skip to content

AMSDAL Cloud

AMSDAL Cloud is a developer tool that enables you to create and update deployments and deployment environments for any AMSDAL application, allowing you to quickly deploy production and uat or other environments for both your databases and api server. With AMSDAL Cloud you simply use the AMSDAL CLI to manage your deployments, secrets, dependencies and security.

One of the most useful features of AMSDAL Cloud is the ability to easily manage multiple deployment environmnets (e.g. PROD, UAT, STAGING), ensuring that your code works as expected.

Installation

First install the AMSDAL CLI

 pip install amsdal[cli]

Help

Open any terminal from the application root directory and enter the amsdal cloud --help command.

Usage: amsdal cloud [OPTIONS] COMMAND [ARGS]...                                                                                                                                                                                   

 Commands to interact with the Cloud Server.                                                                                                                                                                                       

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ dependencies, deps                              Manage dependencies for your Cloud Server app.                                          │
│ dependency                                      Manage dependencies for your Cloud Server app.                            (deprecated)  │
│ deploy                                          Deploy app to the Cloud Server.                                           (deprecated)  │
│ deployments, deploys, ds                        Manage app deployments on the Cloud Server.                                             │
│ environments, envs, env                         Manage environments of your Cloud Server app.                                           │
│ expose-db, expose_db, edb                       Adds your IP to the allowlist of the database and returns the connection configs.       │
│ get-monitoring-info, get_monitoring_info, gmi   Retrieves monitoring information for the specified environment.                         │
│ secret                                          Manage secrets for your Cloud Server app.                                 (deprecated)  │
│ secrets, sec, s                                 Manage secrets for your Cloud Server app.                                               │
│ security                                        Manage security of the Cloud Server app.                                                │
│ sync-db, sync_db, sdb                           Recreate local database from the remote one.                                                ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Manage environments

With any AMSDAL application (see here to create an application) you can easily manage different environments

For help with any command add the --help arguement

 amsdal cloud env --help
 Usage: amsdal cloud env [OPTIONS] COMMAND [ARGS]...                                                                                                                                                                               

 Manage environments of your Cloud Server app.                                                                                                                                                                                     

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --output  -o      [default|json|wide]  [default: default]                                                           │
│ --help                                 Show this message and exit.                                                  │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ checkout, co     Change the current environment.                                                                    │
│ delete, del, d   Delete an environment from the Cloud Server app.                                                   │
│ new, n           Adds a new environment to your Cloud Server app.                                                   │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

View your current environments

~$amsdal cloud env
┏━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Environment   Current  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│    main          *     │
└──────────────┴──────────┘

As you can see, your application has a default main environment which is currently checked out.

Create a UAT environment

~$amsdal cloud env new uat
Environment uat created successfully.

Checkout an environment

And check it out: amsdal cloud env checkout uat

Environment changed to uat
~$amsdal cloud env
┏━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Environment   Current  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│    main                │
│    uat           *     │
└──────────────┴──────────┘

Managing secrets

Now we can add secrets to the envionment: amsdal cloud secrets new my_secret 123

Adding secret my_secret to environment: uat
Secret added successfully.

This also adds the secret name to the .amsdal/.secrets file making it a required secret for other deployment environments also

We can also, delete, sync and view secrets with values for any environment

~$amsdal cloud secrets --help
 Usage: amsdal cloud secrets [OPTIONS] COMMAND [ARGS]...                                                                                                                                                                           

 Manage secrets for your Cloud Server app.                                                                                                                                                                                         

╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --output  -o      [default|json|wide]  [default: default]                                                             │
│ --env             TEXT                 Environment name. Default is the current environment from configratuion.       │
│                                        [default: None]                                                                │
│ --values  -v                           Show secret values                                                             │
│ --sync                                 Sync the dependencies from the Cloud Server to ".secrets".                     │
│ --help                                 Show this message and exit.                                                    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ delete, del, d   Deletes a secret from the Cloud Server app.                                                          │
│ new, n           Adds a new secret to your Cloud Server app.                                                          │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Managing deployments

Now we can deploy the application to the cloud using amsdal cloud deploys new command

Deploying to environment: uat
Do you want to deploy your app? (y/N): y
Deploy is in progress now. After a few minutes, you can check the status of your deploy.
Your API domain: https://uat-k24b59718d90041ad9d2779b8cea1581.cloud.amsdal.com/

After a few minutes we can see the application has deployed successfully.

~$amsdal cloud deploys -o json 
{
    "deployments": [
        {
            "status": "deployed",
            "client_id": "1bc712bb090b4b65b978d5b079a7e40c",
            "deployment_id": "c595119f21954e4a869e5e5120e6e526",
            "created_at": 1722601979044.0,
            "last_update_at": 1722601979508.0,
            "environment_name": "uat",
            "application_uuid": "k24b59718d90041ad9d2779b8cea1581",
            "application_name": "docs",
            "domain_url": "https://uat-k24b59718d90041ad9d2779b8cea1581.cloud.amsdal.com/"
        }
    ]
}

We can also delete a deployment

~$amsdal cloud deploys delete c595119f21954e4a869e5e5120e6e526
You are about to destroy the deployment for docs and environment uat. Are you sure you want to proceed? [y/N]: y
Destroying process is in progress now. After a few minutes, you can check the status of your deployment.

And deploy while copying data from another environment (e.g. deploy to UAT with PROD data) using the --from-env command

Usage: amsdal cloud deploys new [OPTIONS]                                                                                                                                             

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --deploy-type           [lakehouse_only|include_state_db]    [default: include_state_db]                                                                                            │
│ --lakehouse-type        [spark|postgres|postgres-immutable]  [default: postgres]                                                                                                    │
│ --env                   TEXT                                 Environment name. Default is the current environment from configratuion.                                               │
│                                                              [default: None]                                                                                                        │
│ --from-env              TEXT                                 Environment name to copy from.                                                                                         │
│                                                              [default: None]                                                                                                        │
│ --no-input                                                   Do not prompt for input.                                                                                               │
│ --skip-checks                                                Skip checking secrets and dependencies before deploying.                                                               │
│ --help                                                       Show this message and exit.                                                                                            │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯