[LINUX] Preparing to use aws cli on Mac OS X

Here are the steps to install AWS CLI version 2 on Mac OS X.


--I have a Mac OSX PC --You can connect to the Internet --I have an AWS account --AWS CLI version 2 is for installation

Advance preparation

Before you start, create an IAM user to work with the AWS CLI.

--AWS console - IAM --Access management> User --Add user --Username: (optional) --Access type: Programmatic access --Permission settings: (optional)

When you create a user, you will be assigned a ʻAccess key ID and a Secret access key`. Make a note of it as you will need it later when configuring.

Install AWS CLI

Execute the command as shown in AWS Documents. It is a mystery whether the last backslash is needed.

Install awscli

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

After installing the AWS CLI, configure it next. It's like logging in. You can give it any profile name. Creating a named profile makes it easier to switch users. (For example, if you own another AWS account and want to use aws-cli on the same PC) You will be asked four questions at the prompt. Please read {Access key ID} and {Secret access key} as appropriate. Specify the region and output format you like. If you don't need to switch users, you don't need the --profile {profile name} part.

Run configure

aws configure --profile {Profile name}

Execution result

AWS Access Key ID [None]: {Access key ID}
AWS Secret Access Key [None]: {Secret access key}
Default region name [None]: us-west-2
Default output format [None]: json

Operation check

I will try to get the information of EC2 instance. If you haven't created a named profile, you don't need the --profile {profile name} part.

EC2 information acquisition

aws ec2 describe-instances --profile {Profile name}
The execution result is omitted. If you want to see it, please open here.

Execution result

    "Reservations": [
            "Groups": [],
            "Instances": [
                    "AmiLaunchIndex": 0,
                    "ImageId": "ami-XXXXXXXX",
                    "InstanceId": "i-XXXXXXXXXXXXXXXXX",
                    "InstanceType": "t2.nano",
                    "LaunchTime": "2020-01-01T00:00:00+00:00",
                    "Monitoring": {
                        "State": "disabled"
                    "Placement": {
                        "AvailabilityZone": "us-west-2b",
                        "GroupName": "",
                        "Tenancy": "default"
                    "PrivateDnsName": "ip-XXX-XXX-XXX-XXX.us-west-2.compute.internal",
                    "PrivateIpAddress": "XXX.XXX.XXX.XXX",
                    "ProductCodes": [],
                    "PublicDnsName": "ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com",
                    "PublicIpAddress": "XXX.XXX.XXX.XXX",
                    "State": {
                        "Code": 16,
                        "Name": "running"
                    "StateTransitionReason": "",
                    "SubnetId": "subnet-XXXXXXXX",
                    "VpcId": "vpc-XXXXXXXX",
                    "Architecture": "x86_64",
                    "BlockDeviceMappings": [
                            "DeviceName": "/dev/xvda",
                            "Ebs": {
                                "AttachTime": "2020-01-01T00:00:00+00:00",
                                "DeleteOnTermination": false,
                                "Status": "attached",
                                "VolumeId": "vol-XXXXXXXXXXXXXXXXX"
                    "ClientToken": "",
                    "EbsOptimized": false,
                    "EnaSupport": true,
                    "Hypervisor": "xen",
                    "NetworkInterfaces": [
                            "Association": {
                                "IpOwnerId": "XXXXXXXXXXXX",
                                "PublicDnsName": "ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com",
                                "PublicIp": "XXX.XXX.XXX.XXX"
                            "Attachment": {
                                "AttachTime": "2020-01-01T00:00:00+00:00",
                                "AttachmentId": "eni-attach-XXXXXXXXXXXXXXXXX",
                                "DeleteOnTermination": true,
                                "DeviceIndex": 0,
                                "Status": "attached"
                            "Description": "",
                            "Groups": [
                                    "GroupName": "XXXXXXXXXXXXXX",
                                    "GroupId": "sg-XXXXXXXX"
                            "Ipv6Addresses": [],
                            "MacAddress": "XX:XX:XX:XX:XX:XX",
                            "NetworkInterfaceId": "eni-XXXXXXXXXXXXXXXXX",
                            "OwnerId": "XXXXXXXXXXXX",
                            "PrivateDnsName": "ip-XXX-XXX-XXX-XXX.us-west-2.compute.internal",
                            "PrivateIpAddress": "XXX.XXX.XXX.XXX",
                            "PrivateIpAddresses": [
                                    "Association": {
                                        "IpOwnerId": "XXXXXXXXXXXX",
                                        "PublicDnsName": "ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com",
                                        "PublicIp": "XXX.XXX.XXX.XXX"
                                    "Primary": true,
                                    "PrivateDnsName": "ip-XXX-XXX-XXX-XXX.us-west-2.compute.internal",
                                    "PrivateIpAddress": "XXX.XXX.XXX.XXX"
                            "SourceDestCheck": true,
                            "Status": "in-use",
                            "SubnetId": "subnet-XXXXXXXX",
                            "VpcId": "vpc-XXXXXXXX",
                            "InterfaceType": "interface"
                    "RootDeviceName": "/dev/xvda",
                    "RootDeviceType": "ebs",
                    "SecurityGroups": [
                            "GroupName": "XXXXXXXXXXXXXX",
                            "GroupId": "sg-XXXXXXXX"
                    "SourceDestCheck": true,
                    "VirtualizationType": "hvm",
                    "CpuOptions": {
                        "CoreCount": 1,
                        "ThreadsPerCore": 1
                    "CapacityReservationSpecification": {
                        "CapacityReservationPreference": "open"
                    "HibernationOptions": {
                        "Configured": false
                    "MetadataOptions": {
                        "State": "applied",
                        "HttpTokens": "optional",
                        "HttpPutResponseHopLimit": 1,
                        "HttpEndpoint": "enabled"
            "OwnerId": "XXXXXXXXXXXX",
            "ReservationId": "r-XXXXXXXXXXXXXXXXX"

Recommended Posts

Preparing to use aws cli on Mac OS X
Steps to use the AWS command line interface (Python / awscli) on Mac OS X
Preparing to run ImageMagick + im4java on Mac OS
Memo on Mac OS X
Very easy to install SciPy on Mac OS X
Install Sphinx on Mac OS X
Install mitmproxy on Mac OS X
Install pgmagick on Mac OS X 10.9
How to install Theano on Mac OS X with homebrew
Continuation ・ Notes on preparing the Python development environment on Mac OS X
I want to use Linux on mac
Installed aws-cli On Mac OS X Lion
How to erase Python 2.x on Mac.
How to install Theano on Mac OS X 10.10 (using pyenv, anaconda)
Run NASA CEA on Mac OS X
Easy way to use Python 2.7 on Cent OS 6
Run Zookeeper x python (kazoo) on Mac OS X
Shpinx (Python documentation builder) on Mac OS X
Building an environment for "Tello_Video" on Mac OS X
How to install caffe on OS X with macports
Try using E-Cell 4 on Windows 7 or Mac OS X
Build a Python development environment on Mac OS X
Preparing to use Ansible on an existing Linux server
Install PyQt5 with homebrew on Mac OS X Marvericks (10.9.2)
I want to AWS Lambda with Python on Mac!
OS X EI Capitan (10.11.6) AWS CLI installation error (python-dateutil)
Update python on Mac to 3.7-> 3.8
Use matplot libwidget on mac
Using multiple versions of Python on Mac OS X (2) Usage
Using NAOqi 2.4.2 Python SDK on Mac OS X El Capitan
Get started with the Python framework Django on Mac OS X
How to install mysql-connector-python on mac
Using multiple versions of Python on Mac OS X (1) Multiple Ver installation
How to use Dataiku on Windows
Preparing to run Flask on EC2
Steps to install matplotlib on Mac
Convert wma to mp3 on Mac
Notes on how to use pywinauto
Use jupyter on AWS GPU instance
Installation of scikit-learn (Mac OS X)
Install Scipy on Mac OS Sierra
Notes on how to use featuretools
How to install OpenCV on Mac
How to use homebrew on Debian
I tried to display GUI on Mac with X Window System
Install lp_solve on Mac OS X and call it with python.
Steps to get Caffe into Mac OS X 10.10 in CPU Mode
Notes on how to use doctest
Steps to install python3 on mac
Update Python on Mac from 2 to 3
Steps to get KeePassX key on OS X with one command line
How to use gcc when compiling extension modules from setup.py on Mac
[Just a note] Until Keras + TensorFlow works on Mac OS X Sierra
Introduction to Graph Database Neo4j in Python for Beginners (for Mac OS X)
Mac OS X Mavericks 10.9.5 Development environment construction
How to install drobertadams / toggl-cli on Mac
Install matplotlib on OS X El Capitan
How to use mecab, neologd-ipadic on colab
How to use Google Assistant on Windows 10
Memorandum on how to use gremlin python
Use without installing python 2.x on Windows