

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# AWS CLI를 사용하여 시작하기
<a name="getting-started-cli"></a>

 AWS Command Line Interface(AWS CLI)를 사용하여 CodeArtifact를 시작하려면 다음 단계를 실행합니다. 자세한 내용은 [설치 또는 업그레이드 후 구성 AWS CLI](get-set-up-install-cli.md) 섹션을 참조하세요. 이 안내서는 `npm` 패키지 관리자를 사용합니다. 다른 패키지 관리자를 사용하는 경우 다음 단계 중 일부를 수정해야 합니다.

1.  AWS CLI를 사용하여 **create-domain** 명령을 실행합니다.

   ```
   aws codeartifact create-domain --domain my-domain
   ```

    JSON 형식의 데이터는 새 도메인에 관한 세부 정보와 함께 출력에 표시됩니다.

   ```
   {
       "domain": {
           "name": "my-domain",
           "owner": "111122223333",
           "arn": "arn:aws:codeartifact:us-west-2:111122223333:domain/my-domain",
           "status": "Active",
           "createdTime": "2020-10-07T15:36:35.194000-04:00",
           "encryptionKey": "arn:aws:kms:us-west-2:111122223333:key/your-kms-key",
           "repositoryCount": 0,
           "assetSizeBytes": 0
       }
   }
   ```

   `Could not connect to the endpoint URL` 오류가 표시되는 경우 AWS CLI가 구성되어 있고 **기본 지역 이름**이 리포지토리를 생성한 리전과 동일한 리전으로 설정되어 있는지 확인합니다. [AWS Command Line Interface 구성](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)을 참조합니다.

1.  **create-repository** 명령을 사용하여 도메인에 리포지토리를 생성합니다.

   ```
   aws codeartifact create-repository --domain my-domain --domain-owner 111122223333 --repository my-repo
   ```

    JSON 형식의 데이터는 새 리포지토리에 관한 세부 정보와 함께 출력에 표시됩니다.

   ```
   {
       "repository": {
           "name": "my-repo",
           "administratorAccount": "111122223333",
           "domainName": "my-domain",
           "domainOwner": "111122223333",
           "arn": "arn:aws:codeartifact:us-west-2:111122223333:repository/my-domain/my-repo",
           "upstreams": [],
           "externalConnections": []
       }
   }
   ```

1. **create-repository** 명령을 실행하여 `my-repo` 리포지토리의 업스트림 리포지토리를 생성합니다.

   ```
   aws codeartifact create-repository --domain my-domain --domain-owner 111122223333 --repository npm-store
   ```

    JSON 형식의 데이터는 새 리포지토리에 관한 세부 정보와 함께 출력에 표시됩니다.

   ```
   {
       "repository": {
           "name": "npm-store",
           "administratorAccount": "111122223333",
           "domainName": "my-domain",
           "domainOwner": "111122223333",
           "arn": "arn:aws:codeartifact:us-west-2:111122223333:repository/my-domain/npm-store",
           "upstreams": [],
           "externalConnections": []
       }
   }
   ```

1.  **associate-external-connection** 명령을 사용하여 npm 퍼블릭 리포지토리에 대한 외부 연결을 `npm-store` 리포지토리에 추가합니다.

   ```
   aws codeartifact associate-external-connection --domain my-domain --domain-owner 111122223333 --repository npm-store --external-connection "public:npmjs"
   ```

    JSON 형식의 데이터는 리포지토리와 그것의 새 외부 연결에 관한 세부 정보와 함께 출력 화면에 표시됩니다.

   ```
   {
       "repository": {
           "name": "npm-store",
           "administratorAccount": "111122223333",
           "domainName": "my-domain",
           "domainOwner": "111122223333",
           "arn": "arn:aws:codeartifact:us-west-2:111122223333:repository/my-domain/npm-store",
           "upstreams": [],
           "externalConnections": [
               {
                   "externalConnectionName": "public:npmjs",
                   "packageFormat": "npm",
                   "status": "AVAILABLE"
               }
           ]
       }
   }
   ```

    자세한 내용은 [CodeArtifact 저장소를 공용 저장소에 연결하기](external-connection.md) 섹션을 참조하세요.

1.  **update-repository** 명령을 사용하여 `npm-store` 리포지토리를 `my-repo` 리포지토리에 대한 업스트림 리포지토리로 연결합니다.

   ```
   aws codeartifact update-repository --repository my-repo --domain my-domain --domain-owner 111122223333 --upstreams repositoryName=npm-store
   ```

    JSON 형식의 데이터는 새 업스트림 리포지토리를 포함해 업데이트된 리포지토리에 관한 세부 정보와 함께 출력 화면에 표시됩니다.

   ```
   {
       "repository": {
           "name": "my-repo",
           "administratorAccount": "111122223333",
           "domainName": "my-domain",
           "domainOwner": "111122223333",
           "arn": "arn:aws:codeartifact:us-west-2:111122223333:repository/my-domain/my-repo",
           "upstreams": [
               {
                   "repositoryName": "npm-store"
               }
           ],
           "externalConnections": []
       }
   }
   ```

    자세한 내용은 [업스트림 리포지토리 추가 또는 제거(AWS CLI)](repo-upstream-add.md#repo-upstream-add-cli) 섹션을 참조하세요.

1. **login** 명령을 실행하여 `my-repo` 리포지토리와 함께 npm 패키지 관리자를 구성합니다.

   ```
   aws codeartifact login --tool npm --repository my-repo --domain my-domain --domain-owner 111122223333
   ```

   로그인이 성공했음을 확인하는 출력 화면이 표시될 것입니다.

   ```
   Successfully configured npm to use AWS CodeArtifact repository https://my-domain-111122223333.d.codeartifact.us-east-2.amazonaws.com/npm/my-repo/
   Login expires in 12 hours at 2020-10-08 02:45:33-04:00
   ```

    자세한 내용은 [CodeArtifact로 npm 구성 및 사용](npm-auth.md) 섹션을 참조하세요.

1.  npm CLI를 사용하여 npm 패키지를 설치합니다. 예를 들어, 인기 있는 npm 패키지 `lodash`를 설치하려면 다음 명령을 실행합니다.

   ```
   npm install lodash
   ```

1.  **list-packages** 명령을 실행하면 `my-repo` 리포지토리에 방금 설치한 패키지를 볼 수 있습니다.
**참고**  
`npm install` 설치 명령이 완료되는 시점과 패키지가 리포지토리에 표시되는 시점 간에 지연이 발생할 수 있습니다. 퍼블릭 리포지토리에서 패키지를 가져올 때 일반적인 지연 시간에 관한 자세한 내용은 [외부 연결 지연 시간](external-connection-requesting-packages.md#external-connection-latency)를 참조하세요.

   ```
   aws codeartifact list-packages --domain my-domain --repository my-repo
   ```

    JSON 형식의 데이터는 설치한 패키지의 형식 및 이름과 함께 출력 화면에 표시됩니다.

   ```
   {
       "packages": [
           {
               "format": "npm",
               "package": "lodash"
           }
       ]
   }
   ```

   이제 다음과 같이 세 개의 CodeArtifact 리소스가 있습니다.
   +  도메인 `my-domain`.
   +  `my-domain`에 포함된 `my-repo`라는 이름의 리포지토리. 이 리포지토리에는 npm 패키지가 있습니다.
   +  `my-domain`에 포함된 `npm-store`라는 이름의 리포지토리. 이 리포지토리는 퍼블릭 npm 리포지토리에 대한 외부 연결이 있으며 업스트림 리포지토리로서 `my-repo` 리포지토리와 연결되어 있습니다.

1. 추가 AWS 요금이 부과되지 않도록 하려면 이 자습서에서 사용한 리소스를 삭제하세요.
**참고**  
 리포지토리가 포함된 도메인은 삭제할 수 없으므로 `my-domain`을 삭제하기 전에 먼저 `my-repo`와 `npm-store`를 삭제해야 합니다.

   1.  `npm-store` 리포지토리를 삭제하려면 **delete-repository** 명령을 사용합니다.

      ```
      aws codeartifact delete-repository --domain my-domain --domain-owner 111122223333 --repository my-repo
      ```

       JSON 형식의 데이터는 삭제된 리포지토리에 관한 세부 정보와 함께 출력 화면에 표시됩니다.

      ```
      {
          "repository": {
              "name": "my-repo",
              "administratorAccount": "111122223333",
              "domainName": "my-domain",
              "domainOwner": "111122223333",
              "arn": "arn:aws:codeartifact:us-west-2:111122223333:repository/my-domain/my-repo",
              "upstreams": [
                  {
                      "repositoryName": "npm-store"
                  }
              ],
              "externalConnections": []
          }
      }
      ```

   1.  `npm-store` 리포지토리를 삭제하려면 **delete-repository** 명령을 사용합니다.

      ```
      aws codeartifact delete-repository --domain my-domain --domain-owner 111122223333 --repository npm-store
      ```

       JSON 형식의 데이터는 삭제된 리포지토리에 관한 세부 정보와 함께 출력 화면에 표시됩니다.

      ```
      {
          "repository": {
              "name": "npm-store",
              "administratorAccount": "111122223333",
              "domainName": "my-domain",
              "domainOwner": "111122223333",
              "arn": "arn:aws:codeartifact:us-west-2:111122223333:repository/my-domain/npm-store",
              "upstreams": [],
              "externalConnections": [
                  {
                      "externalConnectionName": "public:npmjs",
                      "packageFormat": "npm",
                      "status": "AVAILABLE"
                  }
              ]
          }
      }
      ```

   1. `my-domain` 리포지토리를 삭제하려면 **delete-domain** 명령을 사용합니다.

      ```
      aws codeartifact delete-domain --domain my-domain --domain-owner 111122223333
      ```

       JSON 형식의 데이터는 삭제된 도메인에 관한 세부 정보와 함께 출력 화면에 표시됩니다.

      ```
      {
          "domain": {
              "name": "my-domain",
              "owner": "111122223333",
              "arn": "arn:aws:codeartifact:us-west-2:111122223333:domain/my-domain",
              "status": "Deleted",
              "createdTime": "2020-10-07T15:36:35.194000-04:00",
              "encryptionKey": "arn:aws:kms:us-west-2:111122223333:key/your-kms-key",
              "repositoryCount": 0,
              "assetSizeBytes": 0
          }
      }
      ```