Via the CLI, how do I make sure I'm in the right workspace and deployment?

If you’ve installed our CLI and started a project (perhaps called hello-astro if you’re just getting started and following this guide), you need to make sure that the following is true before you’re ready for your first astro deploy.

1. You’ve authenticated correctly.

To pull your workspaces and deployments from our app, you need to make sure you’re logged in first.

To do so, run the following:

$ astro auth login gcp0001.us-east4.astronomer.io

If you’ve already made an account on our app (app.astronomer.cloud), then press enter when you see something like:

 "Paolas-MBP-2:hello-astro paola$ astro auth login gcp0001.us-east4.astronomer.io
 CLUSTER                                        WORKSPACE                           
  gcp0001.us-east4.astronomer.io    4a6cb370-c361-440d-b02b-c90b07ef15f6

 Switched cluster
Username (leave blank for oAuth): 

Once you press enter, you’ll be prompted to go back into our UI to this link: https://app.gcp0001.us-east4.astronomer.io/token.

Grab that token, paste it back into your command line, and you’re good to go. Your success message should read:

Successfully authenticated to registry.gcp0001.us-east4.astronomer.io

2. You’re in the right workspace

Now that you’re logged in, you need to make sure you’re in the right workspace. To start, run: astro workspace list

You should see a list of 1 or more workspaces in the output. To “pick” one to create and jump into deployments to, run our switch command followed by the corresponding ID you’ll have to copy and paste:

astro workspace switch (no syntax needed around the ID)

3. You have a deployment to work from

If you have a deployment up, skip to step 4. If not, you can create a deployment from our UI or via the CLI.

(1) Creating a deployment via app.gcp0001.us-east4.astronomer.io

  • Start from https://app.gcp0001.us-east4.astronomer.io/login
  • Click into the workspace you want to create a deployment from
  • Hit “New Deployment” on the top right of the page
  • Give your deployment a name and description
  • Wait a few minutes (might have to refresh) for your Webserver, scheduler, and celery flower (worker monitoring) to spin up

Once you see an active URL under “Apache Airflow” in the middle of the page, you are set and ready to deploy your DAGs.

(2) Creating a deployment via the Astronomer CLI

To create a deployment directly from our CLI, run:

astro deployment create <deployment name>

Note: This is a bit misleading. deployment name here is your workspace ID (that you pulled above), NOT the name of your new deployment (which doesn’t exist yet).

Once your webserver, scheduler, and celery flower are up, you should see the following success message and URLs:

Successfully created deployment. Deployment can be accessed at the following URLs 

 Airflow Dashboard: https://popular-orbit-2745-airflow.astronomer.cloud
 Flower Dashboard: https://popular-orbit-2745-flower.astronomer.cloud

From here, you’re set.

4. You have the right deployment

To “pick” a deployment (a bit different than picking a workspace), just do:

astro deploy

Your list of deployments will come up, like below:

 #    RELEASE NAME                  WORKSPACE                     DEPLOYMENT UUID                                   
 1    false-wavelength-5456         Paola Peraza Calderon's Workspace90b3dc76-2022-4e0f-9bac-74a03d0dffa7              

> 

Hit the single number that corresponds to the deployment you want to push to, and you’re good!

Is it possible to get current-workspace as a cli command? This would allow adding the workspace name to bash prompt without a fragile grep command:

astro workspace list | cat -e | grep -E '^\^.* [a-zA-Z0-9]+' | cut -d' ' -f2

@medwig Running astro workspace list will list all Workspaces you have access to and the one you’re currently in will be highlighted in green via the CLI as shown in the screenshot below:

We haven’t considered building a command to list your current Workspace as the above does the trick for most folks, but does that answer your question? What part of the deploy process are you looking to make easier?

This is in the context of adding the current workspace to the bash prompt, so it’s always clear what workspace the shell is referencing. Specifically zsh/powerlevel9k, but it applies to any bash promp customization: https://github.com/Powerlevel9k/powerlevel9k/wiki/stylizing-your-prompt

For example, in k8s I can leverage this command:
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status dir vcs kubecontext)

And the prompt will show the the workspace. This solution works, it’s just hacky:Screen Shot 2020-05-04 at 11.13.39 AM

~/.zshrc

I recognize this isn’t that big a deal, was just curious if I was missing something obvious.