를 사용하여 확인된 권한 예제 AWS CLI - AWS Command Line Interface

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

를 사용하여 확인된 권한 예제 AWS CLI

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

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

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

주제

작업

다음 코드 예시에서는 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" }

자격 증명 소스에 대한 자세한 내용은 Amazon Verified Permissions 사용 설명서의 자격 증명 공급자와 함께 Amazon Verified Permissions 사용을 참조하세요.

다음 코드 예시에서는 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 정책 스토어를 참조하세요.

  • 자세한 API 내용은 명령 참조CreatePolicyStore의 섹션을 참조하세요. AWS CLI

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

AWS CLI

예제 1: 정책 템플릿 생성

다음 create-policy-template 예제에서는 보안 주체의 자리 표시자가 포함된 문이 포함된 정책 템플릿을 생성합니다.

aws verifiedpermissions create-policy-template \ --definition 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 정책 템플릿을 참조하세요.

다음 코드 예시에서는 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 정책을 참조하세요.

  • 자세한 API 내용은 명령 참조CreatePolicy의 섹션을 참조하세요. AWS CLI

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

AWS CLI

자격 증명 소스를 삭제하려면

다음 delete-identity-source 예제에서는 지정된 ID가 있는 자격 증명 소스를 삭제합니다.

aws verifiedpermissions delete-identity-source \ --identity-source-id ISEXAMPLEabcdefg111111 \ --policy-store-id PSEXAMPLEabcdefg111111

이 명령은 출력을 생성하지 않습니다.

자격 증명 소스에 대한 자세한 내용은 Amazon Verified Permissions 사용 설명서의 자격 증명 공급자와 함께 Amazon Verified Permissions 사용을 참조하세요.

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

AWS CLI

정책 스토어를 삭제하려면

다음 delete-policy-store 예제에서는 지정된 ID가 있는 정책 스토어를 삭제합니다.

aws verifiedpermissions delete-policy-store \ --policy-store-id PSEXAMPLEabcdefg111111

이 명령은 출력을 생성하지 않습니다.

정책 스토어에 대한 자세한 내용은 Amazon Verified Permissions 사용 설명서의 Amazon Verified Permissions 정책 스토어를 참조하세요.

  • 자세한 API 내용은 명령 참조DeletePolicyStore의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책 템플릿을 참조하세요.

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

AWS CLI

정적 또는 템플릿 연결 정책을 삭제하려면

다음 delete-policy 예제에서는 지정된 ID가 있는 정책을 삭제합니다.

aws verifiedpermissions delete-policy \ --policy-id SPEXAMPLEabcdefg111111 \ --policy-store-id PSEXAMPLEabcdefg111111

이 명령은 출력을 생성하지 않습니다.

정책에 대한 자세한 내용은 Amazon Verified Permissions 사용 설명서의 Amazon Verified Permissions 정책을 참조하세요.

  • 자세한 API 내용은 명령 참조DeletePolicy의 섹션을 참조하세요. AWS CLI

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

AWS CLI

자격 증명 소스에 대한 세부 정보를 검색하려면

다음 get-identity-source 예제에서는 지정된 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 사용 설명서의 자격 증명 공급자와 함께 Amazon Verified Permissions 사용을 참조하세요.

  • 자세한 API 내용은 명령 참조GetIdentitySource의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책 스토어를 참조하세요.

  • 자세한 API 내용은 명령 참조GetPolicyStore의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책 템플릿을 참조하세요.

  • 자세한 API 내용은 명령 참조GetPolicyTemplate의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책을 참조하세요.

  • 자세한 API 내용은 명령 참조GetPolicy의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 사용 설명서정책 스토어 스키마를 참조하세요.

  • 자세한 API 내용은 명령 참조GetSchema의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 사용자 풀의 자격 증명 사용에 대한 자세한 내용은 Amazon Verified Permissions 사용 설명서의 자격 증명 공급자와 Amazon Verified Permissions 사용을 참조하세요.

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

AWS CLI

예제 1: 사용자 요청에 대한 권한 부여 결정을 요청하려면(허용)

다음 is-authorized 예제에서는 User라는 유형의 리소스에 대해 updatePhoto 작업을 수행Alice하려는 Photo라는 유형의 보안 주체에 대한 권한 부여 결정을 요청합니다VacationPhoto94.jpg.

응답은 요청이 하나의 정책에서 허용된다는 것을 보여줍니다.

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 사용 설명서 섹션을 참조하세요.

  • 자세한 API 내용은 명령 참조IsAuthorized의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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" } ] }

자격 증명 소스에 대한 자세한 내용은 Amazon Verified Permissions 사용 설명서의 자격 증명 공급자와 함께 Amazon Verified Permissions 사용을 참조하세요.

  • 자세한 API 내용은 명령 참조ListIdentitySources의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책을 참조하세요.

  • 자세한 API 내용은 명령 참조ListPolicies의 섹션을 참조하세요. AWS CLI

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

AWS CLI

사용 가능한 정책 스토어를 나열하려면

다음 list-policy-stores 예제에서는 AWS 리전의 모든 정책 스토어를 나열합니다. create-policy-store 및 를 제외한 Verified Permissions에 대한 모든 명령은 작업하려는 정책 스토어의 ID를 지정list-policy-stores해야 합니다.

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 정책 스토어를 참조하세요.

  • 자세한 API 내용은 명령 참조ListPolicyStores의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책 템플릿을 참조하세요.

  • 자세한 API 내용은 명령 참조ListPolicyTemplates의 섹션을 참조하세요. AWS CLI

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

AWS CLI

스키마를 정책 스토어에 저장하려면

다음 put-schema 예제에서는 지정된 정책 스토어에서 스키마를 생성하거나 바꿉니다.

입력 파일의 cedarJson 파라미터는 JSON 객체의 문자열 표현을 취합니다. 여기에는 가장 바깥쪽의 따옴표 쌍 내에 포함된 따옴표(“)가 포함되어 있습니다. 이렇게 하려면 모든 포함된 따옴표 앞에 백슬래시 문자( ')를 붙이고 모든 줄을 줄 바꿈 없이 단일 텍스트 줄로 결합하여 를 JSON 문자열로 변환해야 합니다.

여기서는 가독성을 위해 여러 줄에 걸쳐 예제 문자열을 표시할 수 있지만, 작업을 수행하려면 파라미터를 단일 줄 문자열로 제출해야 합니다.

aws verifiedpermissions put-schema --정의 파일://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 사용 설명서정책 스토어 스키마를 참조하세요.

  • 자세한 API 내용은 명령 참조PutSchema의 섹션을 참조하세요. AWS CLI

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

AWS CLI

자격 증명 소스를 업데이트하려면

다음 update-identity-source 예제에서는 새 Cognito 사용자 풀 구성을 제공하고 자격 증명 소스에서 반환한 엔터티 유형을 변경하여 지정된 자격 증명 소스를 수정합니다.

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 사용 설명서의 자격 증명 공급자와 함께 Amazon Verified Permissions 사용을 참조하세요.

다음 코드 예시에서는 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 정책 스토어를 참조하세요.

  • 자세한 API 내용은 명령 참조UpdatePolicyStore의 섹션을 참조하세요. AWS CLI

다음 코드 예시에서는 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 정책 템플릿을 참조하세요.

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

AWS CLI

예제 1: 정적 정책 생성

다음 create-policy 예제에서는 보안 주체와 리소스를 모두 지정하는 정책 범위를 사용하여 정적 정책을 생성합니다.

aws verifiedpermissions create-policy \ --definition file://definition.txt \ --policy-store-id PSEXAMPLEabcdefg111111

statement 파라미터는 JSON 객체의 문자열 표현을 취합니다. 여기에는 가장 바깥쪽의 따옴표 쌍 내에 포함된 따옴표(“)가 포함되어 있습니다. 이렇게 하려면 모든 포함된 따옴표 앞에 백슬래시 문자( ')를 붙이고 모든 줄을 줄 바꿈 없이 단일 텍스트 줄로 결합하여 를 JSON 문자열로 변환해야 합니다.

여기서는 가독성을 위해 여러 줄에 걸쳐 예제 문자열을 표시할 수 있지만, 작업을 수행하려면 파라미터를 단일 줄 문자열로 제출해야 합니다.

definition.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://definition2.txt \ --policy-store-id PSEXAMPLEabcdefg111111

정의 내용3.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 정책을 참조하세요.

  • 자세한 API 내용은 명령 참조UpdatePolicy의 섹션을 참조하세요. AWS CLI