Amazon Web Services

Installing the AWS Command Line Interface on OS X (AWS CLI 설치하기)

sstdio.h·2017년 4월 12일·조회 6,336

1. 개요

오늘은 OS X, 현재 이름으로는 macOS에서 Homebrew를 이용해 AWS CLI를 설치해보려고 한다.

AWS CLI는 터미널에서 AWS 서비스를 제어할 수 있게 해주는 명령줄 도구다. 설치가 끝나면 aws --version으로 정상 설치 여부를 확인할 수 있다.


2. 설치 조건

AWS CLI의 설치 조건은 설치하는 버전에 따라 조금 다르다. 아래 조건은 이 글의 예시처럼 AWS CLI v1을 설치할 때 필요한 조건이다.

  • Python 2 version 2.6.5+ 또는 Python 3 version 3.3+
  • Windows, Linux, macOS 또는 Unix

참고로 Homebrew로 awscli를 설치하면 시점에 따라 설치되는 AWS CLI 버전이 달라질 수 있다. 아래 설치 로그의 버전 번호는 당시 실행 결과이므로, 현재 환경에서는 다르게 표시될 수 있다.


3. 설치

이제 Homebrew를 통해 AWS CLI를 설치한다.

$ brew install awscli
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
alexjs              expect              jenkins-lts         make                teleport
apple-gcc42         file-formula        juju-wait           maven@3.3           terraform-docs
(생략...)
ed                  heimdal             m4                  tcl-tk
exa                 httpflow            magic-wormhole      tcpdump
==> Updated Formulae
abcde                             godep                             osquery
ace                               goenv                             osrm-backend
(생략...)
go                                osc
gobject-introspection             osmfilter
==> Renamed Formulae
bazel02 -> bazel@0.2
bigdata -> blazegraph
bison27 -> bison@2.7
boost-python159 -> boost-python@1.59
cassandra21 -> cassandra@2.1
cassandra22 -> cassandra@2.2
clang-format38 -> clang-format@3.8
docker111 -> docker@1.11
docker171 -> docker@1.71
eris -> monax
ffmpeg28 -> ffmpeg@2.8
freetds091 -> freetds@0.91
glfw2 -> glfw@2
gnuplot4 -> gnuplot@4
gradle214 -> gradle@2.14
grails25 -> grails@2.5
gsl1 -> gsl@1
gst-plugins-bad010 -> gst-plugins-bad@0.10
gst-plugins-base010 -> gst-plugins-base@0.10
gst-plugins-good010 -> gst-plugins-good@0.10
gst-plugins-ugly010 -> gst-plugins-ugly@0.10
gstreamer010 -> gstreamer@0.10
influxdb08 -> influxdb@0.8
jboss-as5 -> jboss-as@5
jetty8 -> jetty@8
jpeg6b -> jpeg@6
jpeg9 -> jpeg@9
kafka080 -> kafka@0.80
kibana41 -> kibana@4.1
kibana44 -> kibana@4.4
kubernetes-cli13 -> kubernetes-cli@1.3
ledger26 -> ledger@2.6
libpng12 -> libpng@1.2
libpqxx3 -> libpqxx@3
libxml278 -> libxml2@2.7
logstash24 -> logstash@2.4
mapnik2 -> mapnik@2
maven31 -> maven@3.1
maven32 -> maven@3.2
mongodb30 -> mongodb@3.0
mongodb32 -> mongodb@3.2
open-mpi16 -> open-mpi@1.6
percona-server55 -> percona-server@5.5
percona-server56 -> percona-server@5.6
perl514 -> perl@5.14
perl518 -> perl@5.18
phantomjs192 -> phantomjs@1.92
phantomjs198 -> phantomjs@1.98
postgresql94 -> postgresql@9.4
postgresql95 -> postgresql@9.5
pyqt5 -> pyqt
qt5 -> qt
rebar3 -> rebar@3
recipes -> gnome-recipes
redis26 -> redis@2.6
redis28 -> redis@2.8
ruby187 -> ruby@1.8
ruby193 -> ruby@1.9
ruby20 -> ruby@2.0
ruby21 -> ruby@2.1
ruby22 -> ruby@2.2
ruby23 -> ruby@2.3
selenium-server-standalone245 -> selenium-server-standalone@2.45
solr54 -> solr@5.4
solr55 -> solr@5.5
srtp15 -> srtp@1.5
subversion18 -> subversion@1.8
swig2 -> swig@2
swig304 -> swig@3.04
thrift090 -> thrift@0.90
unison240 -> unison@2.40
v8-315 -> v8@3.15
varnish4 -> varnish@4
vim74 -> vim@7.4
zeromq32 -> zeromq@3.2
zeromq40 -> zeromq@4.0
==> Deleted Formulae
devhelp             elasticsearch@2.3   gnupg2              scsh                xstow
elasticsearch@1.7   fb-adb              multirust           webkitgtk

==> Downloading https://homebrew.bintray.com/bottles/awscli-1.11.76.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring awscli-1.11.76.sierra.bottle.tar.gz
==> Caveats
The "examples" directory has been installed to:
  /usr/local/share/awscli/examples

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
⯑  /usr/local/Cellar/awscli/1.11.76: 4,056 files, 33.8MB

뭐가 엄청 많이 지나갔다. Homebrew가 먼저 자신과 formula 목록을 업데이트한 뒤 AWS CLI를 내려받아 설치한 것이다.

설치 확인

버전을 확인한다.

$ aws --version
aws-cli/1.11.76 Python/2.7.10 Darwin/16.4.0 botocore/1.5.39

혹은 환경에 따라 다음처럼 다른 버전으로 표시될 수 있다.

$ aws --version
aws-cli/1.16.230 Python/3.7.4 Darwin/18.7.0 botocore/1.12.220

aws 명령을 찾을 수 없다는 메시지가 나온다면 Homebrew 설치 경로가 PATH에 포함되어 있는지 확인해야 한다. 터미널을 새로 열어 다시 시도하는 것만으로 해결되는 경우도 있다.

기본 설정

설치만으로는 AWS 계정에 접근할 수 없다. 실제로 명령을 실행하려면 액세스 키, 기본 리전, 출력 형식 등을 설정해야 한다.

$ aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

설정 후에는 권한이 있는 계정인지 간단한 조회 명령으로 확인해볼 수 있다. 예를 들어 S3 권한이 있다면 다음 명령으로 버킷 목록 조회를 시도할 수 있다.

$ aws s3 ls

4. 기타

또 다른 설치 방법은 Python과 pip를 이용하는 것이다. 다만 pip로 설치할 때는 사용 중인 Python 환경과 AWS CLI 버전에 따라 설치 방식이 달라질 수 있으므로, 공식 문서의 안내를 확인한 뒤 진행하는 것이 좋다.

댓글 1

로그인 후 댓글을 남길 수 있습니다.

  • 고구마엔사이다· 2019년 10월 31일
    [code]$ aws --version aws-cli/1.16.260 Python/3.7.4 Darwin/18.2.0 botocore/1.12.250[/code]