

# AWS CLI를 사용한 Amazon Cognito ID 예제
<a name="cli_cognito-identity_code_examples"></a>

다음 코드 예제에서는 Amazon Cognito 자격 증명에서 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여 줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

### `create-identity-pool`
<a name="cognito-identity_CreateIdentityPool_cli_topic"></a>

다음 코드 예시는 `create-identity-pool`의 사용 방법을 보여줍니다.

**AWS CLI**  
**Cognito ID 풀 공급자를 사용하여 자격 증명 풀 생성**  
이 예시에서는 MyIdentityPool이라는 ID 풀을 생성합니다. Cognito ID 풀 공급자가 있습니다. 인증되지 않은 자격 증명은 허용되지 않습니다.  
명령:  

```
aws cognito-identity create-identity-pool --identity-pool-name MyIdentityPool --no-allow-unauthenticated-identities --cognito-identity-providers ProviderName="cognito-idp.us-west-2.amazonaws.com/us-west-2_aaaaaaaaa",ClientId="3n4b5urk1ft4fl3mg5e62d9ado",ServerSideTokenCheck=false
```
출력:  

```
{
  "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
  "IdentityPoolName": "MyIdentityPool",
  "AllowUnauthenticatedIdentities": false,
  "CognitoIdentityProviders": [
      {
          "ProviderName": "cognito-idp.us-west-2.amazonaws.com/us-west-2_111111111",
          "ClientId": "3n4b5urk1ft4fl3mg5e62d9ado",
          "ServerSideTokenCheck": false
      }
  ]
}
```
+  API 세부 정보는 **AWS CLI 명령 참조의 [CreateIdentityPool](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/create-identity-pool.html)을 참조합니다.

### `delete-identities`
<a name="cognito-identity_DeleteIdentities_cli_topic"></a>

다음 코드 예시는 `delete-identities`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀 삭제**  
이 예제에서는 ID 풀을 삭제합니다.  
명령:  

```
aws cognito-identity delete-identity-pool --identity-ids-to-delete "us-west-2:11111111-1111-1111-1111-111111111111"
```
출력:  

```
{
  "UnprocessedIdentityIds": []
}
```
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteIdentities](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/delete-identities.html)를 참조하세요.

### `delete-identity-pool`
<a name="cognito-identity_DeleteIdentityPool_cli_topic"></a>

다음 코드 예시는 `delete-identity-pool`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀 삭제**  
다음 `delete-identity-pool` 예시에서는 지정된 ID 풀을 삭제합니다.  
명령:  

```
aws cognito-identity delete-identity-pool \
    --identity-pool-id "us-west-2:11111111-1111-1111-1111-111111111111"
```
이 명령은 출력을 생성하지 않습니다.  
+  API 세부 정보는 **AWS CLI 명령 참조에서 [DeleteIdentityPool](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/delete-identity-pool.html)을 참조하세요.

### `describe-identity-pool`
<a name="cognito-identity_DescribeIdentityPool_cli_topic"></a>

다음 코드 예시는 `describe-identity-pool`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀을 설명하는 방법**  
이 예제에서는 ID 풀을 설명합니다.  
명령:  

```
aws cognito-identity describe-identity-pool --identity-pool-id "us-west-2:11111111-1111-1111-1111-111111111111"
```
출력:  

```
{
  "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
  "IdentityPoolName": "MyIdentityPool",
  "AllowUnauthenticatedIdentities": false,
  "CognitoIdentityProviders": [
      {
          "ProviderName": "cognito-idp.us-west-2.amazonaws.com/us-west-2_111111111",
          "ClientId": "3n4b5urk1ft4fl3mg5e62d9ado",
          "ServerSideTokenCheck": false
      }
  ]
}
```
+  API 세부 정보는 **AWS CLI 명령 참조의 [DescribeIdentityPool](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/describe-identity-pool.html) 섹션을 참조하세요.

### `get-identity-pool-roles`
<a name="cognito-identity_GetIdentityPoolRoles_cli_topic"></a>

다음 코드 예시는 `get-identity-pool-roles`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀 역할을 가져오는 방법**  
이 예제에서는 ID 풀이 나열되어 있습니다.  
명령:  

```
aws cognito-identity get-identity-pool-roles --identity-pool-id "us-west-2:11111111-1111-1111-1111-111111111111"
```
출력:  

```
{
  "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
  "Roles": {
      "authenticated": "arn:aws:iam::111111111111:role/Cognito_MyIdentityPoolAuth_Role",
      "unauthenticated": "arn:aws:iam::111111111111:role/Cognito_MyIdentityPoolUnauth_Role"
  }
}
```
+  API 세부 정보는 **AWS CLI 명령 참조의 [GetIdentityPoolRoles](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/get-identity-pool-roles.html) 섹션을 참조하세요.

### `list-identity-pools`
<a name="cognito-identity_ListIdentityPools_cli_topic"></a>

다음 코드 예시는 `list-identity-pools`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀 나열**  
이 예시에는 ID 풀이 나열되어 있습니다. 최대 20개의 자격 증명이 나열되어 있습니다.  
명령:  

```
aws cognito-identity list-identity-pools --max-results 20
```
출력:  

```
{
  "IdentityPools": [
      {
          "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
          "IdentityPoolName": "MyIdentityPool"
      },
      {
          "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
          "IdentityPoolName": "AnotherIdentityPool"
      },
      {
          "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
          "IdentityPoolName": "IdentityPoolRegionA"
      }
  ]
}
```
+  API 세부 정보는 **AWS CLI 명령 참조의 [ListIdentityPools](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/list-identity-pools.html) 섹션을 참조하세요.

### `set-identity-pool-roles`
<a name="cognito-identity_SetIdentityPoolRoles_cli_topic"></a>

다음 코드 예시는 `set-identity-pool-roles`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀 역할을 설정하는 방법**  
다음 `set-identity-pool-roles` 예제에서는 ID 풀의 역할을 설정합니다.  

```
aws cognito-identity set-identity-pool-roles \
    --identity-pool-id "us-west-2:11111111-1111-1111-1111-111111111111" \
    --roles authenticated="arn:aws:iam::111111111111:role/Cognito_MyIdentityPoolAuth_Role"
```
+  API 세부 정보는 *AWS CLI 명령 참조*의 [SetIdentityPoolRoles](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/set-identity-pool-roles.html) 섹션을 참조하세요.

### `update-identity-pool`
<a name="cognito-identity_UpdateIdentityPool_cli_topic"></a>

다음 코드 예시는 `update-identity-pool`의 사용 방법을 보여줍니다.

**AWS CLI**  
**ID 풀을 생성하는 방법**  
이 예제에서는 ID 풀을 업데이트합니다. 이름을 MyIdentityPool로 설정합니다. 자격 증명 공급자로 Cognito를 추가합니다. 인증되지 않은 자격 증명은 허용되지 않습니다.  
명령:  

```
aws cognito-identity update-identity-pool --identity-pool-id "us-west-2:11111111-1111-1111-1111-111111111111" --identity-pool-name "MyIdentityPool" --no-allow-unauthenticated-identities --cognito-identity-providers ProviderName="cognito-idp.us-west-2.amazonaws.com/us-west-2_111111111",ClientId="3n4b5urk1ft4fl3mg5e62d9ado",ServerSideTokenCheck=false
```
출력:  

```
{
  "IdentityPoolId": "us-west-2:11111111-1111-1111-1111-111111111111",
  "IdentityPoolName": "MyIdentityPool",
  "AllowUnauthenticatedIdentities": false,
  "CognitoIdentityProviders": [
      {
          "ProviderName": "cognito-idp.us-west-2.amazonaws.com/us-west-2_111111111",
          "ClientId": "3n4b5urk1ft4fl3mg5e62d9ado",
          "ServerSideTokenCheck": false
      }
  ]
}
```
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateIdentityPool](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-identity/update-identity-pool.html) 섹션을 참조하세요.