1. Packages
  2. Packages
  3. AWS
  4. API Docs
  5. iam
  6. getRolePolicyAttachments
Viewing docs for AWS v7.30.0
published on Thursday, May 14, 2026 by Pulumi
aws logo
Viewing docs for AWS v7.30.0
published on Thursday, May 14, 2026 by Pulumi

    Provides details about the managed policies attached to an AWS IAM Role.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.iam.getRolePolicyAttachments({
        roleName: "example-role",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.iam.get_role_policy_attachments(role_name="example-role")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := iam.GetRolePolicyAttachments(ctx, &iam.GetRolePolicyAttachmentsArgs{
    			RoleName: "example-role",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Iam.GetRolePolicyAttachments.Invoke(new()
        {
            RoleName = "example-role",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetRolePolicyAttachmentsArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = IamFunctions.getRolePolicyAttachments(GetRolePolicyAttachmentsArgs.builder()
                .roleName("example-role")
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: aws:iam:getRolePolicyAttachments
          arguments:
            roleName: example-role
    
    Example coming soon!
    

    Using getRolePolicyAttachments

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getRolePolicyAttachments(args: GetRolePolicyAttachmentsArgs, opts?: InvokeOptions): Promise<GetRolePolicyAttachmentsResult>
    function getRolePolicyAttachmentsOutput(args: GetRolePolicyAttachmentsOutputArgs, opts?: InvokeOptions): Output<GetRolePolicyAttachmentsResult>
    def get_role_policy_attachments(path_prefix: Optional[str] = None,
                                    role_name: Optional[str] = None,
                                    opts: Optional[InvokeOptions] = None) -> GetRolePolicyAttachmentsResult
    def get_role_policy_attachments_output(path_prefix: pulumi.Input[Optional[str]] = None,
                                    role_name: pulumi.Input[Optional[str]] = None,
                                    opts: Optional[InvokeOptions] = None) -> Output[GetRolePolicyAttachmentsResult]
    func GetRolePolicyAttachments(ctx *Context, args *GetRolePolicyAttachmentsArgs, opts ...InvokeOption) (*GetRolePolicyAttachmentsResult, error)
    func GetRolePolicyAttachmentsOutput(ctx *Context, args *GetRolePolicyAttachmentsOutputArgs, opts ...InvokeOption) GetRolePolicyAttachmentsResultOutput

    > Note: This function is named GetRolePolicyAttachments in the Go SDK.

    public static class GetRolePolicyAttachments 
    {
        public static Task<GetRolePolicyAttachmentsResult> InvokeAsync(GetRolePolicyAttachmentsArgs args, InvokeOptions? opts = null)
        public static Output<GetRolePolicyAttachmentsResult> Invoke(GetRolePolicyAttachmentsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRolePolicyAttachmentsResult> getRolePolicyAttachments(GetRolePolicyAttachmentsArgs args, InvokeOptions options)
    public static Output<GetRolePolicyAttachmentsResult> getRolePolicyAttachments(GetRolePolicyAttachmentsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: aws:iam/getRolePolicyAttachments:getRolePolicyAttachments
      arguments:
        # arguments dictionary
    data "aws_iam_getrolepolicyattachments" "name" {
        # arguments
    }

    The following arguments are supported:

    RoleName string

    Name of the IAM role.

    The following arguments are optional:

    PathPrefix string
    Path prefix for filtering the results.
    RoleName string

    Name of the IAM role.

    The following arguments are optional:

    PathPrefix string
    Path prefix for filtering the results.
    role_name string

    Name of the IAM role.

    The following arguments are optional:

    path_prefix string
    Path prefix for filtering the results.
    roleName String

    Name of the IAM role.

    The following arguments are optional:

    pathPrefix String
    Path prefix for filtering the results.
    roleName string

    Name of the IAM role.

    The following arguments are optional:

    pathPrefix string
    Path prefix for filtering the results.
    role_name str

    Name of the IAM role.

    The following arguments are optional:

    path_prefix str
    Path prefix for filtering the results.
    roleName String

    Name of the IAM role.

    The following arguments are optional:

    pathPrefix String
    Path prefix for filtering the results.

    getRolePolicyAttachments Result

    The following output properties are available:

    AttachedPolicies List<GetRolePolicyAttachmentsAttachedPolicy>
    List of attached managed policies. See below.
    Id string
    The provider-assigned unique ID for this managed resource.
    RoleName string
    PathPrefix string
    AttachedPolicies []GetRolePolicyAttachmentsAttachedPolicy
    List of attached managed policies. See below.
    Id string
    The provider-assigned unique ID for this managed resource.
    RoleName string
    PathPrefix string
    attached_policies list(object)
    List of attached managed policies. See below.
    id string
    The provider-assigned unique ID for this managed resource.
    role_name string
    path_prefix string
    attachedPolicies List<GetRolePolicyAttachmentsAttachedPolicy>
    List of attached managed policies. See below.
    id String
    The provider-assigned unique ID for this managed resource.
    roleName String
    pathPrefix String
    attachedPolicies GetRolePolicyAttachmentsAttachedPolicy[]
    List of attached managed policies. See below.
    id string
    The provider-assigned unique ID for this managed resource.
    roleName string
    pathPrefix string
    attached_policies Sequence[GetRolePolicyAttachmentsAttachedPolicy]
    List of attached managed policies. See below.
    id str
    The provider-assigned unique ID for this managed resource.
    role_name str
    path_prefix str
    attachedPolicies List<Property Map>
    List of attached managed policies. See below.
    id String
    The provider-assigned unique ID for this managed resource.
    roleName String
    pathPrefix String

    Supporting Types

    GetRolePolicyAttachmentsAttachedPolicy

    PolicyArn string
    ARN of the attached managed policy.
    PolicyName string
    Name of the attached managed policy.
    PolicyArn string
    ARN of the attached managed policy.
    PolicyName string
    Name of the attached managed policy.
    policy_arn string
    ARN of the attached managed policy.
    policy_name string
    Name of the attached managed policy.
    policyArn String
    ARN of the attached managed policy.
    policyName String
    Name of the attached managed policy.
    policyArn string
    ARN of the attached managed policy.
    policyName string
    Name of the attached managed policy.
    policy_arn str
    ARN of the attached managed policy.
    policy_name str
    Name of the attached managed policy.
    policyArn String
    ARN of the attached managed policy.
    policyName String
    Name of the attached managed policy.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    Viewing docs for AWS v7.30.0
    published on Thursday, May 14, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.