Amazon Web Services offers reliable, scalable, and inexpensive cloud computing services. Free to join, pay only for what you use. $ aws -version aws-cli/2.0.47 Python/3.7.4 Linux/4.14.133-113.105.amzn2.x8664 botocore/2.0.0 AWS CLI version 2. The AWS CLI version 2 is the most recent major version of the AWS CLI and supports all of the latest features. First, you need to install AWS CLI for OSX using the following link. Refer the documentation for Install the AWS Command Line Interface on macOS for more details. Then you need to create AWS Programmatic Access Credentials (After creating a AWS IAM User) and download the credentials. For this you need to go to the IAM section of AWS Web Console.
We can use the AWS Command Line Interface (AWS CLI) to control multiple AWS services from the command line and automate them through scripts. We can use the AWS CLI for ad hoc operations, such as creating a table. We can also use it to embed Amazon DynamoDB operations within utility scripts. Before you can use the AWS CLI with DynamoDB, you must get an access key ID and secret access key.
The AWS CLI is available at http://aws.amazon.com/cli. It runs on Windows, macOS, or Linux.
Installing the AWS CLI on macOS
The AWS CLI version 2 has no dependencies on other Python packages. It has a self-contained, embedded copy of Python included in the installer.
Prerequisites for macOS:
- It supports the AWS CLI version 2 on Apple-supported versions of 64-bit macOS.
- Because AWS doesn’t maintain third-party repositories, we can’t guarantee that they contain the latest version of the AWS CLI.
Installation:
The following steps show how to install the latest version of the AWS CLI version 2 by using the standard macOS user interface and your browser:
- In your browser, download the macOS pkg file: https://awscli.amazonaws.com/AWSCLIV2.pkg
- Double-click the downloaded file to launch the installer.
- Follow the on-screen instructions.If you have sudopermissions, you can install the AWS CLI version 2 for all users on the computer.Download the file using the curl command. The -o option specifies the file name that the downloaded package is written to. In this example, the file is written to AWSCLIV2.pkg in the current folder.
- Run the standard macOS installer program, specifying the downloaded .pkg file as the source. Use the -pkg parameter to specify the name of the package to install, and the-target / parameter for which drive to install the package to. The files are installed to/usr/local/aws-cli, and a symlink is automatically created in/usr/local/bin. You must include sudoon the command to grant write permissions to those folders.
This will install the AWS CLI version 2 in your macOS system.
Uninstall the AWS CLI on macOS
To uninstall the AWS CLI version 2, run the following commands, substituting the paths you used to install.
- Find the folder that contains the symlinks to the main program and the completer.
- Using that information, run the following command to find the installation folder that the symlinks point to.
- Delete the two symlinks in the first folder. If your user account already has written permission to these folders, you don’t need to use sudo.
- Delete the main installation folder. Use sudoto gain write access to the/usr/local folder.
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to [email protected]. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the 'Improve Article' button below.
Is it possible to create and manage resources on AWS without logging in to the AWS management Console? Yes, it is definitely possible and the answer is AWS CLI (Command Line Interface)
AWS CLI is a unified tool to manage your AWS Services. You can start using the tool after installing and doing a minimal configuration. The tool provides all the functionality provided by AWS Management Console. The tool can be installed and used on Windows, Linux or Mac. After installing the tool you can run the cli commands by utilizing shell such as Bash on Linux or PowerShell or Windows Command Line on Microsoft Windows.
Installing AWS CLI
WINDOWS
You can install AWS CLI on Windows with an installer
Run the downloaded installer and follow the instructions that appear.
LINUX, mac OS or UNIX
To install AWS CLI on Linux, macOS or Unix make sure you have a working version of Python 2 version 2.6.5+ or Python 3 version 3.3+
Download and run the installation script from the pip website
curl “https://bootstrap.pypa.io/get-pip.py” -o “get-pip.py”
python get-pip.py –user
Install AWS CLI using PIP
pip install awscli –user
How to create the Security Credentials
Inorder to use aws cli tool you have to configure it. The configuration requires AWS Access Key ID and Secret Access Key. Each user who has access to AWS requires his own AWS Access keys in order to use AWS CLI tools. You can also use the Access keys to make direct HTTP calls using the APIs for the individual AWS services.
Note: Do not use the root user ID to access AWS resources. The root user has all access to the AWS resources.
Create a New User
To create a new user, login to AWS Management Console as root user (or the account level user. This user has all access.) After login you can use IAM (Identity and Access Management ) service to create users with restricted access.
Download Aws Cli
Select the option Create individual IAM Users and select Manage Users.
Click Add User to create a new user. You have to enter user name and select the AWS access type required. You have to select programmatic access, since the user should be able to access the aws resources using the CLI. Click on Next:Permissions button to provide the required permission to the user.
Set Permissions
In order to set the permissions, you can do one of the following:
- add the user to a group so that the user will have all the permissions of the group.
- copy the permissions of an existing user.
- attach existing policies directly.
Note: Screen shot shows the groups that i have created, you can create your own group as required.
I will consider EC2 service as an Example to show the use of CLI in this article. I will make the new user a member of the developer group. The group has full access to Amazon EC2. This is indicated by the permissionAmazonEC2FullAccess. Click on CreateUser button to create the user. Select the newly created user and go to the Security Credentials tab. Click on Create Access Key to create a new set of secret keys for the user.
You can note that this user cannot login to the console as his password is disabled. Every resource that you create on AWS including the users that you create has its own unique resource name called ARN (Amazon Resource Name).
Download the CSV file. This file contains the Access Key ID and the Secret access key. This information is required to configure the CLI tool.
Note: Store the downloaded CSV file in a safe location. This is the only time you can view the secret keys or download the CSV file containing these keys. You cannot get this information again. If required, you can create a new access key at any time. You are allowed to have only two access keys for any user
Configure AWS CLI
You can download the csv file and use it to configure CLI by running the following command in the terminal window on linux (Power shell or command prompt on windows). Use the details in the CSV file to provide Access Key Id, Secret Access Key, Default region name and Default output format
$ aws configure
AWS Access Key ID [None] : AKIAIOSFODNN7EXAMPLEKEYID
AWS Secret Access Key [None] : wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None] : us-west-2
Default output format [None] : json
AWS Access Key ID [None] : AKIAIOSFODNN7EXAMPLEKEYID
AWS Secret Access Key [None] : wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None] : us-west-2
Default output format [None] : json
What is a Region?
AWS provides its services from several different regions. Each region is a separate geographical area and each region is completely independent. You can select a specific region after login to AWS Console.
Note: Some of the services may not be available in some regions
What is an Availability Zone?
Each region has multiple isolated locations known as availability zone. AWS allows you to place your resources (Like EC2 virtual machine instances, data) in multiple locations. The resources will not be replicated across regions unless you do it specifically. Each availability zone is isolated, but the Availability Zones in a region are connected through low latency links. The following diagram illustrates the relationship between regions and availability zones.
Output Format
You can set the output of any command that you execute to display in Json (JavaScript Object Notation), Text or Table format.If you do not specify an output format JSON will be used as default.
General AWS Command Syntax
Now your CLI tool is configured and you can execute commands to manage your AWS resources. You can refer to the AWS CLI Command Reference for a complete list of commands. Also you can refer to this documentation to find out what services are supported by CLI.
Install Aws Cli Mac Os
The general aws command syntax is
$ aws <command> <sub-command> [options and parameters]
where each command begins with the word aws. The next part is the command. The command is usually an AWS service supported by CLI. Each service has additional sub command that specify the operation to be performed in that service. Options and parameters indicate the general CLI options or specific parameters of an operation.They can be specified on the command line in any order.
Some EC2 Commands
describe-instances
This command provides you information of one or more EC2 instances based on the instance IDs specified. This command requires a parameter instance id. You can provide multiple instance ids if you want to get the details of all those vm instances.
$ aws ec2 describe-instances –instance-id i-0408b622aa5658683
You can see that the JSON output shows the details of the virtual machine instance like the public IP (an IP address which is reachable over the Internet), private IP (an IP address which is not reachable over the Internet), type of virtualization, type of VM instance (based on the amount of CPU,memory, storage and network capabilities of the VM), current state of the VM and several other properties.
You can display the same output in table form. This is achieved by changing the default output format to table in the aws configure command
stop-instances
Aws Cli For Mac Os 10.13
You can use this command to stop an EBS backed instance. You have to provide instance id of the instance to be stopped or instance ids of multiple instances.
Every time you create a VM instance an EBS volume will be attached to your instance (The root volume). The size of this volume is 8GiB by default. You can have a bigger root volume if required. You can attach and mount additional volumes as and when required.
Aws Cli For Mac
Note: You will be charged for EBS volume usage even when you stop your instance since the EBS volume is still connected to your instance.
$ aws ec2 stop-instances –instance-id i-0408b622aa5658683
Aws Cli For Mac Os 10.13
You can run the describe-instances command with the same instance id to make sure that the instance has entered the stopped state
Conclusion
Aws Cli For Mac Os 10.7
AWS CLI tools allow you to manage your aws resources. You can provide the required access for the resources you own to your users. This allows fine grained access to your aws resources without logging in to AWS management console. You can set the required permissions for each of the user using the IAM service. You can then create access keys for each user and provide the keys to the user. The user can configure CLI tools on his machine using these access keys. This allows the user to access your aws resources based on the permissions provided by you.
Did you like this article?. Don’t forget to mention your comments about this article.