

Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 [AWS](https://github.com/awsdocs/aws-doc-sdk-examples)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# を使用した Verified Permissions の例 AWS CLI
<a name="cli_2_verifiedpermissions_code_examples"></a>

次のコード例は、Verified Permissions AWS Command Line Interface で を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

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

次のコード例は、`create-identity-source` を使用する方法を示しています。

**AWS CLI**  
**ID ソースを作成するには**  
次の `create-identity-source` の例では、指定された Amazon Cognito ユーザープールに保存されているアイデンティティを参照できる ID ソースを作成します。これらのアイデンティティは、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"
}
```
詳細については、「[Amazon Verified Permissions ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)」の「*ID プロバイダでの Amazon Verified Permissions の使用*」を参照してください。  
+  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_2_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_2_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_2_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 ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)」の「*Amazon Verified Permissions のポリシー*」を参照してください。  
+  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_2_topic"></a>

次のコード例は、`delete-identity-source` を使用する方法を示しています。

**AWS CLI**  
**ID ソースを削除するには**  
次の `delete-identity-source` の例では、指定された ID を持つ ID ソースを削除します。  

```
aws verifiedpermissions delete-identity-source \
    --identity-source-id ISEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
このコマンドでは何も出力されません。  
詳細については、「[Amazon Verified Permissions ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)」の「*ID プロバイダでの Amazon Verified Permissions の使用*」を参照してください。  
+  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_2_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_2_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_2_topic"></a>

次のコード例は、`delete-policy` を使用する方法を示しています。

**AWS CLI**  
**静的ポリシーまたはテンプレートにリンクされたポリシーを削除するには**  
次の `delete-policy` の例では、指定された ID を持つポリシーを削除します。  

```
aws verifiedpermissions delete-policy \
    --policy-id SPEXAMPLEabcdefg111111 \
    --policy-store-id PSEXAMPLEabcdefg111111
```
このコマンドでは何も出力されません。  
ポリシーに関する詳細については、「[Amazon Verified Permissions ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)」の「*Amazon Verified Permissions のポリシー*」を参照してください。  
+  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_2_topic"></a>

次のコード例は、`get-identity-source` を使用する方法を示しています。

**AWS CLI**  
**ID ソースの詳細を取得するには**  
次の`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"
}
```
詳細については、「[Amazon Verified Permissions ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)」の「*ID プロバイダでの Amazon Verified Permissions の使用*」を参照してください。  
+  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_2_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_2_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_2_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 ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)」の「*Amazon Verified Permissions のポリシー*」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/get-policy.html)」を参照してください。

### `get-schema`
<a name="verifiedpermissions_GetSchema_cli_2_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_2_topic"></a>

次のコード例は、`is-authorized-with-token` を使用する方法を示しています。

**AWS CLI**  
**例 1: ユーザーリクエストの承認決定をリクエストするには (許可)**  
次の `is-authorized-with-token` の例では、Amazon Cognito によって認証されたユーザーの認証決定をリクエストします。リクエストは、アクセストークンではなく Cognito によって提供される ID トークンを使用します。この例では、指定された情報ストアは、プリンシパルをタイプ `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 からアイデンティティを受け入れる次のステートメントを含むポリシーが含まれています。  

```
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_2_topic"></a>

次のコード例は、`is-authorized` を使用する方法を示しています。

**AWS CLI**  
**例 1: ユーザーリクエストの承認決定をリクエストするには (許可)**  
次の `is-authorized` の例では、`VacationPhoto94.jpg` というタイプ `Photo` のリソースにで `updatePhoto` オペレーションを実行する、`Alice` というタイプ `User` のプリンシパルの承認決定をリクエストします。  
レスポンスは、リクエストが 1 つのポリシーで許可されていることを示します。  

```
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_2_topic"></a>

次のコード例は、`list-identity-sources` を使用する方法を示しています。

**AWS CLI**  
**使用可能な ID ソースを一覧表示するには**  
次の `list-identity-sources` の例では、指定されたポリシーストア内のすべての ID ソースを一覧表示します。  

```
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"
        }
    ]
}
```
詳細については、「[Amazon Verified Permissions ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)」の「*ID プロバイダでの Amazon Verified Permissions の使用*」を参照してください。  
+  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_2_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 ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)」の「*Amazon Verified Permissions のポリシー*」を参照してください。  
+  API の詳細については、「AWS CLI Command Reference」の「[ListPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/list-policies.html)」を参照してください。**

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

次のコード例は、`list-policy-stores` を使用する方法を示しています。

**AWS CLI**  
**使用可能なポリシーストアを一覧表示するには**  
次の の`list-policy-stores`例では、 AWS リージョン内のすべてのポリシーストアを一覧表示します。`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_2_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_2_topic"></a>

次のコード例は、`put-schema` を使用する方法を示しています。

**AWS CLI**  
**スキーマをポリシーストアに保存するには**  
次の `put-schema` の例では、指定されたポリシーストアでスキーマを作成または置き換えます。  
入力ファイルの `cedarJson` パラメータは、JSON オブジェクトの文字列表現を取得します。これには、最も外側の引用符ペア内に埋め込まれた引用符 (") が含まれます。そのためには、すべての埋め込み引用符にバックスラッシュ文字 ( " ) を付け、すべての行を改行のない単一のテキスト行に結合して、JSON を文字列に変換する必要があります。  
文字列の例は、読みやすくするためにここで複数の行にラップして表示できますが、 オペレーションではパラメータを 1 行の文字列として送信する必要があります。  
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_2_topic"></a>

次のコード例は、`update-identity-source` を使用する方法を示しています。

**AWS CLI**  
**ID ソースを更新するには**  
次の `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"
}
```
詳細については、「[Amazon Verified Permissions ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/identity-providers.html)」の「*ID プロバイダでの Amazon Verified Permissions の使用*」を参照してください。  
+  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_2_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_2_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_2_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 を文字列に変換する必要があります。  
文字列の例は、読みやすくするために複数の行にラップして表示できますが、オペレーションではパラメータを 1 行の文字列として送信する必要があります。  
`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 ユーザーガイド](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policies.html)」の「*Amazon Verified Permissions のポリシー*」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdatePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/verifiedpermissions/update-policy.html)」を参照してください。