Top Related Projects
GitHub’s official command line tool
Azure Command-Line Interface
Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
Pulumi - Infrastructure as Code in any programming language 🚀
Issue tracker and mirror of kubectl code
Quick Overview
The AWS CLI (Command Line Interface) is an open-source tool that enables users to interact with AWS services using commands in their command-line shell. It provides a unified interface to manage multiple AWS services from the terminal and can be used to automate AWS operations through scripts.
Pros
- Simplifies management of AWS resources across multiple services
- Supports automation through scripting and integration with other tools
- Provides consistent interface across different operating systems
- Regularly updated with new AWS service features
Cons
- Steep learning curve for users new to command-line interfaces
- Requires separate installation and configuration
- May be overwhelming due to the large number of available commands and options
- Performance can be slower compared to using AWS SDKs directly in application code
Code Examples
- Listing S3 buckets:
aws s3 ls
- Creating an EC2 instance:
aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type t2.micro --key-name MyKeyPair --security-group-ids sg-xxxxxxxx --subnet-id subnet-xxxxxxxx
- Describing all running EC2 instances:
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[*].[InstanceId,InstanceType,PublicIpAddress,Tags[?Key=='Name'].Value|[0]]" --output table
Getting Started
-
Install the AWS CLI:
- On macOS:
brew install awscli
- On Windows: Download and run the MSI installer from the AWS website
- On Linux:
pip install awscli
- On macOS:
-
Configure the AWS CLI:
aws configure
Enter your AWS Access Key ID, Secret Access Key, default region, and output format when prompted.
- Verify the installation:
aws --version
- Run your first command:
aws s3 ls
This will list all S3 buckets in your account if configured correctly.
Competitor Comparisons
GitHub’s official command line tool
Pros of cli
- More versatile, supporting multiple GitHub operations beyond just AWS services
- Faster execution times for many operations
- Better integration with GitHub-specific features and workflows
Cons of cli
- Limited to GitHub-specific operations, not as broad in scope as aws-cli
- May require more frequent updates to keep pace with GitHub's rapidly evolving features
- Steeper learning curve for users not familiar with GitHub's ecosystem
Code Comparison
aws-cli example:
aws s3 cp myfile.txt s3://my-bucket/
cli example:
gh repo create my-new-repo --public
gh issue create --title "Bug report" --body "Description of the bug"
The aws-cli focuses on AWS service interactions, while cli provides GitHub-specific commands for repository and issue management. The cli commands are often more concise and tailored to GitHub workflows, whereas aws-cli covers a broader range of cloud services but with more verbose syntax.
Azure Command-Line Interface
Pros of azure-cli
- More extensive documentation and examples in the repository
- Better organized codebase with clear separation of concerns
- More active community engagement and faster issue resolution
Cons of azure-cli
- Larger codebase, potentially more complex to contribute to
- Slower release cycle compared to aws-cli
- Less comprehensive coverage of Azure services
Code Comparison
azure-cli:
from azure.cli.core import AzCommandsLoader
from azure.cli.core.commands import CliCommandType
class MyExtensionLoader(AzCommandsLoader):
def load_command_table(self, args):
custom_command_type = CliCommandType(operations_tmpl='{}#{}')
with self.command_group('myextension', custom_command_type) as g:
g.custom_command('dosomething', 'my_command_handler')
aws-cli:
import click
from awscli.clidriver import CLIDriver
@click.command()
@click.option('--option', help='Description of the option')
def my_command(option):
cli = CLIDriver()
cli.main(['my-service', 'my-operation', '--option', option])
The azure-cli example shows a more structured approach to adding commands, while the aws-cli example demonstrates a simpler, function-based method using the Click library for command-line interface creation.
Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
Pros of Terraform
- Multi-cloud support, allowing infrastructure management across various providers
- Declarative syntax for defining infrastructure as code
- Robust state management and resource tracking
Cons of Terraform
- Steeper learning curve for users new to infrastructure as code
- Potential for state drift if not managed carefully
- Limited native support for some AWS-specific features
Code Comparison
Terraform:
resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
}
AWS CLI:
aws ec2 run-instances \
--image-id ami-0c55b159cbfafe1f0 \
--instance-type t2.micro
Terraform uses a declarative approach to define resources, while the AWS CLI uses imperative commands. Terraform's syntax is more readable and maintainable for complex infrastructure, but the AWS CLI offers more direct control over individual actions.
Both tools have their strengths: Terraform excels in managing infrastructure across multiple providers and maintaining state, while the AWS CLI provides a more straightforward interface for quick AWS-specific tasks and scripting. The choice between them depends on the project's scope, team expertise, and infrastructure complexity.
Pulumi - Infrastructure as Code in any programming language 🚀
Pros of Pulumi
- Supports multiple programming languages (Python, JavaScript, Go, etc.) for infrastructure as code
- Offers a more flexible and powerful approach to infrastructure management
- Provides better integration with existing development workflows and tools
Cons of Pulumi
- Steeper learning curve for those familiar with declarative IaC tools
- Requires more setup and configuration compared to AWS CLI
- May have slower execution times for complex infrastructure deployments
Code Comparison
AWS CLI:
aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type t2.micro
Pulumi:
import pulumi_aws as aws
server = aws.ec2.Instance("webserver",
instance_type="t2.micro",
ami="ami-xxxxxxxx")
The AWS CLI example shows a simple command to launch an EC2 instance, while the Pulumi example demonstrates how to achieve the same result using Python code. Pulumi's approach allows for more complex logic and better integration with existing codebases, but may require more initial setup and familiarity with the chosen programming language.
Issue tracker and mirror of kubectl code
Pros of kubectl
- More versatile for managing multi-cloud and hybrid environments
- Supports a wider range of container orchestration tasks
- Extensive plugin ecosystem for extended functionality
Cons of kubectl
- Steeper learning curve due to Kubernetes complexity
- Requires more setup and configuration compared to AWS CLI
- Limited to container-specific operations
Code Comparison
kubectl:
kubectl get pods
kubectl apply -f deployment.yaml
kubectl describe service my-service
AWS CLI:
aws ec2 describe-instances
aws s3 cp file.txt s3://my-bucket/
aws ecs list-tasks --cluster my-cluster
Summary
kubectl is designed specifically for Kubernetes cluster management, offering powerful container orchestration capabilities across various cloud providers. It excels in complex, multi-cloud environments but requires more expertise to use effectively.
AWS CLI, on the other hand, provides a broader range of AWS-specific services beyond just container management. It's easier to get started with for AWS users but is limited to the AWS ecosystem.
Both tools are essential for their respective domains, with kubectl being more specialized for container orchestration and AWS CLI offering wider AWS service coverage.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
aws-cli
.. image:: https://github.com/aws/aws-cli/actions/workflows/run-tests.yml/badge.svg :target: https://github.com/aws/aws-cli/actions/workflows/run-tests.yml :alt: Build Status
This package provides a unified command line interface to Amazon Web Services.
Jump to:
Getting Started <#getting-started>
__Getting Help <#getting-help>
__More Resources <#more-resources>
__
Getting Started
This README is for the AWS CLI version 1. If you are looking for
information about the AWS CLI version 2, please visit the v2 branch <https://github.com/aws/aws-cli/tree/v2>
__.
Requirements
The aws-cli package works on Python versions:
- 3.8.x and greater
- 3.9.x and greater
- 3.10.x and greater
- 3.11.x and greater
- 3.12.x and greater
Notices
~~~~~~~
On 2022-05-30, support for Python 3.6 was ended. This follows the
Python Software Foundation `end of support <https://www.python.org/dev/peps/pep-0494/#lifespan>`__
for the runtime which occurred on 2021-12-23.
On 2023-12-13, support for Python 3.7 was ended. This follows the
Python Software Foundation `end of support <https://www.python.org/dev/peps/pep-0537/#lifespan>`__
for the runtime which occurred on 2023-06-27.
For more information, see this `blog post <https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/>`__.
*Attention!*
*We recommend that all customers regularly monitor the* `Amazon Web
Services Security Bulletins
website <https://aws.amazon.com/security/security-bulletins>`__ *for
any important security bulletins related to aws-cli.*
Maintenance and Support for CLI Major Versions
The AWS CLI version 1 was made generally available on 09/02/2013 and is currently in the full support phase of the availability life cycle.
For information about maintenance and support for SDK major versions and their underlying dependencies, see the Maintenance Policy <https://docs.aws.amazon.com/credref/latest/refdocs/maint-policy.html>
__ section in the AWS SDKs and Tools Shared Configuration and Credentials Reference Guide.
Installation
Installation of the AWS CLI and its dependencies use a range of packaging
features provided by ``pip`` and ``setuptools``. To ensure smooth installation,
it's recommended to use:
- ``pip``: 9.0.2 or greater
- ``setuptools``: 36.2.0 or greater
The safest way to install the AWS CLI is to use
`pip <https://pip.pypa.io/en/stable/>`__ in a ``virtualenv``:
::
$ python -m pip install awscli
or, if you are not installing in a ``virtualenv``, to install globally:
::
$ sudo python -m pip install awscli
or for your user:
::
$ python -m pip install --user awscli
If you have the aws-cli package installed and want to upgrade to the
latest version, you can run:
::
$ python -m pip install --upgrade awscli
This will install the aws-cli package as well as all dependencies.
.. note::
On macOS, if you see an error regarding the version of ``six`` that
came with ``distutils`` in El Capitan, use the ``--ignore-installed``
option:
::
$ sudo python -m pip install awscli --ignore-installed six
On Linux and Mac OS, the AWS CLI can be installed using a `bundled
installer <https://docs.aws.amazon.com/cli/latest/userguide/install-linux.html#install-linux-bundled>`__.
The AWS CLI can also be installed on Windows via an `MSI
Installer <https://docs.aws.amazon.com/cli/latest/userguide/install-windows.html#msi-on-windows>`__.
If you want to run the ``develop`` branch of the AWS CLI, see the
`Development Version <CONTRIBUTING.md#cli-development-version>`__ section of
the contributing guide.
See the
`installation <https://docs.aws.amazon.com/cli/latest/userguide/install-cliv1.html>`__
section of the AWS CLI User Guide for more information.
Configuration
Before using the AWS CLI, you need to configure your AWS credentials. You can do this in several ways:
- Configuration command
- Environment variables
- Shared credentials file
- Config file
- IAM Role
The quickest way to get started is to run the aws configure
command:
::
$ aws configure AWS Access Key ID: MYACCESSKEY AWS Secret Access Key: MYSECRETKEY Default region name [us-west-2]: us-west-2 Default output format [None]: json
To use environment variables, do the following:
::
$ export AWS_ACCESS_KEY_ID=<access_key> $ export AWS_SECRET_ACCESS_KEY=<secret_key>
To use the shared credentials file, create an INI formatted file like this:
::
[default] aws_access_key_id=MYACCESSKEY aws_secret_access_key=MYSECRETKEY
[testing] aws_access_key_id=MYACCESSKEY aws_secret_access_key=MYSECRETKEY
and place it in ~/.aws/credentials
(or in
%UserProfile%\.aws/credentials
on Windows). If you wish to place the
shared credentials file in a different location than the one specified
above, you need to tell aws-cli where to find it. Do this by setting the
appropriate environment variable:
::
$ export AWS_SHARED_CREDENTIALS_FILE=/path/to/shared_credentials_file
To use a config file, create an INI formatted file like this:
::
[default]
aws_access_key_id=
Optional, to define default region for this profile.
region=us-west-1
[profile testing]
aws_access_key_id=
and place it in ~/.aws/config
(or in %UserProfile%\.aws\config
on Windows). If you wish to place the config file in a different
location than the one specified above, you need to tell the AWS CLI
where to find it. Do this by setting the appropriate environment
variable:
::
$ export AWS_CONFIG_FILE=/path/to/config_file
As you can see, you can have multiple profiles
defined in both the
shared credentials file and the configuration file. You can then specify
which profile to use by using the --profile
option. If no profile is
specified the default
profile is used.
In the config file, except for the default profile, you must prefix
each config section of a profile group with profile
. For example, if
you have a profile named "testing" the section header would be
[profile testing]
.
The final option for credentials is highly recommended if you are using
the AWS CLI on an EC2 instance. IAM Roles <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html>
__
are a great way to have credentials installed automatically on your
instance. If you are using IAM Roles, the AWS CLI will find and use them
automatically.
In addition to credentials, a number of other variables can be
configured either with environment variables, configuration file
entries, or both. See the AWS Tools and SDKs Shared Configuration and Credentials Reference Guide <https://docs.aws.amazon.com/credref/latest/refdocs/overview.html>
__
for more information.
For more information about configuration options, please refer to the
AWS CLI Configuration Variables topic <http://docs.aws.amazon.com/cli/latest/topic/config-vars.html#cli-aws-help-config-vars>
__.
You can access this topic from the AWS CLI as well by running
aws help config-vars
.
Basic Commands
An AWS CLI command has the following structure:
::
$ aws <command> <subcommand> [options and parameters]
For example, to list S3 buckets, the command would be:
::
$ aws s3 ls
To view help documentation, use one of the following:
::
$ aws help
$ aws <command> help
$ aws <command> <subcommand> help
To get the version of the AWS CLI:
::
$ aws --version
To turn on debugging output:
::
$ aws --debug <command> <subcommand>
You can read more information on the `Using the AWS
CLI <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-using.html>`__
chapter of the AWS CLI User Guide.
Command Completion
The aws-cli package includes a command completion feature for Unix-like
systems. This feature is not automatically installed so you need to
configure it manually. To learn more, read the AWS CLI Command completion topic <https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html>
__.
Getting Help
The best way to interact with our team is through GitHub. You can open an issue <https://github.com/aws/aws-cli/issues/new/choose>
__ and
choose from one of our templates for guidance, bug reports, or feature
requests.
You may find help from the community on Stack Overflow <https://stackoverflow.com/>
__ with the tag
aws-cli <https://stackoverflow.com/questions/tagged/aws-cli>
__ or on
the AWS Discussion Forum for CLI <https://forums.aws.amazon.com/forum.jspa?forumID=150>
. If you
have a support plan with AWS Support <https://aws.amazon.com/premiumsupport>
, you can also create
a new support case.
Please check for open similar
issues <https://github.com/aws/aws-cli/issues/>
__ before opening
another one.
The AWS CLI implements AWS service APIs. For general issues regarding
the services or their limitations, you may find the Amazon Web Services Discussion Forums <https://forums.aws.amazon.com/>
__ helpful.
More Resources
Changelog <https://github.com/aws/aws-cli/blob/develop/CHANGELOG.rst>
__AWS CLI Documentation <https://docs.aws.amazon.com/cli/index.html>
__AWS CLI User Guide <https://docs.aws.amazon.com/cli/latest/userguide/>
__AWS CLI Command Reference <https://docs.aws.amazon.com/cli/latest/reference/>
__Amazon Web Services Discussion Forums <https://forums.aws.amazon.com/>
__AWS Support <https://console.aws.amazon.com/support/home#/>
__
.. |Build Status| image:: https://travis-ci.org/aws/aws-cli.svg?branch=develop :target: https://travis-ci.org/aws/aws-cli .. |Gitter| image:: https://badges.gitter.im/aws/aws-cli.svg :target: https://gitter.im/aws/aws-cli
Top Related Projects
GitHub’s official command line tool
Azure Command-Line Interface
Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
Pulumi - Infrastructure as Code in any programming language 🚀
Issue tracker and mirror of kubectl code
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot