AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi
aws.iam.getRole
Explore with Pulumi AI
This data source can be used to fetch information about a specific IAM role. By using this data source, you can reference IAM role properties without having to hard code ARNs as input.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.iam.getRole({
    name: "an_example_role_name",
});
import pulumi
import pulumi_aws as aws
example = aws.iam.get_role(name="an_example_role_name")
package main
import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := iam.LookupRole(ctx, &iam.LookupRoleArgs{
			Name: "an_example_role_name",
		}, 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.GetRole.Invoke(new()
    {
        Name = "an_example_role_name",
    });
});
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.GetRoleArgs;
import java.util.List;
import java.util.ArrayList;
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.getRole(GetRoleArgs.builder()
            .name("an_example_role_name")
            .build());
    }
}
variables:
  example:
    fn::invoke:
      function: aws:iam:getRole
      arguments:
        name: an_example_role_name
Using getRole
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 getRole(args: GetRoleArgs, opts?: InvokeOptions): Promise<GetRoleResult>
function getRoleOutput(args: GetRoleOutputArgs, opts?: InvokeOptions): Output<GetRoleResult>def get_role(name: Optional[str] = None,
             tags: Optional[Mapping[str, str]] = None,
             opts: Optional[InvokeOptions] = None) -> GetRoleResult
def get_role_output(name: Optional[pulumi.Input[str]] = None,
             tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetRoleResult]func LookupRole(ctx *Context, args *LookupRoleArgs, opts ...InvokeOption) (*LookupRoleResult, error)
func LookupRoleOutput(ctx *Context, args *LookupRoleOutputArgs, opts ...InvokeOption) LookupRoleResultOutput> Note: This function is named LookupRole in the Go SDK.
public static class GetRole 
{
    public static Task<GetRoleResult> InvokeAsync(GetRoleArgs args, InvokeOptions? opts = null)
    public static Output<GetRoleResult> Invoke(GetRoleInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetRoleResult> getRole(GetRoleArgs args, InvokeOptions options)
public static Output<GetRoleResult> getRole(GetRoleArgs args, InvokeOptions options)
fn::invoke:
  function: aws:iam/getRole:getRole
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Name string
 - Friendly IAM role name to match.
 - Dictionary<string, string>
 - Tags attached to the role.
 
- Name string
 - Friendly IAM role name to match.
 - map[string]string
 - Tags attached to the role.
 
- name String
 - Friendly IAM role name to match.
 - Map<String,String>
 - Tags attached to the role.
 
- name string
 - Friendly IAM role name to match.
 - {[key: string]: string}
 - Tags attached to the role.
 
- name str
 - Friendly IAM role name to match.
 - Mapping[str, str]
 - Tags attached to the role.
 
- name String
 - Friendly IAM role name to match.
 - Map<String>
 - Tags attached to the role.
 
getRole Result
The following output properties are available:
- Arn string
 - ARN of the role.
 - Assume
Role stringPolicy  - Policy document associated with the role.
 - Create
Date string - Creation date of the role in RFC 3339 format.
 - Description string
 - Description for the role.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Max
Session intDuration  - Maximum session duration.
 - Name string
 - Path string
 - Path to the role.
 - Permissions
Boundary string - The ARN of the policy that is used to set the permissions boundary for the role.
 - Role
Last List<GetUseds Role Role Last Used>  - Contains information about the last time that an IAM role was used. See 
role_last_usedfor details. - Dictionary<string, string>
 - Tags attached to the role.
 - Unique
Id string - Stable and unique string identifying the role.
 
- Arn string
 - ARN of the role.
 - Assume
Role stringPolicy  - Policy document associated with the role.
 - Create
Date string - Creation date of the role in RFC 3339 format.
 - Description string
 - Description for the role.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Max
Session intDuration  - Maximum session duration.
 - Name string
 - Path string
 - Path to the role.
 - Permissions
Boundary string - The ARN of the policy that is used to set the permissions boundary for the role.
 - Role
Last []GetUseds Role Role Last Used  - Contains information about the last time that an IAM role was used. See 
role_last_usedfor details. - map[string]string
 - Tags attached to the role.
 - Unique
Id string - Stable and unique string identifying the role.
 
- arn String
 - ARN of the role.
 - assume
Role StringPolicy  - Policy document associated with the role.
 - create
Date String - Creation date of the role in RFC 3339 format.
 - description String
 - Description for the role.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - max
Session IntegerDuration  - Maximum session duration.
 - name String
 - path String
 - Path to the role.
 - permissions
Boundary String - The ARN of the policy that is used to set the permissions boundary for the role.
 - role
Last List<GetUseds Role Role Last Used>  - Contains information about the last time that an IAM role was used. See 
role_last_usedfor details. - Map<String,String>
 - Tags attached to the role.
 - unique
Id String - Stable and unique string identifying the role.
 
- arn string
 - ARN of the role.
 - assume
Role stringPolicy  - Policy document associated with the role.
 - create
Date string - Creation date of the role in RFC 3339 format.
 - description string
 - Description for the role.
 - id string
 - The provider-assigned unique ID for this managed resource.
 - max
Session numberDuration  - Maximum session duration.
 - name string
 - path string
 - Path to the role.
 - permissions
Boundary string - The ARN of the policy that is used to set the permissions boundary for the role.
 - role
Last GetUseds Role Role Last Used[]  - Contains information about the last time that an IAM role was used. See 
role_last_usedfor details. - {[key: string]: string}
 - Tags attached to the role.
 - unique
Id string - Stable and unique string identifying the role.
 
- arn str
 - ARN of the role.
 - assume_
role_ strpolicy  - Policy document associated with the role.
 - create_
date str - Creation date of the role in RFC 3339 format.
 - description str
 - Description for the role.
 - id str
 - The provider-assigned unique ID for this managed resource.
 - max_
session_ intduration  - Maximum session duration.
 - name str
 - path str
 - Path to the role.
 - permissions_
boundary str - The ARN of the policy that is used to set the permissions boundary for the role.
 - role_
last_ Sequence[Getuseds Role Role Last Used]  - Contains information about the last time that an IAM role was used. See 
role_last_usedfor details. - Mapping[str, str]
 - Tags attached to the role.
 - unique_
id str - Stable and unique string identifying the role.
 
- arn String
 - ARN of the role.
 - assume
Role StringPolicy  - Policy document associated with the role.
 - create
Date String - Creation date of the role in RFC 3339 format.
 - description String
 - Description for the role.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - max
Session NumberDuration  - Maximum session duration.
 - name String
 - path String
 - Path to the role.
 - permissions
Boundary String - The ARN of the policy that is used to set the permissions boundary for the role.
 - role
Last List<Property Map>Useds  - Contains information about the last time that an IAM role was used. See 
role_last_usedfor details. - Map<String>
 - Tags attached to the role.
 - unique
Id String - Stable and unique string identifying the role.
 
Supporting Types
GetRoleRoleLastUsed    
- Last
Used stringDate  - The date and time, in RFC 3339 format, that the role was last used.
 - Region string
 - The name of the AWS Region in which the role was last used.
 
- Last
Used stringDate  - The date and time, in RFC 3339 format, that the role was last used.
 - Region string
 - The name of the AWS Region in which the role was last used.
 
- last
Used StringDate  - The date and time, in RFC 3339 format, that the role was last used.
 - region String
 - The name of the AWS Region in which the role was last used.
 
- last
Used stringDate  - The date and time, in RFC 3339 format, that the role was last used.
 - region string
 - The name of the AWS Region in which the role was last used.
 
- last_
used_ strdate  - The date and time, in RFC 3339 format, that the role was last used.
 - region str
 - The name of the AWS Region in which the role was last used.
 
- last
Used StringDate  - The date and time, in RFC 3339 format, that the role was last used.
 - region String
 - The name of the AWS Region in which the role was last used.
 
Package Details
- Repository
 - AWS Classic pulumi/pulumi-aws
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
awsTerraform Provider.