Show / Hide Table of Contents

Class Role

Provides an IAM role.

NOTE: If policies are attached to the role via the aws.iam.PolicyAttachment resource and you are modifying the role name or path, the force_detach_policies argument must be set to true and applied before attempting the operation otherwise you will encounter a DeleteConflict error. The aws.iam.RolePolicyAttachment resource (recommended) does not have this requirement.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var testRole = new Aws.Iam.Role("testRole", new Aws.Iam.RoleArgs
    {
        AssumeRolePolicy = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
  ""Action"": ""sts:AssumeRole"",
  ""Principal"": {
    ""Service"": ""ec2.amazonaws.com""
  },
  ""Effect"": ""Allow"",
  ""Sid"": """"
}
]
}

",
        Tags = 
        {
            { "tag-key", "tag-value" },
        },
    });
}

}

Example of Using Data Source for Assume Role Policy

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var instance_assume_role_policy = Output.Create(Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
    {
        Statements = 
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
            {
                Actions = 
                {
                    "sts:AssumeRole",
                },
                Principals = 
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
                    {
                        Identifiers = 
                        {
                            "ec2.amazonaws.com",
                        },
                        Type = "Service",
                    },
                },
            },
        },
    }));
    var instance = new Aws.Iam.Role("instance", new Aws.Iam.RoleArgs
    {
        AssumeRolePolicy = instance_assume_role_policy.Apply(instance_assume_role_policy => instance_assume_role_policy.Json),
        Path = "/system/",
    });
}

}
Inheritance
System.Object
Resource
CustomResource
Role
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.Iam
Assembly: Pulumi.Aws.dll
Syntax
public class Role : CustomResource

Constructors

View Source

Role(String, RoleArgs, CustomResourceOptions)

Create a Role resource with the given unique name, arguments, and options.

Declaration
public Role(string name, RoleArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

RoleArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Arn

The Amazon Resource Name (ARN) specifying the role.

Declaration
public Output<string> Arn { get; }
Property Value
Type Description
Output<System.String>
View Source

AssumeRolePolicy

The policy that grants an entity permission to assume the role.

Declaration
public Output<string> AssumeRolePolicy { get; }
Property Value
Type Description
Output<System.String>
View Source

CreateDate

The creation date of the IAM role.

Declaration
public Output<string> CreateDate { get; }
Property Value
Type Description
Output<System.String>
View Source

Description

The description of the role.

Declaration
public Output<string> Description { get; }
Property Value
Type Description
Output<System.String>
View Source

ForceDetachPolicies

Specifies to force detaching any policies the role has before destroying it. Defaults to false.

Declaration
public Output<bool?> ForceDetachPolicies { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

MaxSessionDuration

The maximum session duration (in seconds) that you want to set for the specified role. If you do not specify a value for this setting, the default maximum of one hour is applied. This setting can have a value from 1 hour to 12 hours.

Declaration
public Output<int?> MaxSessionDuration { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

Name

The name of the role. If omitted, this provider will assign a random, unique name.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

NamePrefix

Creates a unique name beginning with the specified prefix. Conflicts with name.

Declaration
public Output<string> NamePrefix { get; }
Property Value
Type Description
Output<System.String>
View Source

Path

The path to the role. See IAM Identifiers for more information.

Declaration
public Output<string> Path { get; }
Property Value
Type Description
Output<System.String>
View Source

PermissionsBoundary

The ARN of the policy that is used to set the permissions boundary for the role.

Declaration
public Output<string> PermissionsBoundary { get; }
Property Value
Type Description
Output<System.String>
View Source

Tags

Key-value map of tags for the IAM role

Declaration
public Output<ImmutableDictionary<string, object>> Tags { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>>
View Source

UniqueId

The stable and unique string identifying the role.

Declaration
public Output<string> UniqueId { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, RoleState, CustomResourceOptions)

Get an existing Role resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static Role Get(string name, Input<string> id, RoleState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

RoleState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Role
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.