Auto-generate CloudFormation with no-code and no commitment 🚀
Try Now

Announcing Altostra CLI v5.14

We added and improved CLI commands to make your development experience with Altostra even better.
Yev Krupetsky

July 7 2021 · 4 min read

SHARE ON

Announcing Altostra CLI v5.14

Altostra is a developer-first platform, and as such, it's important to us to provide developers with a CLI to carry out whatever task they need to, right from their terminal.

It's been a while since our last post on the Altostra CLI. We have since improved the overall developer experience, made some changes, and added a few commands.

Setting up

Before installing the Altostra CLI, make sure you have Node.js 10 or above installed.

The Altostra CLI is available as an NPM package.

$ npm install -g @altostra/cli

What's new

Minor renames

We made some terminology changes to make things clearer.

Instances are now called Stacks, and Images are now called Versions.

The previous names remain as aliases, so you can still use them in commands.

A quicker way to deploy

We realized that the alto push and alto deploy commands are commonly used together, and that version (image) names don’t always matter.

The alto deploy command now makes it quicker for you to deploy stacks by allowing you to push new versions in one command using the new --push option.

# deploy with an auto-generated version name
$ alto deploy my-stack --env dev --push

# deploy with a specific version name
$ alto deploy my-stack --env prod --push v1.1

You can choose to provide the version name after the command option or omit it to let Altostra auto-generate one for you.

Deploying non-Altostra projects

We continue our effort to make it easier to manage your existing projects with Altostra. You can manage deployments of your Serverless Framework, SAM and CloudFormation projects using Altostra. See our previous post on deploying Serverless Framework projects.

After you import your project to Altostra, use one of the following commands to deploy it:

# deploy a Serverless Framework project
$ alto deploy-sls 

# deploy an AWS SAM project
$ alto deploy-sam 

# deploy an AWS CloudFormation project
$ alto deploy-cfn 

Switching between accounts

We improved the CLI for multi-account users. You can now switch between your personal and team accounts easily.

The command comes with a few aliases to make it easier to remember and use.

# all these commands switch the working account
$ alto account
$ alto accounts
$ alto team
$ alto teams

For example:

$ alto team <account-id>
✔ Validating request
✔ Checking user credentials
✔ Working account: Altostra, Inc
✔ Listing teams
? Select an account: (Use arrow keys)
❯ My Personal
  Altostra, Inc
  Altostra Demos
  Altostra Dev

Omit the <account-id> argument in interactive mode to select the account from a list. In non-interactive mode, you must specify the <account-id> as part of the command.

Listing deployed endpoints URLs

When you deploy a project that contains resources like a CDN, an API Gateway, or other resources that support endpoints, AWS assigns these resources with endpoint URLs. The endpoint URLs are unique for every deployed stack of the project, so the command takes a stack name as an argument.

$ alto endpoints <stack-name>
✔ Checking user credentials
✔ Working account: Altostra, Inc
✔ Loading project
✔ Getting project domain names
Api01:
  Domain01: demo.altostra.com
  StageProd: https://demo.execute-api.us-east-1.amazonaws.com/Prod
Bucket01:
  demo.s3.amazonaws.com

Omit the <stack-name> argument in interactive mode to select the stack from a list.

Improved multi-region operations

When creating an environment using the alto environment command, you can now specify the account and region using the --account and --region arguments.

The CLI will now indicate when an environment is still initializing and cannot be used. See our previous post Deploy stacks across multiple AWS Accounts and Regions for more details about deployments across regions.

Get stack deployment errors

When a deployment fails, Altostra stores the reason alongside the deployment record, which you can then inspect in the Altostra Web Console.

Now, you can also view these errors in the Altostra CLI.

$ alto stack errors <stack-name>
✔ Checking user credentials
✔ Working account: Altostra, Inc
✔ Loading project
✔ Getting stack errors data

Errors for stack [demo]:
[
  {
    "status": "CREATE_FAILED",
    "reason": "duplicateSNSTopic already exists",
    "type": "AWS::SNS::Topic",
    "properties": "{\"DisplayName\":\"demo\",\"TopicName\":\"duplicateSNSTopic\"}"
  },
  ...
]

Omit the <stack-name> argument in interactive mode to select the stack from a list.

Get the project ID

We added a new command that allows you to get the project ID. It is primarily useful in scripts but can also help if you need to get the ID in the terminal.

# get the ID of the project in the current directory
$ alto project id

# get the ID of a project on your Altostra account using its name
$ alto project id --project-name "My Project"

Output AWS CloudFormation templates in YAML format

You can now choose the output format, JSON or YAML, for the CloudFormation template file when building an Altostra project.

$ alto build --format yaml --env Production
✔ Checking user credentials
✔ Working account: Altostra, Inc
✔ Processing request
✔ Loading project
✔ Loading environment configuration
✔ Compiling project
✔ Saving template: Template saved to /Users/.../sam-template.yml

The alto build command converts projects from the Altostra Blueprint data model to CloudFormation templates, incorporating parameter values from an environment. The resulting CloudFormation template is then saved to the disk.

Auto-login by default

Until now, if your CLI authentication expired or if you haven’t logged in, you would get an error message when executing commands that require authentication.

Since the most common use case is to authenticate and run a command, we enabled auto-login by default to save you some time and typing.

Now, whenever you execute a command requiring authentication, the login workflow will automatically kick in, asking you to authenticate. The CLI will then continue executing your command.

If you wish to turn it off, run:

$ alto config set --global autoLogin false

The auto-login feature works only in interactive mode.

Improved ergonomics

The CLI will now ask you for missing required arguments and will allow you to select values from a list whenever possible.

For example, the alto stack history command will provide a list of stacks to choose from:

$ alto stack history
✔ Checking user credentials
✔ Working account: Altostra, Inc
✔ Loading project
✔ Listing available stacks
? Select a stack: (Use arrow keys)
❯ prod
  dev
  qa

This only applies to interactive mode.

Scripting

For scripting, we like to use the --json option together with the jq tool. You can also use the --text option if you prefer to parse the output that way.

Here's a simple example:

# get the latest status of the first project stack
$ alto stack --json | \
    jq -r '.[] | "\(.name) is \(.status) to \(.environment) from \(.tag)"'

prod-stack is Deployed to Production from v2.11.2
yev-stack is Deployed to Dev from v2.11.3
dan-stack is Deployed to Dev from v2.11.3

Summary

We improved the CLI to make it easier to use, apply to more use cases, and support the new features Altostra offers.

We'll continue improving the CLI—adding more features and commands. Meanwhile, if you feel that something is missing or can be improved, let us know so we can make your development experience even better.

Next steps

Want to give it a try? We provide a free-forever plan for developers. Create your free account today at https://app.altostra.com.

We want to hear from you! Share your Altostra experience with us on Twitter @AltostraHQ and LinkedIn and any suggestions that can make your work with Altostra even better.

Happy coding!

By submitting this form, you are accepting our Terms of Service and our Privacy Policy

Thanks for subscribing!

Ready to Get Started?

Get Started for Free

Copyright © 2021 Altostra. All rights reserved.