github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iam/getRole.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package iam
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // This data source can be used to fetch information about a specific
    15  // IAM role. By using this data source, you can reference IAM role
    16  // properties without having to hard code ARNs as input.
    17  //
    18  // ## Example Usage
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			_, err := iam.LookupRole(ctx, &iam.LookupRoleArgs{
    34  //				Name: "an_example_role_name",
    35  //			}, nil)
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			return nil
    40  //		})
    41  //	}
    42  //
    43  // ```
    44  // <!--End PulumiCodeChooser -->
    45  func LookupRole(ctx *pulumi.Context, args *LookupRoleArgs, opts ...pulumi.InvokeOption) (*LookupRoleResult, error) {
    46  	opts = internal.PkgInvokeDefaultOpts(opts)
    47  	var rv LookupRoleResult
    48  	err := ctx.Invoke("aws:iam/getRole:getRole", args, &rv, opts...)
    49  	if err != nil {
    50  		return nil, err
    51  	}
    52  	return &rv, nil
    53  }
    54  
    55  // A collection of arguments for invoking getRole.
    56  type LookupRoleArgs struct {
    57  	// Friendly IAM role name to match.
    58  	Name string `pulumi:"name"`
    59  	// Tags attached to the role.
    60  	Tags map[string]string `pulumi:"tags"`
    61  }
    62  
    63  // A collection of values returned by getRole.
    64  type LookupRoleResult struct {
    65  	// ARN of the role.
    66  	Arn string `pulumi:"arn"`
    67  	// Policy document associated with the role.
    68  	AssumeRolePolicy string `pulumi:"assumeRolePolicy"`
    69  	// Creation date of the role in RFC 3339 format.
    70  	CreateDate string `pulumi:"createDate"`
    71  	// Description for the role.
    72  	Description string `pulumi:"description"`
    73  	// The provider-assigned unique ID for this managed resource.
    74  	Id string `pulumi:"id"`
    75  	// Maximum session duration.
    76  	MaxSessionDuration int    `pulumi:"maxSessionDuration"`
    77  	Name               string `pulumi:"name"`
    78  	// Path to the role.
    79  	Path string `pulumi:"path"`
    80  	// The ARN of the policy that is used to set the permissions boundary for the role.
    81  	PermissionsBoundary string `pulumi:"permissionsBoundary"`
    82  	// Contains information about the last time that an IAM role was used. See `roleLastUsed` for details.
    83  	RoleLastUseds []GetRoleRoleLastUsed `pulumi:"roleLastUseds"`
    84  	// Tags attached to the role.
    85  	Tags map[string]string `pulumi:"tags"`
    86  	// Stable and unique string identifying the role.
    87  	UniqueId string `pulumi:"uniqueId"`
    88  }
    89  
    90  func LookupRoleOutput(ctx *pulumi.Context, args LookupRoleOutputArgs, opts ...pulumi.InvokeOption) LookupRoleResultOutput {
    91  	return pulumi.ToOutputWithContext(context.Background(), args).
    92  		ApplyT(func(v interface{}) (LookupRoleResult, error) {
    93  			args := v.(LookupRoleArgs)
    94  			r, err := LookupRole(ctx, &args, opts...)
    95  			var s LookupRoleResult
    96  			if r != nil {
    97  				s = *r
    98  			}
    99  			return s, err
   100  		}).(LookupRoleResultOutput)
   101  }
   102  
   103  // A collection of arguments for invoking getRole.
   104  type LookupRoleOutputArgs struct {
   105  	// Friendly IAM role name to match.
   106  	Name pulumi.StringInput `pulumi:"name"`
   107  	// Tags attached to the role.
   108  	Tags pulumi.StringMapInput `pulumi:"tags"`
   109  }
   110  
   111  func (LookupRoleOutputArgs) ElementType() reflect.Type {
   112  	return reflect.TypeOf((*LookupRoleArgs)(nil)).Elem()
   113  }
   114  
   115  // A collection of values returned by getRole.
   116  type LookupRoleResultOutput struct{ *pulumi.OutputState }
   117  
   118  func (LookupRoleResultOutput) ElementType() reflect.Type {
   119  	return reflect.TypeOf((*LookupRoleResult)(nil)).Elem()
   120  }
   121  
   122  func (o LookupRoleResultOutput) ToLookupRoleResultOutput() LookupRoleResultOutput {
   123  	return o
   124  }
   125  
   126  func (o LookupRoleResultOutput) ToLookupRoleResultOutputWithContext(ctx context.Context) LookupRoleResultOutput {
   127  	return o
   128  }
   129  
   130  // ARN of the role.
   131  func (o LookupRoleResultOutput) Arn() pulumi.StringOutput {
   132  	return o.ApplyT(func(v LookupRoleResult) string { return v.Arn }).(pulumi.StringOutput)
   133  }
   134  
   135  // Policy document associated with the role.
   136  func (o LookupRoleResultOutput) AssumeRolePolicy() pulumi.StringOutput {
   137  	return o.ApplyT(func(v LookupRoleResult) string { return v.AssumeRolePolicy }).(pulumi.StringOutput)
   138  }
   139  
   140  // Creation date of the role in RFC 3339 format.
   141  func (o LookupRoleResultOutput) CreateDate() pulumi.StringOutput {
   142  	return o.ApplyT(func(v LookupRoleResult) string { return v.CreateDate }).(pulumi.StringOutput)
   143  }
   144  
   145  // Description for the role.
   146  func (o LookupRoleResultOutput) Description() pulumi.StringOutput {
   147  	return o.ApplyT(func(v LookupRoleResult) string { return v.Description }).(pulumi.StringOutput)
   148  }
   149  
   150  // The provider-assigned unique ID for this managed resource.
   151  func (o LookupRoleResultOutput) Id() pulumi.StringOutput {
   152  	return o.ApplyT(func(v LookupRoleResult) string { return v.Id }).(pulumi.StringOutput)
   153  }
   154  
   155  // Maximum session duration.
   156  func (o LookupRoleResultOutput) MaxSessionDuration() pulumi.IntOutput {
   157  	return o.ApplyT(func(v LookupRoleResult) int { return v.MaxSessionDuration }).(pulumi.IntOutput)
   158  }
   159  
   160  func (o LookupRoleResultOutput) Name() pulumi.StringOutput {
   161  	return o.ApplyT(func(v LookupRoleResult) string { return v.Name }).(pulumi.StringOutput)
   162  }
   163  
   164  // Path to the role.
   165  func (o LookupRoleResultOutput) Path() pulumi.StringOutput {
   166  	return o.ApplyT(func(v LookupRoleResult) string { return v.Path }).(pulumi.StringOutput)
   167  }
   168  
   169  // The ARN of the policy that is used to set the permissions boundary for the role.
   170  func (o LookupRoleResultOutput) PermissionsBoundary() pulumi.StringOutput {
   171  	return o.ApplyT(func(v LookupRoleResult) string { return v.PermissionsBoundary }).(pulumi.StringOutput)
   172  }
   173  
   174  // Contains information about the last time that an IAM role was used. See `roleLastUsed` for details.
   175  func (o LookupRoleResultOutput) RoleLastUseds() GetRoleRoleLastUsedArrayOutput {
   176  	return o.ApplyT(func(v LookupRoleResult) []GetRoleRoleLastUsed { return v.RoleLastUseds }).(GetRoleRoleLastUsedArrayOutput)
   177  }
   178  
   179  // Tags attached to the role.
   180  func (o LookupRoleResultOutput) Tags() pulumi.StringMapOutput {
   181  	return o.ApplyT(func(v LookupRoleResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   182  }
   183  
   184  // Stable and unique string identifying the role.
   185  func (o LookupRoleResultOutput) UniqueId() pulumi.StringOutput {
   186  	return o.ApplyT(func(v LookupRoleResult) string { return v.UniqueId }).(pulumi.StringOutput)
   187  }
   188  
   189  func init() {
   190  	pulumi.RegisterOutputType(LookupRoleResultOutput{})
   191  }