728x90
반응형
Overview
오늘은 gcloud 명령어를 사용해 gmail 계정 2개를 등록해보려고 한다.
아직 계정이 없거나 gcloud init을 한번도 하지 않았다면 아래의 게시물을 참조하기 바란다.
2023.04.06 - [GCP] - GCP란? - 서비스 계정 & Project 생성 / SDK(gcloud) 설치
오늘은 실습할 내용은 아래와 같다.
- gcloud configurations 확인
- 기존 계정 configurations name 변경 및 비활성화
- 두번째 계정 등록
- 계정 전환 방법
- 계정 전환 후 Project 확인
GCP 실습
1. gcloud configurations 확인
gcloud config configurations 명령어
$ gcloud config configurations
Available commands for gcloud config configurations:
activate Activates an existing named configuration.
create Creates a new named configuration.
delete Deletes a named configuration.
describe Describes a named configuration by listing its
properties.
list Lists existing named configurations.
rename Renames a named configuration.
gcloud config configurations list 확인
$ gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION
default True somaz@gmail.com somaz-project
2. 기존 계정 configurations name 변경 및 비활성화
기존 계정 configurations name 변경
$ gcloud config configurations rename default --new-name=somaz
ERROR: (gcloud.config.configurations.rename) Cannot rename configuration [default], it is the currently active configuration.
- name 변경을 시도하였지만 현재 active 상태라 변경되지 않는다.
$ gcloud config configurations create somaz2
Created [somaz2].
Activated [somaz2].
somaz@AD01769994:~$ gcloud config configurations activate somaz2
Activated [somaz2].
- 새로운 계정을 추가한 뒤 activate 시킨다.
$ gcloud config configurations rename default --new-name=somaz
Renamed [default] to be [somaz].
somaz@AD01769994:~$ gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION
somaz2 True
somaz False somaz@gmail.com somaz-project
somaz@AD01769994:~$ gcloud config set account somaz2@gmail.com
Updated property [core/account].
$ gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION
somaz2 True somaz2@gmail.com
somaz False somaz@gmail.com somaz-project
- active 상태가 아니라서 이름변경이 잘된다.
- 이름 변경후 새로운 계정에 이메일을 추가해준다.
3. 두번째 계정 등록
계정 인증
$ gcloud auth login
- auth login 명령어를 사용하면 google 창에 로그인 한뒤 동의를 해준다.
4. 계정 전환 방법
$ gcloud config configurations activate somaz
Activated [somaz].
somaz@AD01769994:~$ gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION
somaz2 False somaz2@gmail.com
somaz True somaz@gmail.com somaz-project
somaz@AD01769994:~$ gcloud config list
[core]
account = somaz@gmail.com
disable_usage_reporting = False
project = somaz-project
Your active configuration is: [somaz]
somaz@AD01769994:~$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* somaz@gmail.com
somaz2@gmail.com
5. Project 확인
$ gcloud projects list
PROJECT_ID NAME PROJECT_NUMBER
singular-acumen-382905 My First Project 736664391334
somaz-project somaz-project 470321790129
$ gcloud config configurations activate somaz2
Activated [somaz].
somaz@AD01769994:~$ gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION
somaz2 True somaz2@gmail.com
somaz False somaz@gmail.com somaz-project
somaz@AD01769994:~$ gcloud config list
[core]
account = somaz2@gmail.com
disable_usage_reporting = False
project = somaz2-project
Your active configuration is: [somaz]
somaz@AD01769994:~$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
somaz@gmail.com
* somaz2@gmail.com
$ gcloud projects list
PROJECT_ID NAME PROJECT_NUMBER
singular-acumen-382906 My First Project 736664391334
somaz2-project somaz2-project 470361790129
gcloud Service Account activate 하는 방법
gcloud auth activate-service-account --key-file=/home/somaz/.ssh/sevice-account.json
Reference
728x90
반응형
'GCP' 카테고리의 다른 글
BigQuery와 DataFlow를 활용한 Data ETL(GCP) (0) | 2023.10.02 |
---|---|
GCP BigQuery란? & Data Warehouse (0) | 2023.05.21 |
GCP vs AWS 리소스 비교 (1) | 2023.05.05 |
GCP IAM이란? (0) | 2023.04.17 |
GCP란? - 서비스 계정 & Project 생성 / SDK(gcloud) 설치 (0) | 2023.04.06 |