Tuesday, March 21, 2023

Differences between AWS CLI v1 and v2

Sometimes, aws-cli doesn’t run your cli commands if you are using v1. If your aws cli is v1, I should recommend updating. In this article, you’ll learn in which conditions you should use an AWS CLI v2.

AWS CLI v1 is written in Python language and for v1, you should install Python first but if you are using v2, it comes embedded and a Python interpreter is not needed

Auto Prompt feature is amazing! The AWS CLI v2 can prompt you for commands, parameters, and resources when you run an aws command.

You can import your config! Yes, AWS CLI v2 comes with aws configure import option and you can import your .csv credentials generated from the AWS Management Console. A .csv file is imported with the profile name matching the IAM user name. For example aws configure import.

Metadata Support for high-level S3 commands: You can configure additional metadata support for high-level S3 commands with the --copy-props argument.

AWS_REGION: is absolutely a lifesaver! It’s an SDK-compatible variable and it overrides the AWS_DEFAULT_REGION variable on your environment. It’s only available in the AWS CLI.

ddb put and ddb select commands are available on AWS CLI v2 for DynamoDB operations. You can put the items into DynamoDB and search in DynamoDB tables or indexes.

YAML Support: Previously, AWS CLI v1 is only using JSON but in v2, it’s more dynamic for
stream-formats and the yaml.

aws configure list-profiles: You can list all aws cli profiles with one command.

Docker Support: This means you don’t have to install AWS CLI v2 anymore. You can just run the docker container and run your aws cli commands easily. You can run into your CI/CD directly without no worries.

aws logs tail: For CloudWatch Logs groups, you can use aws logs tail command to tails the logs. By default, the command returns logs from all CloudWatch Logs streams during the last 10 minutes.

Single Sign-On: If you are an enterprise user, you probably use an SSO to login to AWS Console. Now, AWS CLI v2 is supporting IdP for sign in requests. For example, maybe you are using the Active Directory or Google Cloud SSO Service. You can also use it via AWS CLI v2.

Client-Side Pager Program: The AWS CLI v2 provides the use of a client-side pager program for output. Default, this feature comes with turned on and returns all output through into your OS default pager program.

Wizards: This is really interesting feature I guess. You can use wizard for some configure, dynamodb, events, iam and lambda. You can follow the example on GitHub. https://github.com/aws/aws-cli/tree/v2/awscli/customizations/wizard/wizards

I hope this article helped you.

Leave a Reply

Your email address will not be published. Required fields are marked *