IBM Cloud Shell에서 AWS CLI를 사용하여 IBM Cloud Object Storage에 액세스해 보기

개요



IBM Cloud Shell에서 AWS CLI를 사용하여 IBM Cloud Object Storage에 액세스하는 절차를 설명합니다.

전제



IBM Cloud Object Storage 서비스 인스턴스가 작성되었음

절차 개요


  • IBM Cloud Shell 시작
  • IBM Cloud Object Storage 버킷 작성
  • AWS CLI를 IBM Cloud Shell에 설치
  • 서비스 키 만들기
  • AWS CLI에서 IBM Cloud Object Storage에 액세스

  • 1. IBM Cloud 쉘 시작



    IBM Cloud 콘솔의 오른쪽 상단에 있는 IBM Cloud Shell 아이콘을 클릭하여 시작하십시오.



    2. IBM Cloud Object Storage 버킷 작성



    IBM Cloud CLI를 사용하여 버킷을 작성합니다.

    서비스 인스턴스를 나열합니다.
    TSOTA@cloudshell:~$ ibmcloud resource service-instances
    Retrieving instances with type service_instance in all resource groups in all locations under account ...
    OK
    Name                              Location   State    Type   
    ・・・  
    Cloud Object Storage-lo           global     active   service_instance   
    ・・・
    

    서비스 인스턴스 세부정보 검토(CRN 확인)
    TSOTA@cloudshell:~$ ibmcloud resource service-instance "Cloud Object Storage-lo"
    Retrieving service instance Cloud Object Storage-lo in all resource groups under account ...
    OK
    
    Name:                  Cloud Object Storage-lo   
    ID:                    crn:v1:bluemix:public:cloud-object-storage:global:a/xxx:xxx::   
    GUID:                  xxxxx   
    Location:              global   
    Service Name:          cloud-object-storage   
    Service Plan Name:     lite   
    Resource Group Name:   Default   
    State:                 active   
    Type:                  service_instance   
    Sub Type:                 
    Created at:            2020-10-13T07:08:17Z   
    Created by:            xxxxxxx   
    Updated at:            2020-10-13T07:08:17Z   
    Last Operation:                        
                           Status    create succeeded      
                           Message   Completed create instance operation      
    

    CRN 설정
    TSOTA@cloudshell:~$ ibmcloud cos config crn
    Resource Instance ID CRN:  ()> crn:v1:bluemix:public:cloud-object-storage:global:a/xxx:xxx:: 
    Saving new Service Instance ID...
    OK
    Successfully stored your service instance ID.
    

    버킷 만들기(CrossRegion 버킷 만들기)
    TSOTA@cloudshell:~$ ibmcloud cos bucket-create --bucket tsota-bucket --region ap
    OK
    Details about bucket tsota-bucket:
    Region: ap
    Class: Standard
    TSOTA@cloudshell:~$ ibmcloud cos buckets-extended
    OK
    Found 7 buckets:
    
    Name                                              Location Constraint   Creation Date   
    tsota-bucket                                      ap-standard           Dec 08, 2020 at 15:44:36   
    

    3. AWS CLI를 IBM Cloud Shell에 설치



    참고: Linux에서 AWS CLI 버전 2 설치
    htps : // / cs. 아 ws. 아마존. 이 m/그럼_jp/cぃ/ぁてst/うせrぐいで/いんsたっlcぃv2-ぃぬx. HTML # c ぃ v2 ぃ ん x

    AWS_CLI 설치 (sudo를 실행할 수 없으므로 홈 디렉토리 아래에 배포)
    TSOTA@cloudshell:~$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    TSOTA@cloudshell:~$ unzip awscliv2.zip
    TSOTA@cloudshell:~$ ./aws/install -i ~/aws-cli -b ~/bin
    You can now run: /home/TSOTA/bin/aws --version
    TSOTA@cloudshell:~$ /home/TSOTA/bin/aws --version
    aws-cli/2.1.7 Python/3.7.3 Linux/5.9.8 exe/x86_64.ubuntu.18 prompt/off
    

    4. 서비스 키 생성



    AWS CLI에서 액세스할 수 있는 서비스 키를 생성합니다.
    HMAC 자격 증명으로 작성합니다.
    참고 : htps : // c ぉ d. 이 bm. 이 m/도 cs/cぉ우 d오 b지ぇctss 가시/h마 c? 토피 c = c ぉ u d b b ぇ c t s touge-h ma c

    서비스 키를 만듭니다.
    TSOTA@cloudshell:~$ ibmcloud resource service-key-create tsota-test-key Manager --instance-name "Cloud Object Storage-lo" --parameters '{"HMAC":true}'
    Creating service key of service instance Cloud Object Storage-lo under account ...
    OK
    Service key crn:v1:bluemix:public:cloud-object-storage:global:a/xxx:xxx:resource-key:xxx was created.
    
    Name:          tsota-test-key   
    ID:            crn:v1:bluemix:public:cloud-object-storage:global:a/xxx:xxx:resource-key:xxx   
    Created At:    Tue Dec  8 16:13:52 UTC 2020   
    State:         active   
    Credentials:                                   
                   apikey:                   xxx     
                   cos_hmac_keys:                                          
                                             access_key_id:       xxx        
                                             secret_access_key:   xxx         
    
                   endpoints:                https://control.cloud-object-storage.cloud.ibm.com/v2/endpoints      
                   iam_apikey_description:   Auto-generated for key xxx      
                   iam_apikey_name:          tsota-test-key      
                   iam_role_crn:             crn:v1:bluemix:public:iam::::serviceRole:Manager      
                   iam_serviceid_crn:        crn:v1:bluemix:public:iam-identity::a/xxx::serviceid:ServiceId-xxx      
                   resource_instance_id:     crn:v1:bluemix:public:cloud-object-storage:global:a/xxx:xxx::      
    

    5. AWS CLI에서 IBM Cloud Object Storage에 액세스



    이전 단계에서 만든 액세스 키를 설정합니다.

    액세스 키 설정
    TSOTA@cloudshell:~$ bin/aws configure
    AWS Access Key ID [None]: xxx
    AWS Secret Access Key [None]: xxx
    Default region name [None]: ap
    Default output format [None]: json
    TSOTA@cloudshell:~$ 
    

    버킷 목록
    TSOTA@cloudshell:~$ bin/aws --endpoint-url https://s3.ap.cloud-object-storage.appdomain.cloud s3 ls
    2020-12-08 15:44:36 tsota-bucket
    

    버킷 내부 확인
    TSOTA@cloudshell:~$ bin/aws --endpoint-url https://s3.ap.cloud-object-storage.appdomain.cloud s3 ls tsota-bucket/
    TSOTA@cloudshell:~$
    

    파일 업로드
    TSOTA@cloudshell:~$ echo test > test.txt
    TSOTA@cloudshell:~$ bin/aws --endpoint-url https://s3.ap.cloud-object-storage.appdomain.cloud s3 cp test.txt s3://tsota-bucket
    upload: ./test.txt to s3://tsota-bucket/test.txt    
    

    버킷 내부 확인
    TSOTA@cloudshell:~$ bin/aws --endpoint-url https://s3.ap.cloud-object-storage.appdomain.cloud s3 ls tsota-bucket/
    2020-12-08 16:18:55          5 test.txt
    TSOTA@cloudshell:~$ 
    

    좋은 웹페이지 즐겨찾기