기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
조직의 정책에 대한 정보 가져오기
이 주제에서는 조직 내 정책에 대한 세부 정보를 확인하는 다양한 방법을 설명합니다. 이러한 절차는 모든 정책 유형에 적용됩니다. 해당 유형의 정책을 해당 조직 루트의 모든 엔터티에 연결하려면 먼저 조직 루트에서 정책 유형을 활성화해야 합니다.
모든 정책 나열
조직 내 정책을 나열하려면 다음과 같은 권한이 있어야 합니다.
또는 AWS Command Line Interface (AWS CLI) 명령 AWS Management Console 또는 AWS SDK 작업을 사용하여 조직의 정책을 볼 수 있습니다.
조직의 모든 정책을 나열하려면
-
AWS Organizations 콘솔에 로그인합니다. 조직의 관리 계정에서 IAM 사용자로 로그인하거나 IAM 역할을 맡거나 루트 사용자로 로그인(권장되지 않음)해야 합니다.
-
정책(Policies) 페이지에서 나열할 정책을 선택합니다.
지정된 정책 유형이 활성화되어 있으면 조직에서 현재 사용 가능한 해당 유형의 모든 정책 목록이 콘솔에 표시됩니다.
-
정책(Policies) 페이지로 돌아가서 각 정책 유형에 대해 위의 과정을 반복합니다.
다음 코드 예제는 ListPolicies
의 사용 방법을 보여 줍니다.
- .NET
-
- AWS SDK for .NET
-
using System;
using System.Threading.Tasks;
using Amazon.Organizations;
using Amazon.Organizations.Model;
/// <summary>
/// Shows how to list the AWS Organizations policies associated with an
/// organization.
/// </summary>
public class ListPolicies
{
/// <summary>
/// Initializes an Organizations client object, and then calls its
/// ListPoliciesAsync method.
/// </summary>
public static async Task Main()
{
// Create the client object using the default account.
IAmazonOrganizations client = new AmazonOrganizationsClient();
// The value for the Filter parameter is required and must must be
// one of the following:
// AISERVICES_OPT_OUT_POLICY
// BACKUP_POLICY
// SERVICE_CONTROL_POLICY
// TAG_POLICY
var request = new ListPoliciesRequest
{
Filter = "SERVICE_CONTROL_POLICY",
MaxResults = 5,
};
var response = new ListPoliciesResponse();
try
{
do
{
response = await client.ListPoliciesAsync(request);
response.Policies.ForEach(p => DisplayPolicies(p));
if (response.NextToken is not null)
{
request.NextToken = response.NextToken;
}
}
while (response.NextToken is not null);
}
catch (AWSOrganizationsNotInUseException ex)
{
Console.WriteLine(ex.Message);
}
}
/// <summary>
/// Displays information about the Organizations policies associated
/// with an organization.
/// </summary>
/// <param name="policy">An Organizations policy summary to display
/// information on the console.</param>
private static void DisplayPolicies(PolicySummary policy)
{
string policyInfo = $"{policy.Id} {policy.Name}\t{policy.Description}";
Console.WriteLine(policyInfo);
}
}
- CLI
-
- AWS CLI
-
특정 유형의 조직에 있는 모든 정책 목록을 검색하는 방법
다음 예시에서는 필터 파라미터로 지정된 SCP 목록을 가져오는 방법을 보여줍니다.
aws organizations list-policies --filter SERVICE_CONTROL_POLICY
출력에는 요약 정보가 있는 정책 목록이 포함됩니다.
{
"Policies": [
{
"Type": "SERVICE_CONTROL_POLICY",
"Name": "AllowAllS3Actions",
"AwsManaged": false,
"Id": "p-examplepolicyid111",
"Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid111",
"Description": "Enables account admins to delegate permissions for any S3 actions to users and roles in their accounts."
},
{
"Type": "SERVICE_CONTROL_POLICY",
"Name": "AllowAllEC2Actions",
"AwsManaged": false,
"Id": "p-examplepolicyid222",
"Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid222",
"Description": "Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts."
},
{
"AwsManaged": true,
"Description": "Allows access to every operation",
"Type": "SERVICE_CONTROL_POLICY",
"Id": "p-FullAWSAccess",
"Arn": "arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess",
"Name": "FullAWSAccess"
}
]
}
- Python
-
- SDK for Python (Boto3)
-
def list_policies(policy_filter, orgs_client):
"""
Lists the policies for the account, limited to the specified filter.
:param policy_filter: The kind of policies to return.
:param orgs_client: The Boto3 Organizations client.
:return: The list of policies found.
"""
try:
response = orgs_client.list_policies(Filter=policy_filter)
policies = response["Policies"]
logger.info("Found %s %s policies.", len(policies), policy_filter)
except ClientError:
logger.exception("Couldn't get %s policies.", policy_filter)
raise
else:
return policies
루트, OU, 계정에 연결된 정책 나열
조직 내 루트, 조직 단위(OU) 또는 계정에 연결된 정책을 나열하려면 다음과 같은 권한이 있어야 합니다.
- AWS Management Console
-
지정된 루트, OU 또는 계정에 직접 연결된 모든 정책을 나열하려면
-
AWS Organizations 콘솔에 로그인합니다. 조직의 관리 계정에서 IAM 사용자로 로그인하거나 IAM 역할을 맡거나 루트 사용자로 로그인(권장되지 않음)해야 합니다.
-
AWS 계정 페이지에서 정책을 보려는 루트, OU 또는 계정의 이름을 선택합니다. 원하는 OU를 찾기 위해 OU를 확장해야 할 수도 있습니다(
선택).
-
루트, OU 또는 계정 페이지에서 정책(Policies) 탭을 선택합니다.
정책 탭에는 해당 루트, OU 또는 계정에 연결된 모든 정책이 정책 유형별로 그룹화되어 표시됩니다.
- AWS CLI & AWS SDKs
-
지정된 루트, OU 또는 계정에 직접 연결된 모든 정책 나열
다음 명령 중 하나를 사용하여 개체에 연결된 정책을 나열할 수 있습니다.
-
AWS CLI: list-policies-for-target
다음 예제에서는 지정된 OU에 연결된 모든 서비스 제어 정책을 나열합니다. 루트, OU 또는 계정의 ID와 나열할 정책 유형을 모두 지정해야 합니다.
$
aws organizations list-policies-for-target \
--target-id ou-a1b2-f6g7h222 \
--filter SERVICE_CONTROL_POLICY
{
"Policies": [
{
"Id": "p-FullAWSAccess",
"Arn": "arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess",
"Name": "FullAWSAccess",
"Description": "Allows access to every operation",
"Type": "SERVICE_CONTROL_POLICY",
"AwsManaged": true
}
]
}
-
AWS SDKs: ListPoliciesForTarget
정책이 연결된 모든 루트, OU, 계정 나열
정책이 연결된 개체를 나열하려면 다음과 같은 권한이 있어야 합니다.
- AWS Management Console
-
지정된 정책이 연결된 모든 루트, OU, 계정을 나열하려면
-
AWS Organizations 콘솔에 로그인합니다. 조직의 관리 계정에서 IAM 사용자로 로그인하거나 IAM 역할을 맡거나 루트 사용자로 로그인(권장되지 않음)해야 합니다.
-
정책(Policies) 페이지에서 정책 유형을 선택한 다음 연결을 검토하려는 정책의 이름을 선택합니다.
-
대상(Targets) 탭을 선택하여 선택한 정책이 연결된 모든 루트, OU, 계정의 테이블을 표시합니다.
- AWS CLI & AWS SDKs
-
지정된 정책이 연결된 모든 루트, OU, 계정을 나열하려면
다음 명령 중 하나를 사용하여 정책이 있는 개체를 나열할 수 있습니다.
-
AWS CLI: list-targets-for-policy
다음 예제에서는 지정된 정책이 연결된 모든 루트, OU, 계정을 보여 줍니다.
$
aws organizations list-targets-for-policy \
--policy-id p-FullAWSAccess
{
"Targets": [
{
"TargetId": "ou-a1b2-f6g7h111",
"Arn": "arn:aws:organizations::123456789012:ou/o-aa111bb222/ou-a1b2-f6g7h111",
"Name": "testou2",
"Type": "ORGANIZATIONAL_UNIT"
},
{
"TargetId": "ou-a1b2-f6g7h222",
"Arn": "arn:aws:organizations::123456789012:ou/o-aa111bb222/ou-a1b2-f6g7h222",
"Name": "testou1",
"Type": "ORGANIZATIONAL_UNIT"
},
{
"TargetId": "123456789012",
"Arn": "arn:aws:organizations::123456789012:account/o-aa111bb222/123456789012",
"Name": "My Management Account (bisdavid)",
"Type": "ACCOUNT"
},
{
"TargetId": "r-a1b2",
"Arn": "arn:aws:organizations::123456789012:root/o-aa111bb222/r-a1b2",
"Name": "Root",
"Type": "ROOT"
}
]
}
-
AWS SDKs: ListTargetsForPolicy
정책 세부 정보 확인
정책 세부 정보를 표시하려면 다음과 같은 권한이 있어야 합니다.
정책에 대한 세부 정보를 얻으려면
-
AWS Organizations 콘솔에 로그인합니다. 조직의 관리 계정에서 IAM 사용자로 로그인하거나 IAM 역할을 맡거나 루트 사용자로 로그인(권장되지 않음)해야 합니다.
-
정책(Policies) 페이지에서 검토하려는 정책의 정책 유형을 선택한 다음 정책의 이름을 선택합니다.
정책 페이지에는 ARN, 설명, 연결된 대상을 비롯해 정책에 대해 제공되는 정보가 표시됩니다.
-
내용(Content) 탭은 정책의 현재 내용을 JSON 형식으로 보여 줍니다.
-
대상(Targets) 탭에는 정책이 연결된 루트, OU, 계정의 목록이 표시됩니다.
-
태그(Tags) 탭에는 정책에 연결된 태그가 표시됩니다. 참고: AWS
관리형 정책은 태그(Tags) 탭을 이용할 수 없습니다.
정책을 편집하려면 정책 편집(Edit policy)을 선택합니다. 정책 유형마다 편집 요구 사항이 다르기 때문에 지정된 정책 유형의 정책 생성 및 업데이트에 대한 지침을 참조하세요.
다음 코드 예제는 DescribePolicy
의 사용 방법을 보여 줍니다.
- CLI
-
- AWS CLI
-
정책 정보 가져오기
다음 예시에서는 정책 정보를 요청하는 방법을 보여줍니다.
aws organizations describe-policy --policy-id p-examplepolicyid111
출력에는 정책의 세부 정보가 있는 정책 객체가 포함됩니다.
{
"Policy": {
"Content": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": \"*\",\n \"Resource\": \"*\"\n }\n ]\n}",
"PolicySummary": {
"Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111",
"Type": "SERVICE_CONTROL_POLICY",
"Id": "p-examplepolicyid111",
"AwsManaged": false,
"Name": "AllowAllS3Actions",
"Description": "Enables admins to delegate S3 permissions"
}
}
}
- Python
-
- SDK for Python (Boto3)
-
def describe_policy(policy_id, orgs_client):
"""
Describes a policy.
:param policy_id: The ID of the policy to describe.
:param orgs_client: The Boto3 Organizations client.
:return: The description of the policy.
"""
try:
response = orgs_client.describe_policy(PolicyId=policy_id)
policy = response["Policy"]
logger.info("Got policy %s.", policy_id)
except ClientError:
logger.exception("Couldn't get policy %s.", policy_id)
raise
else:
return policy