

# 연습을 위한 도구 설정
<a name="policy-eval-walkthrough-download-awscli"></a>

이 소개 예제는 ([정책을 사용하여 Amazon S3 리소스에 대한 액세스를 관리하는 연습](example-walkthroughs-managing-access.md) 참조) AWS Management Console을 사용하여 리소스를 만들고 권한을 부여합니다. 예시에서는 권한을 테스트하기 위해 명령줄 도구인 AWS Command Line Interface(AWS CLI) 및 AWS Tools for Windows PowerShell을 사용하므로 직접 코드를 작성할 필요가 없습니다. 권한을 테스트하려면 이러한 도구 중 하나를 설정해야 합니다.

**AWS CLI 설정**

1. AWS CLI를 다운로드하고 구성합니다. 관련 지침은 *AWS Command Line Interface 사용 설명서*에서 다음 토픽을 참조하세요.

    [최신 AWS Command Line Interface 버전의 설치 또는 업데이트](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html) 

    [ 시작AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) 

1. 기본 프로필을 설정합니다.

   AWS CLI 구성 파일에 사용자 자격 증명을 저장합니다. AWS 계정 자격 증명을 사용하여 구성 파일에 기본 프로파일을 만듭니다. AWS CLI 구성 파일을 찾고 편집하는 방법에 대한 지침은 [구성 및 자격 증명 파일 설정](https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html)을 참조하세요.

   ```
   [default]
   aws_access_key_id = access key ID
   aws_secret_access_key = secret access key
   region = us-west-2
   ```

1. 명령 프롬프트에 다음 명령을 입력하여 설정을 확인합니다. 이들 명령은 명시적으로 자격 증명을 제공하지 않으므로 기본 프로필의 자격 증명이 사용됩니다.
   + `help` 명령을 사용해 봅니다.

     ```
     aws help
     ```
   + `aws s3 ls` 명령을 사용하여 구성된 계정의 버킷 목록을 가져옵니다.

     ```
     aws s3 ls
     ```

연습을 진행하면서 다음 예시와 같이 사용자를 만들고, 프로파일을 생성하여 구성 파일에 사용자 자격 증명을 저장합니다. 이러한 프로파일의 이름은 `AccountAadmin` 및 `AccountBadmin`입니다.

```
[profile AccountAadmin]
aws_access_key_id = User AccountAadmin access key ID
aws_secret_access_key = User AccountAadmin secret access key
region = us-west-2

[profile AccountBadmin]
aws_access_key_id = Account B access key ID
aws_secret_access_key = Account B secret access key
region = us-east-1
```

이러한 사용자 자격 증명을 사용하여 명령을 실행하기 위해 프로필 이름을 지정하는 `--profile` 파라미터를 추가합니다. 다음 AWS CLI 명령은 *`examplebucket`*의 객체 목록을 검색하고 `AccountBadmin` 프로파일을 지정합니다.

```
aws s3 ls s3://examplebucket --profile AccountBadmin
```

또는 명령 프롬프트에서 `AWS_DEFAULT_PROFILE` 환경 변수를 변경하여 사용자 자격 증명 중 한 세트를 기본 프로필로 구성할 수 있습니다. 이렇게 하고 나면 `--profile` 파라미터 없이 AWS CLI 명령을 실행할 때마다 AWS CLI에서는 환경 변수에 설정된 프로파일을 기본 프로파일로 사용합니다.

```
$ export AWS_DEFAULT_PROFILE=AccountAadmin
```

**AWS Tools for Windows PowerShell 설정**

1. AWS Tools for Windows PowerShell를 다운로드하고 구성합니다. 지침은 AWS Tools for PowerShell 사용 설명서**의 [AWS Tools for Windows PowerShell 설치](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html#pstools-installing-download)를 참조하세요.
**참고**  
AWS Tools for Windows PowerShell 모듈을 로드하려면 PowerShell 스크립트 실행을 활성화해야 합니다. 자세한 내용은 AWS Tools for PowerShell 사용 설명서**의 [스크립트 실행 활성화](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html#enable-script-execution)를 참조하세요.

1. 이 연습에서는 `Set-AWSCredentials` 명령을 사용하여 세션별로 AWS 자격 증명을 지정합니다. 이 명령은 영구 저장소에 자격 증명을 저장합니다(`-StoreAs `파라미터).

   ```
   Set-AWSCredentials -AccessKey AccessKeyID -SecretKey SecretAccessKey -storeas string
   ```

1. 설정을 확인합니다.
   + `Get-Command` 명령을 실행하여 Amazon S3 작업에서 사용할 수 있는 명령 목록을 검색합니다.

     ```
     Get-Command -module awspowershell -noun s3* -StoredCredentials string
     ```
   + `Get-S3Object` 명령을 실행하여 버킷의 객체 목록을 검색합니다.

     ```
     Get-S3Object -BucketName bucketname -StoredCredentials string
     ```

명령 목록은 [AWS Tools for PowerShell Cmdlet 참조](https://docs.aws.amazon.com/powershell/latest/reference/Index.html)를 참조하세요.

이제 연습 준비가 되었습니다. 각 섹션 시작 부분에 있는 링크를 따라 가세요.