

# AWS CLI를 사용하여 Verified Permissions 예시
<a name="cli_verifiedpermissions_code_examples"></a>

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

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

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

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

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

### `create-identity-source`
<a name="verifiedpermissions_CreateIdentitySource_cli_topic"></a>

다음 코드 예시에서는 `create-identity-source` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**자격 증명 소스를 생성하는 방법**  
다음 `create-identity-source` 예시에서는 지정된 Amazon Cognito 사용자 풀에 저장된 자격 증명을 참조할 수 있는 자격 증명 소스를 생성합니다. 이러한 자격 증명은 Verified Permissions에서 유형의 엔터티로 사용할 수 있습니다`User`.  

```
aws verifiedpermissions create-identity-source \
    --configuration file://config.txt \
    --principal-entity-type "User" \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`config.txt`의 콘텐츠:  

```
{
    "cognitoUserPoolConfiguration": {
        "userPoolArn": "arn:aws:cognito-idp:us-west-2:123456789012:userpool/us-west-2_1a2b3c4d5",
        "clientIds":["a1b2c3d4e5f6g7h8i9j0kalbmc"]
    }
}
```
출력:  

```
{
    "createdDate": "2023-05-19T20:30:28.214829+00:00",
    "identitySourceId": "ISEXAMPLEabcdefg111111",
    "lastUpdatedDate": "2023-05-19T20:30:28.214829+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111"
}
```
ID 소스에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CreateIdentitySource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/create-identity-source.html)를 참조하세요.

### `create-policy-store`
<a name="verifiedpermissions_CreatePolicyStore_cli_topic"></a>

다음 코드 예시에서는 `create-policy-store` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 저장소 생성**  
다음 `create-policy-store` 예시에서는 현재 AWS 리전에 정책 저장소를 생성합니다.  

```
aws verifiedpermissions create-policy-store \
    --validation-settings "mode=STRICT"
```
출력:  

```
{
    "arn": "arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg111111",
    "createdDate": "2023-05-16T17:41:29.103459+00:00",
    "lastUpdatedDate": "2023-05-16T17:41:29.103459+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111"
}
```
정책 저장소에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CreatePolicyStore](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/create-policy-store.html)를 참조하세요.

### `create-policy-template`
<a name="verifiedpermissions_CreatePolicyTemplate_cli_topic"></a>

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

**AWS CLI**  
**정책 템플릿을 생성하려면**  
다음 `create-policy-template` 예에서는 위탁자에 대한 자리 표시자가 있는 정책 템플릿을 생성합니다.  

```
aws verifiedpermissions create-policy-template \
    --statement file://template1.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`template1.txt`의 콘텐츠:  

```
permit(
    principal in ?principal,
    action == Action::"view",
    resource == Photo::"VacationPhoto94.jpg"
);
```
출력:  

```
{
    "createdDate": "2023-06-12T20:47:42.804511+00:00",
    "lastUpdatedDate": "2023-06-12T20:47:42.804511+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyTemplateId": "PTEXAMPLEabcdefg111111"
}
```
정책 템플릿에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-templates.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CreatePolicyTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/create-policy-template.html)을 참조하세요.

### `create-policy`
<a name="verifiedpermissions_CreatePolicy_cli_topic"></a>

다음 코드 예시에서는 `create-policy` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**예제 1: 정적 정책 생성**  
다음 `create-policy` 예시에서는 위탁자와 리소스를 모두 지정하는 정책 범위가 있는 정적 정책을 만듭니다.  

```
aws verifiedpermissions create-policy \
    --definition file://definition1.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`definition1.txt` 파일의 콘텐츠:  

```
{
    "static": {
        "description":  "Grant everyone of janeFriends UserGroup access to the vacationFolder Album",
        "statement": "permit(principal in UserGroup::\"janeFriends\", action, resource in Album::\"vacationFolder\" );"
    }
}
```
출력:  

```
{
    "createdDate": "2023-06-12T20:33:37.382907+00:00",
    "lastUpdatedDate": "2023-06-12T20:33:37.382907+00:00",
    "policyId": "SPEXAMPLEabcdefg111111",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyType": "STATIC",
    "principal": {
        "entityId": "janeFriends",
        "entityType": "UserGroup"
    },
    "resource": {
        "entityId": "vacationFolder",
        "entityType": "Album"
    }
}
```
**예시 2: 모든 사용자에게 리소스에 대한 액세스 권한을 부여하는 정적 정책 생성**  
다음 `create-policy` 예시에서는 리소스만 지정하는 정책 범위를 가진 정적 정책을 만듭니다.  

```
aws verifiedpermissions create-policy \
    --definition file://definition2.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`definition2.txt` 파일의 콘텐츠:  

```
{
    "static": {
        "description":  "Grant everyone access to the publicFolder Album",
        "statement": "permit(principal, action, resource in Album::\"publicFolder\");"
    }
}
```
출력:  

```
{
    "createdDate": "2023-06-12T20:39:44.975897+00:00",
    "lastUpdatedDate": "2023-06-12T20:39:44.975897+00:00",
    "policyId": "PbfR73F8oh5MMfr9uRtFDB",
    "policyStoreId": "PSEXAMPLEabcdefg222222",
    "policyType": "STATIC",
    "resource": {
        "entityId": "publicFolder",
        "entityType": "Album"
    }
}
```
**예시 3: 지정된 템플릿과 연결된 템플릿 연결 정책 생성**  
다음 `create-policy` 예시에서는 지정된 정책 템플릿을 사용하여 템플릿 연결 정책을 만들고 사용할 지정된 위탁자를 새 템플릿 연결 정책과 연결합니다.  

```
aws verifiedpermissions create-policy \
    --definition file://definition.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`definition.txt`의 콘텐츠:  

```
{
    "templateLinked": {
        "policyTemplateId": "PTEXAMPLEabcdefg111111",
        "principal": {
            "entityType": "User",
            "entityId": "alice"
        }
    }
}
```
출력:  

```
{
    "createdDate": "2023-06-12T20:49:51.490211+00:00",
    "lastUpdatedDate": "2023-06-12T20:49:51.490211+00:00",
    "policyId": "TPEXAMPLEabcdefg111111",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyType": "TEMPLATE_LINKED",
    "principal": {
        "entityId": "alice",
        "entityType": "User"
    },
    "resource": {
        "entityId": "VacationPhoto94.jpg",
        "entityType": "Photo"
    }
}
```
정책에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [CreatePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/create-policy.html)를 참조하세요.

### `delete-identity-source`
<a name="verifiedpermissions_DeleteIdentitySource_cli_topic"></a>

다음 코드 예시에서는 `delete-identity-source` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**자격 증명 소스 삭제**  
다음 `delete-identity-source` 예시에서는 지정된 ID를 가진 ID 소스를 삭제합니다.  

```
aws verifiedpermissions delete-identity-source \
    --identity-source-id ISEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
이 명령은 출력을 생성하지 않습니다.  
ID 소스에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteIdentitySource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/delete-identity-source.html)를 참조하세요.

### `delete-policy-store`
<a name="verifiedpermissions_DeletePolicyStore_cli_topic"></a>

다음 코드 예시에서는 `delete-policy-store` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 저장소 삭제**  
다음 `delete-policy-store` 예시에서는 지정된 ID를 가진 정책 저장소를 삭제합니다.  

```
aws verifiedpermissions delete-policy-store \
    --policy-store-id PSEXAMPLEabcdefg111111
```
이 명령은 출력을 생성하지 않습니다.  
정책 저장소에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeletePolicyStore](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/delete-policy-store.html)를 참조하세요.

### `delete-policy-template`
<a name="verifiedpermissions_DeletePolicyTemplate_cli_topic"></a>

다음 코드 예시에서는 `delete-policy-template` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 작업 템플릿 삭제**  
다음 `delete-policy-template` 예시에서는 지정된 ID가 있는 정책 템플릿을 삭제합니다.  

```
aws verifiedpermissions delete-policy \
    --policy-template-id PTEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
이 명령은 출력을 생성하지 않습니다.  
정책 템플릿에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-templates.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeletePolicyTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/delete-policy-template.html)을 참조하세요.

### `delete-policy`
<a name="verifiedpermissions_DeletePolicy_cli_topic"></a>

다음 코드 예시에서는 `delete-policy` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정적 또는 템플릿 연결 정책 삭제**  
다음 `delete-policy` 예시에서는 지정된 ID가 있는 정책을 삭제합니다.  

```
aws verifiedpermissions delete-policy \
    --policy-id SPEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
이 명령은 출력을 생성하지 않습니다.  
정책에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [DeletePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/delete-policy.html)를 참조하세요.

### `get-identity-source`
<a name="verifiedpermissions_GetIdentitySource_cli_topic"></a>

다음 코드 예시에서는 `get-identity-source` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**자격 증명 소스에 대한 세부 정보 검색**  
다음 `get-identity-source` 예시에서는 지정된 ID를 가진 ID 소스에 대한 세부 정보를 표시합니다.  

```
aws verifiedpermissions get-identity-source \
    --identity-source  ISEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "createdDate": "2023-06-12T22:27:49.150035+00:00",
    "details": {
        "clientIds": [ "a1b2c3d4e5f6g7h8i9j0kalbmc" ],
        "discoveryUrl": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_1a2b3c4d5",
        "openIdIssuer": "COGNITO",
        "userPoolArn": "arn:aws:cognito-idp:us-west-2:123456789012:userpool/us-west-2_1a2b3c4d5"
    },
    "identitySourceId": "ISEXAMPLEabcdefg111111",
    "lastUpdatedDate": "2023-06-12T22:27:49.150035+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "principalEntityType": "User"
}
```
ID 소스에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetIdentitySource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/get-identity-source.html)를 참조하세요.

### `get-policy-store`
<a name="verifiedpermissions_GetPolicyStore_cli_topic"></a>

다음 코드 예시에서는 `get-policy-store` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 저장소 관련 세부 정보 검색**  
다음 `get-policy-store` 예시에서는 지정된 ID를 가진 정책 저장소에 대한 세부 정보를 표시합니다.  

```
aws verifiedpermissions get-policy-store \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "arn": "arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg111111",
    "createdDate": "2023-06-05T20:16:46.225598+00:00",
    "lastUpdatedDate": "2023-06-08T20:40:23.173691+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "validationSettings": { "mode": "OFF" }
}
```
정책 저장소에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetPolicyStore](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/get-policy-store.html)를 참조하세요.

### `get-policy-template`
<a name="verifiedpermissions_GetPolicyTemplate_cli_topic"></a>

다음 코드 예시에서는 `get-policy-template` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 템플릿에 대한 세부 정보를 검색하는 방법**  
다음 `get-policy-template` 예시에서는 지정된 ID를 가진 정책 템플릿에 대한 세부 정보를 표시합니다.  

```
aws verifiedpermissions get-policy-template \
    --policy-template-id  PTEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "createdDate": "2023-06-12T20:47:42.804511+00:00",
    "lastUpdatedDate": "2023-06-12T20:47:42.804511+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyTemplateId": "PTEXAMPLEabcdefg111111",
    "statement": "permit(\n    principal in ?principal,\n    action == Action::\"view\",\n    resource == Photo::\"VacationPhoto94.jpg\"\n);"
}
```
정책 템플릿에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-templates.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetPolicyTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/get-policy-template.html)을 참조하세요.

### `get-policy`
<a name="verifiedpermissions_GetPolicy_cli_topic"></a>

다음 코드 예시에서는 `get-policy` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 관련 세부 정보 검색**  
다음 `get-policy` 예시에서는 지정된 ID를 가진 정책에 대한 세부 정보를 표시합니다.  

```
aws verifiedpermissions get-policy \
    --policy-id PSEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "createdDate": "2023-06-12T20:33:37.382907+00:00",
    "definition": {
        "static": {
            "description": "Grant everyone of janeFriends UserGroup access to the vacationFolder Album",
            "statement": "permit(principal in UserGroup::\"janeFriends\", action, resource in Album::\"vacationFolder\" );"
        }
    },
    "lastUpdatedDate": "2023-06-12T20:33:37.382907+00:00",
    "policyId": "SPEXAMPLEabcdefg111111",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyType": "STATIC",
    "principal": {
        "entityId": "janeFriends",
        "entityType": "UserGroup"
    },
    "resource": {
        "entityId": "vacationFolder",
        "entityType": "Album"
    }
}
```
정책에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/get-policy.html)를 참조하세요.

### `get-schema`
<a name="verifiedpermissions_GetSchema_cli_topic"></a>

다음 코드 예시에서는 `get-schema` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 저장소에서 스키마 검색**  
다음 `get-schema` 예시에서는 지정된 정책 저장소에 있는 스키마의 세부 정보를 표시합니다.  

```
aws verifiedpermissions get-schema \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "schema": "{\"MySampleNamespace\":{\"entityTypes\":{\"Employee\":{\"shape\":{\"attributes\":{\"jobLevel\":{\"type\":\"Long\"},\"name\":{\"type\":\"String\"}},\"type\":\"Record\"}}},\"actions\":{\"remoteAccess\":{\"appliesTo\":{\"principalTypes\":[\"Employee\"]}}}}}",
    "createdDate": "2023-06-14T17:47:13.999885+00:00",
    "lastUpdatedDate": "2023-06-14T17:47:13.999885+00:00"
}
```
스키마에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [정책 저장소 스키마](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/schema.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetSchema](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/get-schema.html)를 참조하세요.

### `is-authorized-with-token`
<a name="verifiedpermissions_IsAuthorizedWithToken_cli_topic"></a>

다음 코드 예시에서는 `is-authorized-with-token` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**예시 1: 사용자 요청에 대한 권한 부여 결정을 요청하는 방법(허용)**  
다음 `is-authorized-with-token` 예시에서는 Amazon Cognito로 인증된 사용자에 대한 권한 부여 결정을 요청합니다. 요청은 액세스 토큰이 아닌 Cognito에서 제공하는 자격 증명 토큰을 사용합니다. 이 예시에서는 지정된 정보 저장소가 위탁자를 `CognitoUser` 유형의 엔터티로 반환하도록 구성됩니다.  

```
aws verifiedpermissions is-authorized-with-token \
    --action actionId="View",actionType="Action" \
    --resource entityId="vacationPhoto94.jpg",entityType="Photo" \
    --policy-store-id PSEXAMPLEabcdefg111111 \
    --identity-token "AbCdE12345...long.string...54321EdCbA"
```
정책 저장소에는 지정된 Cognito 사용자 풀 및 애플리케이션 Id의 ID를 허용하는 다음 문이 포함된 정책이 포함되어 있습니다.  

```
permit(
    principal == CognitoUser::"us-east-1_1a2b3c4d5|a1b2c3d4e5f6g7h8i9j0kalbmc",
    action,
    resource == Photo::"VacationPhoto94.jpg"
);
```
출력:  

```
{
    "decision":"Allow",
    "determiningPolicies":[
        {
        "determiningPolicyId":"SPEXAMPLEabcdefg111111"
        }
    ],
    "errors":[]
}
```
Cognito 사용자 풀의 ID를 사용하는 방법에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [ID 제공업체와 함께 Amazon Verified Permissions 사용](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [IsAuthorizedWithToken](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/is-authorized-with-token.html)을 참조하세요.

### `is-authorized`
<a name="verifiedpermissions_IsAuthorized_cli_topic"></a>

다음 코드 예시에서는 `is-authorized` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**예시 1: 사용자 요청에 대한 권한 부여 결정을 요청하는 방법(허용)**  
다음 `is-authorized` 예시는 `Photo` 유형의 리소스 `VacationPhoto94.jpg`에 대해 `updatePhoto` 작업을 수행하려는 `User` 유형의 위탁자, `Alice`에 대한 권한 부여 결정을 요청합니다.  
응답은 요청이 하나의 정책에 의해 허용되었음을 보여줍니다.  

```
aws verifiedpermissions is-authorized \
    --principal entityType=User,entityId=alice \
    --action actionType=Action,actionId=view \
    --resource entityType=Photo,entityId=VactionPhoto94.jpg \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "decision": "ALLOW",
    "determiningPolicies": [
        {
            "policyId": "SPEXAMPLEabcdefg111111"
        }
    ],
    "errors": []
}
```
**예시 2: 사용자 요청에 대한 권한 부여 결정을 요청하는 방법(거부)**  
다음 예시에서는 위탁자가 `User::"Bob"`라는 점을 제외하고 이전 예시와 동일합니다. 정책 저장소에 해당 사용자가 `Album::"alice_folder"`에 액세스할 수 있도록 허용하는 정책이 포함되어 있지 않습니다.  
출력은 `DeterminingPolicies` 목록이 비어 있기 때문에 `Deny`가 암시적임을 나타냅니다.  

```
aws verifiedpermissions create-policy \
    --definition file://definition2.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "decision": "DENY",
    "determiningPolicies": [],
    "errors": []
}
```
자세한 내용은 [Amazon Verified Permissions 사용 설명서](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [IsAuthorized](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/is-authorized.html)를 참조하세요.

### `list-identity-sources`
<a name="verifiedpermissions_ListIdentitySources_cli_topic"></a>

다음 코드 예시에서는 `list-identity-sources` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**사용 가능한 자격 증명 소스를 나열하는 방법**  
다음 `list-identity-sources` 예시에서는 지정된 정책 저장소의 모든 자격 증명 소스를 나열합니다.  

```
aws verifiedpermissions list-identity-sources \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "identitySources": [
        {
            "createdDate": "2023-06-12T22:27:49.150035+00:00",
            "details": {
                "clientIds": [ "a1b2c3d4e5f6g7h8i9j0kalbmc" ],
                "discoveryUrl": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_1a2b3c4d5",
                "openIdIssuer": "COGNITO",
                "userPoolArn": "arn:aws:cognito-idp:us-west-2:123456789012:userpool/us-west-2_1a2b3c4d5"
            },
            "identitySourceId": "ISEXAMPLEabcdefg111111",
            "lastUpdatedDate": "2023-06-12T22:27:49.150035+00:00",
            "policyStoreId": "PSEXAMPLEabcdefg111111",
            "principalEntityType": "User"
        }
    ]
}
```
ID 소스에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListIdentitySources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/list-identity-sources.html)를 참조하세요.

### `list-policies`
<a name="verifiedpermissions_ListPolicies_cli_topic"></a>

다음 코드 예시에서는 `list-policies` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**사용 가능한 정책을 나열하는 방법**  
다음 `list-policies` 예시에서는 지정된 정책 저장소의 모든 정책을 나열합니다.  

```
aws verifiedpermissions list-policies \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "policies": [
        {
            "createdDate": "2023-06-12T20:33:37.382907+00:00",
            "definition": {
                "static": {
                    "description": "Grant everyone of janeFriends UserGroup access to the vacationFolder Album"
                }
            },
            "lastUpdatedDate": "2023-06-12T20:33:37.382907+00:00",
            "policyId": "SPEXAMPLEabcdefg111111",
            "policyStoreId": "PSEXAMPLEabcdefg111111",
            "policyType": "STATIC",
            "principal": {
                "entityId": "janeFriends",
                "entityType": "UserGroup"
            },
            "resource": {
                "entityId": "vacationFolder",
                "entityType": "Album"
            }
        },
        {
            "createdDate": "2023-06-12T20:39:44.975897+00:00",
            "definition": {
                "static": {
                    "description": "Grant everyone access to the publicFolder Album"
                }
            },
            "lastUpdatedDate": "2023-06-12T20:39:44.975897+00:00",
            "policyId": "SPEXAMPLEabcdefg222222",
            "policyStoreId": "PSEXAMPLEabcdefg111111",
            "policyType": "STATIC",
            "resource": {
                "entityId": "publicFolder",
                "entityType": "Album"
            }
        },
        {
            "createdDate": "2023-06-12T20:49:51.490211+00:00",
            "definition": {
                "templateLinked": {
                    "policyTemplateId": "PTEXAMPLEabcdefg111111"
                }
            },
            "lastUpdatedDate": "2023-06-12T20:49:51.490211+00:00",
            "policyId": "SPEXAMPLEabcdefg333333",
            "policyStoreId": "PSEXAMPLEabcdefg111111",
            "policyType": "TEMPLATE_LINKED",
            "principal": {
                "entityId": "alice",
                "entityType": "User"
            },
            "resource": {
                "entityId": "VacationPhoto94.jpg",
                "entityType": "Photo"
            }
        }
    ]
}
```
정책에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/list-policies.html)를 참조하세요.

### `list-policy-stores`
<a name="verifiedpermissions_ListPolicyStores_cli_topic"></a>

다음 코드 예시에서는 `list-policy-stores` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**사용 가능한 정책 저장소 나열**  
다음 `list-policy-stores` 예시에서는 AWS 리전의 모든 정책 저장소를 나열합니다. Verified Permissions에 대한 모든 명령 중 `create-policy-store` 및 `list-policy-stores`를 제외한 모든 명령은 작업하려는 정책 저장소의 ID를 지정해야 합니다.  

```
aws verifiedpermissions list-policy-stores
```
출력:  

```
{
    "policyStores": [
        {
            "arn": "arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg111111",
            "createdDate": "2023-06-05T20:16:46.225598+00:00",
            "policyStoreId": "PSEXAMPLEabcdefg111111"
        },
        {
            "arn": "arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg222222",
            "createdDate": "2023-06-08T18:09:37.364356+00:00",
            "policyStoreId": "PSEXAMPLEabcdefg222222"
        },
        {
            "arn": "arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg333333",
            "createdDate": "2023-06-08T18:09:46.920600+00:00",
            "policyStoreId": "PSEXAMPLEabcdefg333333"
        }
    ]
}
```
정책 저장소에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListPolicyStores](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/list-policy-stores.html) 섹션을 참조하세요.

### `list-policy-templates`
<a name="verifiedpermissions_ListPolicyTemplates_cli_topic"></a>

다음 코드 예시에서는 `list-policy-templates` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**사용 가능한 정책 템플릿을 나열하는 방법**  
다음 `list-policy-templates` 예시에서는 지정된 정책 저장소의 모든 정책 템플릿을 나열합니다.  

```
aws verifiedpermissions list-policy-templates \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "policyTemplates": [
        {
            "createdDate": "2023-06-12T20:47:42.804511+00:00",
            "lastUpdatedDate": "2023-06-12T20:47:42.804511+00:00",
            "policyStoreId": "PSEXAMPLEabcdefg111111",
            "policyTemplateId": "PTEXAMPLEabcdefg111111"
        }
    ]
}
```
정책 템플릿에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-templates.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListPolicyTemplates](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/list-policy-templates.html)를 참조하세요.

### `put-schema`
<a name="verifiedpermissions_PutSchema_cli_topic"></a>

다음 코드 예시에서는 `put-schema` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 저장소에 저장**  
다음 `put-schema` 예시에서는 지정된 정책 저장소의 스키마를 생성하거나 바꿉니다.  
입력 파일의 `cedarJson` 파라미터는 JSON 객체를 문자열로 표현합니다. 가장 바깥쪽 따옴표 페어 안에 따옴표(")가 포함되어 있습니다. 이렇게 하려면 포함된 모든 따옴표 앞에 백슬래시 문자( “)를 붙이고 모든 줄을 줄 바꿈 없이 하나의 텍스트 줄로 결합하여 JSON을 문자열로 변환해야 합니다.  
가독성을 위해 여기에 여러 줄에 걸쳐 예시 문자열을 표시할 수 있지만, 작업을 수행하려면 파라미터를 단일 줄 문자열로 제출해야 합니다.  
aws verifiedpermissions put-schema --definition file://schema.txt --policy-store-id PSEXAMPLEabcdefg111111  
`schema.txt`의 콘텐츠:  

```
{
    "cedarJson": "{\"MySampleNamespace\": {\"actions\": {\"remoteAccess\": {
            \"appliesTo\": {\"principalTypes\": [\"Employee\"]}}},\"entityTypes\": {
            \"Employee\": {\"shape\": {\"attributes\": {\"jobLevel\": {\"type\":
            \"Long\"},\"name\": {\"type\": \"String\"}},\"type\": \"Record\"}}}}}"
}
```
출력:  

```
{
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "namespaces": [
        "MySampleNamespace"
    ],
    "createdDate": "2023-06-14T17:47:13.999885+00:00",
    "lastUpdatedDate": "2023-06-14T17:47:13.999885+00:00"
}
```
스키마에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [정책 저장소 스키마](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/schema.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutSchema](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/put-schema.html)를 참조하세요.

### `update-identity-source`
<a name="verifiedpermissions_UpdateIdentitySource_cli_topic"></a>

다음 코드 예시에서는 `update-identity-source` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**자격 증명 소스를 업데이트하는 방법**  
다음 `update-identity-source` 예시에서는 새 Cognito 사용자 풀 구성을 제공하고 ID 소스에서 반환한 엔터티 유형을 변경하여 지정된 ID 소스를 수정합니다.  

```
aws verifiedpermissions update-identity-source
    --identity-source-id ISEXAMPLEabcdefg111111 \
    --update-configuration file://config.txt \
    --principal-entity-type "Employee" \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`config.txt`의 콘텐츠:  

```
{
        "cognitoUserPoolConfiguration": {
                "userPoolArn": "arn:aws:cognito-idp:us-west-2:123456789012:userpool/us-west-2_1a2b3c4d5",
                "clientIds":["a1b2c3d4e5f6g7h8i9j0kalbmc"]
        }
}
```
출력:  

```
{
    "createdDate": "2023-05-19T20:30:28.214829+00:00",
    "identitySourceId": "ISEXAMPLEabcdefg111111",
    "lastUpdatedDate": "2023-05-19T20:30:28.214829+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111"
}
```
ID 소스에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateIdentitySource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/update-identity-source.html)를 참조하세요.

### `update-policy-store`
<a name="verifiedpermissions_UpdatePolicyStore_cli_topic"></a>

다음 코드 예시에서는 `update-policy-store` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**정책 저장소 업데이트**  
다음 `update-policy-store` 예시에서는 유효성 검사 설정을 변경하여 정책 저장소를 수정합니다.  

```
aws verifiedpermissions update-policy-store \
    --validation-settings "mode=STRICT" \
    --policy-store-id PSEXAMPLEabcdefg111111
```
출력:  

```
{
    "arn": "arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg111111",
    "createdDate": "2023-05-16T17:41:29.103459+00:00",
    "lastUpdatedDate": "2023-05-16T17:41:29.103459+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111"
}
```
정책 저장소에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdatePolicyStore](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/update-policy-store.html)를 참조하세요.

### `update-policy-template`
<a name="verifiedpermissions_UpdatePolicyTemplate_cli_topic"></a>

다음 코드 예시에서는 `update-policy-template` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**예시 1: 정책 템플릿 업데이트**  
다음 `update-policy-template` 예시에서는 템플릿에 연결된 지정된 정책을 수정하여 정책 문을 바꿉니다.  

```
aws verifiedpermissions update-policy-template \
    --policy-template-id PTEXAMPLEabcdefg111111 \
    --statement file://template1.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`template1.txt` 파일의 콘텐츠:  

```
permit(
    principal in ?principal,
    action == Action::"view",
    resource == Photo::"VacationPhoto94.jpg"
);
```
출력:  

```
{
    "createdDate": "2023-06-12T20:47:42.804511+00:00",
    "lastUpdatedDate": "2023-06-12T20:47:42.804511+00:00",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyTemplateId": "PTEXAMPLEabcdefg111111"
}
```
정책 템플릿에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-templates.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdatePolicyTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/update-policy-template.html)을 참조하세요.

### `update-policy`
<a name="verifiedpermissions_UpdatePolicy_cli_topic"></a>

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

**AWS CLI**  
**정적 정책을 생성하려면**  
다음 `update-policy` 예제에서는 설명과 문을 업데이트하여 기존 정적 정책을 수정합니다.  

```
aws verifiedpermissions update-policy \
    --policy-id SPEXAMPLEabcdefg111111 \
    --definition file://updated-definition.txt \
    --policy-store-id PSEXAMPLEabcdefg111111
```
`statement` 파라미터는 JSON 객체를 문자열로 표현합니다. 가장 바깥쪽 따옴표 페어 안에 따옴표(")가 포함되어 있습니다. 이렇게 하려면 포함된 모든 따옴표 앞에 백슬래시 문자( “)를 붙이고 모든 줄을 줄 바꿈 없이 하나의 텍스트 줄로 결합하여 JSON을 문자열로 변환해야 합니다.  
가독성을 위해 여러 줄에 걸쳐 예제 문자열을 표시할 수 있지만, 해당 작업을 수행하려면 파라미터를 단일 줄 문자열로 제출해야 합니다.  
`updated-definition.txt` 파일의 콘텐츠:  

```
{
    "static": {
        "description": "Updated policy to grant janeFriends UserGroup access to the vacationFolder Album with view action only",
        "statement": "permit(principal in UserGroup::\"janeFriends\", action == Action::\"view\", resource in Album::\"vacationFolder\" );"
    }
}
```
출력:  

```
{
    "createdDate": "2023-06-12T20:33:37.382907+00:00",
    "lastUpdatedDate": "2023-06-12T20:33:37.382907+00:00",
    "policyId": "SPEXAMPLEabcdefg111111",
    "policyStoreId": "PSEXAMPLEabcdefg111111",
    "policyType": "STATIC",
    "principal": {
        "entityId": "janeFriends",
        "entityType": "UserGroup"
    },
    "resource": {
        "entityId": "vacationFolder",
        "entityType": "Album"
    }
}
```
정책에 대한 자세한 내용은 *Amazon Verified Permissions 사용 설명서*의 [Amazon Verified Permissions 정책](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdatePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/update-policy.html)를 참조하세요.