본문으로 건너뛰기

Alibaba CLI 설정

약 6 분alibabaaliyun

Alibaba CLI 설정

1. CLI 설치

1.1 Download 방식

1.2 MAC - brew 설치

2. 구성 설정

인증 메커니즘이 4가지이며 구성 설정시 --mode 에 Credential type을 넣어서 구성하게 됨

Credential typeLimitInteractive credential configuration (fast)Non-interactive credential configuration
AKUse an AccessKey ID and an AccessKey secret to authorize access.Configure AccessKey credentialopen in new windowConfigure AccessKey credentialopen in new window
StsTokenUse a Security Token Service (STS) token to authorize access.Configure STS token credentialopen in new windowConfigure STS token credentialopen in new window
RamRoleArnUse the role of a Resource Access Management (RAM) user to authorize access.Configure RamRoleArn credentialopen in new windowConfigure RamRoleArn credentialopen in new window
EcsRamRoleUse the RAM role of an Elastic Compute Service (ECS) instance to authorize password-free access.Configure EcsRamRole credentialopen in new windowConfigure EcsRamRole credentialopen in new window

2.1 AK 생성

AccessKey 방식의 인증 정보가 없는 경우 아래와 같이 생성

  • Alibaba Cloud 홈페이지의 우측 상단(변경될 수 있음) 클릭하여 Accesskey Management 클릭
  • AccessKey Pair 항목에서 Create AccessKey Pair 를 클릭하여 AK(AccessKey)를 신규로 생성

2.2 CLI 구성

aliyun cli의 configure 를 실행

  • --mode 에는 Credential Type을 지정
  • --profile 에는 사용할 이름을 사용자가 지정, default는 기본 값
$ aliyun configure --mode AK --profile myprofile
Configuring profile 'myprofile' in 'AK' authenticate mode...
Access Key Id []: LTAI5**********************t88V
Access Key Secret []: *******************************
Default Region Id []: ap-southeast-1
Default Output Format [json]: json (Only support json)
Default Language [zh|en] en: en
Saving profile[gslee] ...Done.

Configure Done!!!

구성 완료 후 home 디렉토리의 .aliyun 디렉토리 내의 config.json에서 구성된 정보를 확인 가능

{
    "current": "myprofile",
    "profiles": [
        {
            "name": "default",
        },
        {
            "name": "gslee",
            "mode": "AK",
            "access_key_id": "LTAI5**********************t88V",
            "region_id": "ap-southeast-1",
            "output_format": "json",
            "language": "en",
        }
    ],
    "meta_path": ""
}

2.3 CLI 사용 예제

Region 목록 확인

profile이 default인 경우 --profile or -p 생략 가능

$ aliyun -p myprofile ecs DescribeRegions 
{
    "Regions": {
        "Region": [
            {
                "LocalName": "华北1(青岛)",
                "RegionEndpoint": "ecs.aliyuncs.com",
                "RegionId": "cn-qingdao"
            },
            {
                "LocalName": "华北2(北京)",
                "RegionEndpoint": "ecs.aliyuncs.com",
                "RegionId": "cn-beijing"
            },
        ]
    },
    "RequestId": "2304DF19-CABF-54DF-BDC6-F889C3A73E4F"
}