または ListUserPoliciesAWS SDKで を使用する CLI - AWS SDK CLI コードの例

AWS Doc SDK Examples GitHub リポジトリには他にも AWS SDK例があります。

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

または ListUserPoliciesAWS SDKで を使用する CLI

以下のコード例は、ListUserPolicies の使用方法を示しています。

CLI
AWS CLI

IAMユーザーのポリシーを一覧表示するには

次のlist-user-policiesコマンドは、 という名前のIAMユーザーにアタッチされているポリシーを一覧表示しますBob

aws iam list-user-policies \ --user-name Bob

出力:

{ "PolicyNames": [ "ExamplePolicy", "TestPolicy" ] }

詳細については、「 AWS IAMユーザーガイド」の「 AWS アカウントでの IAM ユーザーの作成」を参照してください。

  • API 詳細については、AWS CLI 「 コマンドリファレンスListUserPolicies」の「」を参照してください。

Go
SDK Go V2 用
注記

詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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」の「」を参照してください。

PowerShell
のツール PowerShell

例 1: この例では、 という名前のIAMユーザーに埋め込まれているインラインポリシーの名前のリストを取得しますDavid

Get-IAMUserPolicyList -UserName David

出力:

Davids_IAM_Admin_Policy
  • API 詳細については、「 コマンドレットリファレンスListUserPolicies」の「」を参照してください。 AWS Tools for PowerShell