

# AWS SDK 또는 CLI와 함께 `ListUserPolicies` 사용
<a name="iam_example_iam_ListUserPolicies_section"></a>

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

------
#### [ CLI ]

**AWS CLI**  
**IAM 사용자에 대한 정책 나열**  
다음 `list-user-policies` 명령은 이름이 `Bob`인 IAM 사용자에게 연결된 정책을 나열합니다.  

```
aws iam list-user-policies \
    --user-name Bob
```
출력:  

```
{
    "PolicyNames": [
        "ExamplePolicy",
        "TestPolicy"
    ]
}
```
자세한 내용은 **AWS IAM 사용 설명서의 [AWS 계정에서 IAM 사용자 생성](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html)을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [ListUserPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/list-user-policies.html)를 참조하세요.

------
#### [ Go ]

**SDK for Go V2**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예제 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/iam#code-examples)에서 전체 예제를 확인하고 설정 및 실행하는 방법을 알아보세요.

```
import (
	"context"
	"encoding/json"
	"errors"
	"log"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/service/iam"
	"github.com/aws/aws-sdk-go-v2/service/iam/types"
	"github.com/aws/smithy-go"
)

// UserWrapper encapsulates user actions used in the examples.
// It contains an IAM service client that is used to perform user actions.
type UserWrapper struct {
	IamClient *iam.Client
}



// ListUserPolicies lists the inline policies for the specified user.
func (wrapper UserWrapper) ListUserPolicies(ctx context.Context, userName string) ([]string, error) {
	var policies []string
	result, err := wrapper.IamClient.ListUserPolicies(ctx, &iam.ListUserPoliciesInput{
		UserName: aws.String(userName),
	})
	if err != nil {
		log.Printf("Couldn't list policies for user %v. Here's why: %v\n", userName, err)
	} else {
		policies = result.PolicyNames
	}
	return policies, err
}
```
+  API 세부 정보는 *AWS SDK for Go API 참조*의 [ListUserPolicies](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/iam#Client.ListUserPolicies)을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 예제는 `David`라는 IAM 사용자에게 포함된 인라인 정책의 이름 목록을 검색합니다.**  

```
Get-IAMUserPolicyList -UserName David
```
**출력:**  

```
Davids_IAM_Admin_Policy
```
+  API 세부 정보는 **AWS Tools for PowerShell Cmdlet 참조(V4)의 [ListUserPolicies](https://docs.aws.amazon.com/powershell/v4/reference)를 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 예제는 `David`라는 IAM 사용자에게 포함된 인라인 정책의 이름 목록을 검색합니다.**  

```
Get-IAMUserPolicyList -UserName David
```
**출력:**  

```
Davids_IAM_Admin_Policy
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [ListUserPolicies](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

------

AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 [AWS SDK와 함께 이 서비스 사용](sdk-general-information-section.md)을 참조하세요. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.