Google Translate API 등 구글의 API들은 Google Cloud에 통합되어 있다. 그렇기 때문에 어떤 API를 사용하더라도 제일 먼저 해야할일은 Google Cloud CLI를 설치하는 것이다. 기본적인 설명은 아래의 공식 사이트를 참조하기 바란다. Google Cloud 관련해서 굉장히 많은 내용들이 많기 때문에 오늘은 설치하는 과정에만 집중해서 정리하려고 한다.
https://cloud.google.com/sdk/docs/install?hl=ko
1. 프로젝트 생성
자신의 Google Cloud Dashboard에 들어가면 현재 자신이 보유한 프로젝트 리스트도 볼 수가 있고, 새로운 프로젝트를 생성할 수 있다. 아래와 같이 "New Project"를 클릭해 생성해준다.

프로젝트가 생성이 되었으면 이름을 잘 기억해 두고 본격적으로 Google Cloud CLI를 설치하도록 하겠다.
2. Google Cloud CLI 설치
설치는 공식문서를 참조해서 우분투의 경우 아래와 같이 진행하면 된다.
sudo apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-cli
3. 프로젝트 연결
CLI가 설치되면 Google Cloud를 프로젝트와 연결하는 초기화 설정을 해주어야 한다. init을 하면 브라우저가 뜨면서 손쉽게 연결이 가능하다.
gcloud init
그런데 이때 사용하는 환경이 로컬 PC가 아닌 AWS 같은 원격 환경일때는 GUI가 없기 때문에 크롬 브라우저를 볼 수가 없어서 진행이 되지 않는다. 그럴 때는 아래의 명령어로 들어간다.
https://cloud.google.com/sdk/gcloud/reference/init
gcloud init --no-browser
아래 메뉴가 나오면 1번을 누른다.
Welcome! This command will take you through the configuration of gcloud.
Settings from your current configuration [default] are:
accessibility:
screen_reader: 'False'
core:
account: your-email@gmail.com
disable_usage_reporting: 'True'
project: your-project-name
Pick configuration to use:
[1] Re-initialize this configuration [default] with new settings
[2] Create a new configuration
Please enter your numeric choice: 1
자신의 이메일 계정을 선택한다.
Choose the account you would like to use to perform operations for this configuration:
[1] your-email@gmail.com
[2] Log in with a new account
Please enter your numeric choice:1
처음에 만들어 두었던 프로젝트 이름을 선택한다.
Pick cloud project to use:
[1] your-project-name
[2] ...
...
[12] Enter a project ID
[13] Create a new project
Please enter numeric choice or text value (must exactly match list item): 1
아래와 같은 메세지를 보게 된다면 모든 Google Cloud 설정이 성공적으로 완료된 것이다.
Your current project has been set to: [your-project-name].

이후에, Translate 등 자신이 필요한것들만 골라서 자유롭게 API를 추가적으로 설치해서 사용하면 된다.
끝!
댓글