You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/nhn-cli/nhn.git
cd nhn-cli
go build -o nhn main.go
# Linux/macOS
sudo mv nhn /usr/local/bin/
# Windows# nhn.exe를 PATH에 포함된 디렉토리로 이동
초기 설정
인증 정보 설정
nhn configure
대화형 프롬프트에서 Identity + OAuth 인증 정보를 순차적으로 입력합니다:
프로필 이름 [default]:
=== NHN Cloud 인증 설정 ===
--- Identity 인증 (필수) ---
Tenant ID: your-tenant-id
Username (이메일 주소): your-email@example.com
API Password: your-api-password
--- OAuth 인증 (필수) ---
User Access Key ID: your-access-key-id
Secret Access Key: your-secret-access-key
=== 리전 설정 ===
기본 리전 [KR1]: KR1
프로필 관리
# 프로필 목록 보기
nhn configure list
# 특정 프로필로 설정
nhn configure --profile production
서비스별 AppKey 설정
AppKey가 필요한 서비스는 별도로 설정합니다:
nhn configure service dns # DNS Plus AppKey
nhn configure service cdn # CDN AppKey + Secret Key
nhn configure service pipeline # Pipeline AppKey
nhn configure service deploy # Deploy AppKey
nhn configure service appguard # AppGuard AppKey
nhn configure service gamebase # Gamebase App ID + Secret Key# 또는 --app-key 플래그로 직접 지정
nhn dns zone list --app-key <appkey>
nhn cdn service list --app-key <appkey> --secret-key <secretkey>
전역 옵션
모든 명령어에서 사용 가능한 옵션:
옵션
설명
기본값
--profile <name>
사용할 프로필
default
--region <region>
리전 지정
프로필 설정값
--output <format>
출력 형식
table
--help
도움말 표시
-
# 예시: production 프로필로 KR2 리전의 인스턴스 조회
nhn --profile production --region KR2 compute instance list
# JSON 형식으로 출력
nhn --output json vpc list
서비스별 옵션
AppKey가 필요한 서비스(dns, pipeline, deploy, cdn, appguard, gamebase)에서 사용 가능:
옵션
설명
대상 서비스
--app-key <key>
서비스 AppKey (프로필 설정 오버라이드)
모든 AppKey 서비스
--secret-key <key>
Secret Key (프로필 설정 오버라이드)
cdn, gamebase
# 프로필 대신 플래그로 AppKey 지정
nhn dns zone list --app-key my-dns-appkey
# CDN은 AppKey + SecretKey 모두 지정 가능
nhn cdn service list --app-key my-cdn-appkey --secret-key my-secret
# Gamebase도 AppKey(App ID) + SecretKey 지정 가능
nhn gamebase member describe user123 --app-key my-app-id --secret-key my-secret
# 보안 그룹 목록
nhn vpc securitygroup list
# 보안 그룹 생성
nhn vpc securitygroup create \
--name my-sg \
--description "My security group"# 인바운드 규칙 추가 (SSH)
nhn vpc securitygroup add-rule <sg-id> \
--direction ingress \
--protocol tcp \
--port 22 \
--remote-ip 0.0.0.0/0
# 인바운드 규칙 추가 (HTTP/HTTPS)
nhn vpc securitygroup add-rule <sg-id> \
--direction ingress \
--protocol tcp \
--port-range 80-443 \
--remote-ip 0.0.0.0/0
# 보안 그룹 삭제
nhn vpc securitygroup delete <sg-id>
플로팅 IP
# 플로팅 IP 목록
nhn vpc floatingip list
# 플로팅 IP 생성
nhn vpc floatingip create
# 인스턴스에 플로팅 IP 연결
nhn vpc floatingip associate <floatingip-id> \
--instance-id <instance-id># 플로팅 IP 연결 해제
nhn vpc floatingip disassociate <floatingip-id># 플로팅 IP 삭제
nhn vpc floatingip delete <floatingip-id>
네트워크 인터페이스
# 네트워크 인터페이스 목록
nhn vpc port list
# 네트워크 인터페이스 생성
nhn vpc port create \
--network-id <network-id> \
--name my-port
# 네트워크 인터페이스 삭제
nhn vpc port delete <port-id>
# 인스턴스 타입 목록
nhn compute flavor list
# 인스턴스 타입 상세 조회
nhn compute flavor describe <flavor-id>
이미지
# 이미지 목록
nhn compute image list
# 이미지 상세 조회
nhn compute image describe <image-id>
키페어
# 키페어 목록
nhn compute keypair list
# 키페어 생성 (새 키 생성)
nhn compute keypair create --name my-keypair
# 키페어 생성 (공개키 등록)
nhn compute keypair create --name my-keypair \
--public-key "ssh-rsa AAAA..."# 키페어 삭제
nhn compute keypair delete my-keypair
가용성 영역
# 가용성 영역 목록
nhn compute az list
Object Storage 명령어
컨테이너 관리
# 컨테이너 목록 조회
nhn objectstorage container list
nhn os container list # 별칭# 컨테이너 메타데이터 조회
nhn os container describe <container-name># 컨테이너 생성
nhn os container create my-container
# 컨테이너 삭제
nhn os container delete my-container
오브젝트 관리
# 오브젝트 목록 조회
nhn os object list --container my-container
# 파일 업로드
nhn os object upload --container my-container --file ./test.txt
# 커스텀 이름으로 업로드
nhn os object upload --container my-container --file ./test.txt --name custom-name.txt
# 오브젝트 다운로드
nhn os object download test.txt --container my-container
# 저장 경로 지정
nhn os object download test.txt --container my-container --output-file ./downloads/test.txt
# 오브젝트 메타데이터 조회
nhn os object describe test.txt --container my-container
# 오브젝트 삭제
nhn os object delete test.txt --container my-container
DNS Plus 명령어
Zone 관리
# Zone 목록 조회
nhn dns zone list
# Zone 상세 조회
nhn dns zone describe <zone-id># Zone 생성
nhn dns zone create --name example.com. --description "My Zone"# Zone 수정
nhn dns zone update <zone-id> --description "Updated description"# Zone 삭제
nhn dns zone delete <zone-id>
Record Set 관리
# Record Set 목록 조회
nhn dns recordset list --zone-id <zone-id># Record Set 상세 조회
nhn dns recordset describe <recordset-id> --zone-id <zone-id># A 레코드 생성
nhn dns recordset create --zone-id <zone-id> \
--name www.example.com. \
--type A \
--ttl 300 \
--data 1.2.3.4
# 다중 레코드 생성
nhn dns recordset create --zone-id <zone-id> \
--name www.example.com. \
--type A \
--ttl 300 \
--data 1.2.3.4,5.6.7.8
# Record Set 수정
nhn dns recordset update <recordset-id> --zone-id <zone-id> \
--ttl 600 \
--data 1.2.3.4
# Record Set 삭제
nhn dns recordset delete <recordset-id> --zone-id <zone-id>
실전 예제
예제 1: 기본 인프라 구성
VPC, 서브넷, 보안 그룹을 생성하고 인스턴스를 배포하는 전체 과정:
# 1. VPC 생성
nhn vpc create --name my-vpc --cidr 192.168.0.0/16
# 2. 서브넷 생성
nhn vpc subnet create \
--vpc-id <vpc-id> \
--name public-subnet \
--cidr 192.168.1.0/24
# 3. 보안 그룹 생성 및 규칙 추가
nhn vpc securitygroup create --name web-sg
nhn vpc securitygroup add-rule <sg-id> \
--direction ingress --protocol tcp --port 22 --remote-ip 0.0.0.0/0
nhn vpc securitygroup add-rule <sg-id> \
--direction ingress --protocol tcp --port 80 --remote-ip 0.0.0.0/0
# 4. 키페어 생성
nhn compute keypair create --name my-keypair > my-keypair.pem
chmod 400 my-keypair.pem
# 5. 인스턴스 생성
nhn compute instance create \
--name web-server \
--image-id <image-id> \
--flavor-id <flavor-id> \
--network-id <network-id> \
--key-name my-keypair \
--security-group web-sg
# 6. 플로팅 IP 생성 및 연결
nhn vpc floatingip create
nhn vpc floatingip associate <floatingip-id> --instance-id <instance-id># 7. SSH 접속
ssh -i my-keypair.pem centos@<floating-ip>
예제 2: 다중 환경 관리
# 개발 환경 설정
nhn configure --profile dev
nhn --profile dev compute instance list
# 운영 환경 설정
nhn configure --profile prod
nhn --profile prod compute instance list
# 스크립트에서 사용forenvin dev staging prod;doecho"=== $env 환경 인스턴스 ==="
nhn --profile $env compute instance list
done
예제 3: JSON 출력과 jq 활용
# 모든 인스턴스의 이름과 IP 추출
nhn --output json compute instance list | \
jq '.[] | {name: .name, ip: .addresses[].addr}'# 실행 중인 인스턴스만 필터링
nhn --output json compute instance list | \
jq '.[] | select(.status == "ACTIVE")'# VPC별 서브넷 개수
nhn --output json vpc list | \
jq '.[] | {name: .name, subnet_count: (.subnets | length)}'