pulumi

  1. Registry
  2. Packages
  3. AWS
  4. API Docs
  5. iam
  6. Role

aws logo aws logo

AWS v7.43.0, Aug 20 26

aws logo aws logo

AWS v7.43.0, Aug 20 26

Viewing docs for AWS v7.43.0
published on Thursday, Aug 20, 2026 by Pulumi

pulumi/pulumi-aws

aws logo aws logo

Viewing docs for AWS v7.43.0
published on Thursday, Aug 20, 2026 by Pulumi

pulumi/pulumi-aws

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 forceDetachPolicies 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.

NOTE: If you use this resource’s managedPolicyArns argument or inlinePolicy configuration blocks, this resource will take over exclusive management of the role’s respective policy types (e.g., both policy types if both arguments are used). These arguments are incompatible with other ways of managing a role’s policies, such as aws.iam.PolicyAttachment, aws.iam.RolePolicyAttachment, and aws.iam.RolePolicy. If you attempt to manage a role’s policies by multiple means, you will get resource cycling and/or errors.

NOTE: We suggest using explicit JSON encoding or aws.iam.getPolicyDocument when assigning a value to policy. They seamlessly translate configuration to JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON.

Example Usage

Basic Example

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const testRole = new aws.iam.Role("test_role", {
    name: "test_role",
    assumeRolePolicy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: "sts:AssumeRole",
            Effect: "Allow",
            Sid: "",
            Principal: {
                Service: "ec2.amazonaws.com",
            },
        }],
    }),
    tags: {
        "tag-key": "tag-value",
    },
});
import pulumi
import json
import pulumi_aws as aws

test_role = aws.iam.Role("test_role",
    name="test_role",
    assume_role_policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": "sts:AssumeRole",
            "Effect": "Allow",
            "Sid": "",
            "Principal": {
                "Service": "ec2.amazonaws.com",
            },
        }],
    }),
    tags={
        "tag-key": "tag-value",
    })
package main

import (
	"encoding/json"

	"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 {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": "sts:AssumeRole",
					"Effect": "Allow",
					"Sid":    "",
					"Principal": map[string]string{
						"Service": "ec2.amazonaws.com",
					},
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = iam.NewRole(ctx, "test_role", &iam.RoleArgs{
			Name:             pulumi.String("test_role"),
			AssumeRolePolicy: pulumi.String(json0),
			Tags: pulumi.StringMap{
				"tag-key": pulumi.String("tag-value"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var testRole = new Aws.Iam.Role("test_role", new()
    {
        Name = "test_role",
        AssumeRolePolicy = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = "sts:AssumeRole",
                    ["Effect"] = "Allow",
                    ["Sid"] = "",
                    ["Principal"] = new Dictionary<string, object?>
                    {
                        ["Service"] = "ec2.amazonaws.com",
                    },
                },
            },
        }),
        Tags =
        {
            { "tag-key", "tag-value" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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) {
        var testRole = new Role("testRole", RoleArgs.builder()
            .name("test_role")
            .assumeRolePolicy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", "sts:AssumeRole"),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Sid", ""),
                        jsonProperty("Principal", jsonObject(
                            jsonProperty("Service", "ec2.amazonaws.com")
                        ))
                    )))
                )))
            .tags(Map.of("tag-key", "tag-value"))
            .build());

    }
}
resources:
  testRole:
    type: aws:iam:Role
    name: test_role
    properties:
      name: test_role
      assumeRolePolicy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action: sts:AssumeRole
              Effect: Allow
              Sid: ""
              Principal:
                Service: ec2.amazonaws.com
      tags:
        tag-key: tag-value
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_iam_role" "test_role" {
  name = "test_role"
  assume_role_policy = jsonencode({
    "Version" = "2012-10-17"
    "Statement" = [{
      "Action" = "sts:AssumeRole"
      "Effect" = "Allow"
      "Sid"    = ""
      "Principal" = {
        "Service" = "ec2.amazonaws.com"
      }
    }]
  })
  tags = {
    "tag-key" = "tag-value"
  }
}

Example of Using Data Source for Assume Role Policy

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const instanceAssumeRolePolicy = aws.iam.getPolicyDocument({
    statements: [{
        actions: ["sts:AssumeRole"],
        principals: [{
            type: "Service",
            identifiers: ["ec2.amazonaws.com"],
        }],
    }],
});
const instance = new aws.iam.Role("instance", {
    name: "instance_role",
    path: "/system/",
    assumeRolePolicy: instanceAssumeRolePolicy.then(instanceAssumeRolePolicy => instanceAssumeRolePolicy.json),
});
import pulumi
import pulumi_aws as aws

instance_assume_role_policy = aws.iam.get_policy_document(statements=[{
    "actions": ["sts:AssumeRole"],
    "principals": [{
        "type": "Service",
        "identifiers": ["ec2.amazonaws.com"],
    }],
}])
instance = aws.iam.Role("instance",
    name="instance_role",
    path="/system/",
    assume_role_policy=instance_assume_role_policy.json)
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 {
		instanceAssumeRolePolicy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Actions: []string{
						"sts:AssumeRole",
					},
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"ec2.amazonaws.com",
							},
						},
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = iam.NewRole(ctx, "instance", &iam.RoleArgs{
			Name:             pulumi.String("instance_role"),
			Path:             pulumi.String("/system/"),
			AssumeRolePolicy: pulumi.String(instanceAssumeRolePolicy.Json),
		})
		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 instanceAssumeRolePolicy = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "ec2.amazonaws.com",
                        },
                    },
                },
            },
        },
    });

    var instance = new Aws.Iam.Role("instance", new()
    {
        Name = "instance_role",
        Path = "/system/",
        AssumeRolePolicy = instanceAssumeRolePolicy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

});
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.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
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 instanceAssumeRolePolicy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .actions("sts:AssumeRole")
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("ec2.amazonaws.com")
                    .build())
                .build())
            .build());

        var instance = new Role("instance", RoleArgs.builder()
            .name("instance_role")
            .path("/system/")
            .assumeRolePolicy(instanceAssumeRolePolicy.json())
            .build());

    }
}
resources:
  instance:
    type: aws:iam:Role
    properties:
      name: instance_role
      path: /system/
      assumeRolePolicy: ${instanceAssumeRolePolicy.json}
variables:
  instanceAssumeRolePolicy:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - actions:
              - sts:AssumeRole
            principals:
              - type: Service
                identifiers:
                  - ec2.amazonaws.com
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "instanceAssumeRolePolicy" {
  statements {
    actions = ["sts:AssumeRole"]
    principals {
      type        = "Service"
      identifiers = ["ec2.amazonaws.com"]
    }
  }
}

resource "aws_iam_role" "instance" {
  name               = "instance_role"
  path               = "/system/"
  assume_role_policy = data.aws_iam_getpolicydocument.instanceAssumeRolePolicy.json
}

Example of Exclusive Inline Policies

The inlinePolicy argument is deprecated. Use the aws.iam.RolePolicy resource instead. If Pulumi should exclusively manage all inline policy associations (the current behavior of this argument), use the aws.iam.RolePoliciesExclusive resource as well.

This example creates an IAM role with two inline IAM policies. If someone adds another inline policy out-of-band, on the next apply, this provider will remove that policy. If someone deletes these policies out-of-band, this provider will recreate them.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const inlinePolicy = aws.iam.getPolicyDocument({
    statements: [{
        actions: ["ec2:DescribeAccountAttributes"],
        resources: ["*"],
    }],
});
const example = new aws.iam.Role("example", {
    name: "yak_role",
    assumeRolePolicy: instanceAssumeRolePolicy.json,
    inlinePolicies: [
        {
            name: "my_inline_policy",
            policy: JSON.stringify({
                Version: "2012-10-17",
                Statement: [{
                    Action: ["ec2:Describe*"],
                    Effect: "Allow",
                    Resource: "*",
                }],
            }),
        },
        {
            name: "policy-8675309",
            policy: inlinePolicy.then(inlinePolicy => inlinePolicy.json),
        },
    ],
});
import pulumi
import json
import pulumi_aws as aws

inline_policy = aws.iam.get_policy_document(statements=[{
    "actions": ["ec2:DescribeAccountAttributes"],
    "resources": ["*"],
}])
example = aws.iam.Role("example",
    name="yak_role",
    assume_role_policy=instance_assume_role_policy["json"],
    inline_policies=[
        {
            "name": "my_inline_policy",
            "policy": json.dumps({
                "Version": "2012-10-17",
                "Statement": [{
                    "Action": ["ec2:Describe*"],
                    "Effect": "Allow",
                    "Resource": "*",
                }],
            }),
        },
        {
            "name": "policy-8675309",
            "policy": inline_policy.json,
        },
    ])
package main

import (
	"encoding/json"

	"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 {
		inlinePolicy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Actions: []string{
						"ec2:DescribeAccountAttributes",
					},
					Resources: []string{
						"*",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"ec2:Describe*",
					},
					"Effect":   "Allow",
					"Resource": "*",
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = iam.NewRole(ctx, "example", &iam.RoleArgs{
			Name:             pulumi.String("yak_role"),
			AssumeRolePolicy: pulumi.Any(instanceAssumeRolePolicy.Json),
			InlinePolicies: iam.RoleInlinePolicyArray{
				&iam.RoleInlinePolicyArgs{
					Name:   pulumi.String("my_inline_policy"),
					Policy: pulumi.String(json0),
				},
				&iam.RoleInlinePolicyArgs{
					Name:   pulumi.String("policy-8675309"),
					Policy: pulumi.String(inlinePolicy.Json),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var inlinePolicy = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Actions = new[]
                {
                    "ec2:DescribeAccountAttributes",
                },
                Resources = new[]
                {
                    "*",
                },
            },
        },
    });

    var example = new Aws.Iam.Role("example", new()
    {
        Name = "yak_role",
        AssumeRolePolicy = instanceAssumeRolePolicy.Json,
        InlinePolicies = new[]
        {
            new Aws.Iam.Inputs.RoleInlinePolicyArgs
            {
                Name = "my_inline_policy",
                Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
                {
                    ["Version"] = "2012-10-17",
                    ["Statement"] = new[]
                    {
                        new Dictionary<string, object?>
                        {
                            ["Action"] = new[]
                            {
                                "ec2:Describe*",
                            },
                            ["Effect"] = "Allow",
                            ["Resource"] = "*",
                        },
                    },
                }),
            },
            new Aws.Iam.Inputs.RoleInlinePolicyArgs
            {
                Name = "policy-8675309",
                Policy = inlinePolicy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
            },
        },
    });

});
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.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.inputs.RoleInlinePolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 inlinePolicy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .actions("ec2:DescribeAccountAttributes")
                .resources("*")
                .build())
            .build());

        var example = new Role("example", RoleArgs.builder()
            .name("yak_role")
            .assumeRolePolicy(instanceAssumeRolePolicy.json())
            .inlinePolicies(
                RoleInlinePolicyArgs.builder()
                    .name("my_inline_policy")
                    .policy(serializeJson(
                        jsonObject(
                            jsonProperty("Version", "2012-10-17"),
                            jsonProperty("Statement", jsonArray(jsonObject(
                                jsonProperty("Action", jsonArray("ec2:Describe*")),
                                jsonProperty("Effect", "Allow"),
                                jsonProperty("Resource", "*")
                            )))
                        )))
                    .build(),
                RoleInlinePolicyArgs.builder()
                    .name("policy-8675309")
                    .policy(inlinePolicy.json())
                    .build())
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      name: yak_role
      assumeRolePolicy: ${instanceAssumeRolePolicy.json}
      inlinePolicies:
        - name: my_inline_policy
          policy:
            fn::toJSON:
              Version: 2012-10-17
              Statement:
                - Action:
                    - ec2:Describe*
                  Effect: Allow
                  Resource: '*'
        - name: policy-8675309
          policy: ${inlinePolicy.json}
variables:
  inlinePolicy:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - actions:
              - ec2:DescribeAccountAttributes
            resources:
              - '*'
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "inlinePolicy" {
  statements {
    actions   = ["ec2:DescribeAccountAttributes"]
    resources = ["*"]
  }
}

resource "aws_iam_role" "example" {
  name               = "yak_role"
  assume_role_policy = instanceAssumeRolePolicy.json
  inline_policies {
    name = "my_inline_policy"
    policy = jsonencode({
      "Version" = "2012-10-17"
      "Statement" = [{
        "Action"   = ["ec2:Describe*"]
        "Effect"   = "Allow"
        "Resource" = "*"
      }]
    })
  }
  inline_policies {
    name   = "policy-8675309"
    policy = data.aws_iam_getpolicydocument.inlinePolicy.json
  }
}

Example of Removing Inline Policies

The inlinePolicy argument is deprecated. Use the aws.iam.RolePolicy resource instead. If Pulumi should exclusively manage all inline policy associations (the current behavior of this argument), use the aws.iam.RolePoliciesExclusive resource as well.

This example creates an IAM role with what appears to be empty IAM inlinePolicy argument instead of using inlinePolicy as a configuration block. The result is that if someone were to add an inline policy out-of-band, on the next apply, this provider will remove that policy.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.iam.Role("example", {
    inlinePolicies: [{}],
    name: "yak_role",
    assumeRolePolicy: instanceAssumeRolePolicy.json,
});
import pulumi
import pulumi_aws as aws

example = aws.iam.Role("example",
    inline_policies=[{}],
    name="yak_role",
    assume_role_policy=instance_assume_role_policy["json"])
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.NewRole(ctx, "example", &iam.RoleArgs{
			InlinePolicies: iam.RoleInlinePolicyArray{
				&iam.RoleInlinePolicyArgs{},
			},
			Name:             pulumi.String("yak_role"),
			AssumeRolePolicy: pulumi.Any(instanceAssumeRolePolicy.Json),
		})
		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 = new Aws.Iam.Role("example", new()
    {
        InlinePolicies = new[]
        {
            null,
        },
        Name = "yak_role",
        AssumeRolePolicy = instanceAssumeRolePolicy.Json,
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.inputs.RoleInlinePolicyArgs;
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) {
        var example = new Role("example", RoleArgs.builder()
            .inlinePolicies(RoleInlinePolicyArgs.builder()
                .build())
            .name("yak_role")
            .assumeRolePolicy(instanceAssumeRolePolicy.json())
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      inlinePolicies:
        - {}
      name: yak_role
      assumeRolePolicy: ${instanceAssumeRolePolicy.json}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_iam_role" "example" {
  inline_policies {
  }
  name               = "yak_role"
  assume_role_policy = instanceAssumeRolePolicy.json
}

Example of Exclusive Managed Policies

The managedPolicyArns argument is deprecated. Use the aws.iam.RolePolicyAttachment resource instead. If Pulumi should exclusively manage all managed policy attachments (the current behavior of this argument), use the aws.iam.RolePolicyAttachmentsExclusive resource as well.

This example creates an IAM role and attaches two managed IAM policies. If someone attaches another managed policy out-of-band, on the next apply, this provider will detach that policy. If someone detaches these policies out-of-band, this provider will attach them again.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const policyOne = new aws.iam.Policy("policy_one", {
    name: "policy-618033",
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: ["ec2:Describe*"],
            Effect: "Allow",
            Resource: "*",
        }],
    }),
});
const policyTwo = new aws.iam.Policy("policy_two", {
    name: "policy-381966",
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: [
                "s3:ListAllMyBuckets",
                "s3:ListBucket",
                "s3:HeadBucket",
            ],
            Effect: "Allow",
            Resource: "*",
        }],
    }),
});
const example = new aws.iam.Role("example", {
    name: "yak_role",
    assumeRolePolicy: instanceAssumeRolePolicy.json,
    managedPolicyArns: [
        policyOne.arn,
        policyTwo.arn,
    ],
});
import pulumi
import json
import pulumi_aws as aws

policy_one = aws.iam.Policy("policy_one",
    name="policy-618033",
    policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": ["ec2:Describe*"],
            "Effect": "Allow",
            "Resource": "*",
        }],
    }))
policy_two = aws.iam.Policy("policy_two",
    name="policy-381966",
    policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": [
                "s3:ListAllMyBuckets",
                "s3:ListBucket",
                "s3:HeadBucket",
            ],
            "Effect": "Allow",
            "Resource": "*",
        }],
    }))
example = aws.iam.Role("example",
    name="yak_role",
    assume_role_policy=instance_assume_role_policy["json"],
    managed_policy_arns=[
        policy_one.arn,
        policy_two.arn,
    ])
package main

import (
	"encoding/json"

	"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 {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"ec2:Describe*",
					},
					"Effect":   "Allow",
					"Resource": "*",
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		policyOne, err := iam.NewPolicy(ctx, "policy_one", &iam.PolicyArgs{
			Name:   pulumi.String("policy-618033"),
			Policy: pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		tmpJSON1, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"s3:ListAllMyBuckets",
						"s3:ListBucket",
						"s3:HeadBucket",
					},
					"Effect":   "Allow",
					"Resource": "*",
				},
			},
		})
		if err != nil {
			return err
		}
		json1 := string(tmpJSON1)
		policyTwo, err := iam.NewPolicy(ctx, "policy_two", &iam.PolicyArgs{
			Name:   pulumi.String("policy-381966"),
			Policy: pulumi.String(json1),
		})
		if err != nil {
			return err
		}
		_, err = iam.NewRole(ctx, "example", &iam.RoleArgs{
			Name:             pulumi.String("yak_role"),
			AssumeRolePolicy: pulumi.Any(instanceAssumeRolePolicy.Json),
			ManagedPolicyArns: pulumi.StringArray{
				policyOne.Arn,
				policyTwo.Arn,
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var policyOne = new Aws.Iam.Policy("policy_one", new()
    {
        Name = "policy-618033",
        PolicyDocument = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "ec2:Describe*",
                    },
                    ["Effect"] = "Allow",
                    ["Resource"] = "*",
                },
            },
        }),
    });

    var policyTwo = new Aws.Iam.Policy("policy_two", new()
    {
        Name = "policy-381966",
        PolicyDocument = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "s3:ListAllMyBuckets",
                        "s3:ListBucket",
                        "s3:HeadBucket",
                    },
                    ["Effect"] = "Allow",
                    ["Resource"] = "*",
                },
            },
        }),
    });

    var example = new Aws.Iam.Role("example", new()
    {
        Name = "yak_role",
        AssumeRolePolicy = instanceAssumeRolePolicy.Json,
        ManagedPolicyArns = new[]
        {
            policyOne.Arn,
            policyTwo.Arn,
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.Policy;
import com.pulumi.aws.iam.PolicyArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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) {
        var policyOne = new Policy("policyOne", PolicyArgs.builder()
            .name("policy-618033")
            .policy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", jsonArray("ec2:Describe*")),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Resource", "*")
                    )))
                )))
            .build());

        var policyTwo = new Policy("policyTwo", PolicyArgs.builder()
            .name("policy-381966")
            .policy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", jsonArray(
                            "s3:ListAllMyBuckets",
                            "s3:ListBucket",
                            "s3:HeadBucket"
                        )),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Resource", "*")
                    )))
                )))
            .build());

        var example = new Role("example", RoleArgs.builder()
            .name("yak_role")
            .assumeRolePolicy(instanceAssumeRolePolicy.json())
            .managedPolicyArns(
                policyOne.arn(),
                policyTwo.arn())
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      name: yak_role
      assumeRolePolicy: ${instanceAssumeRolePolicy.json}
      managedPolicyArns:
        - ${policyOne.arn}
        - ${policyTwo.arn}
  policyOne:
    type: aws:iam:Policy
    name: policy_one
    properties:
      name: policy-618033
      policy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action:
                - ec2:Describe*
              Effect: Allow
              Resource: '*'
  policyTwo:
    type: aws:iam:Policy
    name: policy_two
    properties:
      name: policy-381966
      policy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action:
                - s3:ListAllMyBuckets
                - s3:ListBucket
                - s3:HeadBucket
              Effect: Allow
              Resource: '*'
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_iam_role" "example" {
  name                = "yak_role"
  assume_role_policy  = instanceAssumeRolePolicy.json
  managed_policy_arns = [aws_iam_policy.policy_one.arn, aws_iam_policy.policy_two.arn]
}
resource "aws_iam_policy" "policy_one" {
  name = "policy-618033"
  policy = jsonencode({
    "Version" = "2012-10-17"
    "Statement" = [{
      "Action"   = ["ec2:Describe*"]
      "Effect"   = "Allow"
      "Resource" = "*"
    }]
  })
}
resource "aws_iam_policy" "policy_two" {
  name = "policy-381966"
  policy = jsonencode({
    "Version" = "2012-10-17"
    "Statement" = [{
      "Action"   = ["s3:ListAllMyBuckets", "s3:ListBucket", "s3:HeadBucket"]
      "Effect"   = "Allow"
      "Resource" = "*"
    }]
  })
}

Example of Removing Managed Policies

The managedPolicyArns argument is deprecated. Use the aws.iam.RolePolicyAttachment resource instead. If Pulumi should exclusively manage all managed policy attachments (the current behavior of this argument), use the aws.iam.RolePolicyAttachmentsExclusive resource as well.

This example creates an IAM role with an empty managedPolicyArns argument. If someone attaches a policy out-of-band, on the next apply, this provider will detach that policy.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.iam.Role("example", {
    name: "yak_role",
    assumeRolePolicy: instanceAssumeRolePolicy.json,
    managedPolicyArns: [],
});
import pulumi
import pulumi_aws as aws

example = aws.iam.Role("example",
    name="yak_role",
    assume_role_policy=instance_assume_role_policy["json"],
    managed_policy_arns=[])
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.NewRole(ctx, "example", &iam.RoleArgs{
			Name:              pulumi.String("yak_role"),
			AssumeRolePolicy:  pulumi.Any(instanceAssumeRolePolicy.Json),
			ManagedPolicyArns: pulumi.StringArray{},
		})
		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 = new Aws.Iam.Role("example", new()
    {
        Name = "yak_role",
        AssumeRolePolicy = instanceAssumeRolePolicy.Json,
        ManagedPolicyArns = new[] {},
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
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) {
        var example = new Role("example", RoleArgs.builder()
            .name("yak_role")
            .assumeRolePolicy(instanceAssumeRolePolicy.json())
            .managedPolicyArns()
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      name: yak_role
      assumeRolePolicy: ${instanceAssumeRolePolicy.json}
      managedPolicyArns: []
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_iam_role" "example" {
  name                = "yak_role"
  assume_role_policy  = instanceAssumeRolePolicy.json
  managed_policy_arns = []
}

Create Role Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

@overload
def Role(resource_name: str,
         args: RoleArgs,
         opts: Optional[ResourceOptions] = None)

@overload
def Role(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         assume_role_policy: Optional[Union[str, PolicyDocumentArgs]] = None,
         description: Optional[str] = None,
         force_detach_policies: Optional[bool] = None,
         inline_policies: Optional[Sequence[RoleInlinePolicyArgs]] = None,
         managed_policy_arns: Optional[Sequence[str]] = None,
         max_session_duration: Optional[int] = None,
         name: Optional[str] = None,
         name_prefix: Optional[str] = None,
         path: Optional[str] = None,
         permissions_boundary: Optional[str] = None,
         tags: Optional[Mapping[str, str]] = None)
public Role(String name, RoleArgs args)
public Role(String name, RoleArgs args, CustomResourceOptions options)
type: aws:iam:Role
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

resource "aws_iam_role" "name" {
    # resource properties
}

Parameters

name string
The unique name of the resource.
args RoleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args RoleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args RoleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RoleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args RoleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var roleResource = new Aws.Iam.Role("roleResource", new()
{
    AssumeRolePolicy = "string",
    Description = "string",
    ForceDetachPolicies = false,
    InlinePolicies = new[]
    {
        new Aws.Iam.Inputs.RoleInlinePolicyArgs
        {
            Name = "string",
            Policy = "string",
        },
    },
    ManagedPolicyArns = new[]
    {
        "string",
    },
    MaxSessionDuration = 0,
    Name = "string",
    NamePrefix = "string",
    Path = "string",
    PermissionsBoundary = "string",
    Tags =
    {
        { "string", "string" },
    },
});
example, err := iam.NewRole(ctx, "roleResource", &iam.RoleArgs{
	AssumeRolePolicy:    pulumi.Any("string"),
	Description:         pulumi.String("string"),
	ForceDetachPolicies: pulumi.Bool(false),
	InlinePolicies: iam.RoleInlinePolicyArray{
		&iam.RoleInlinePolicyArgs{
			Name:   pulumi.String("string"),
			Policy: pulumi.String("string"),
		},
	},
	ManagedPolicyArns: pulumi.StringArray{
		pulumi.String("string"),
	},
	MaxSessionDuration:  pulumi.Int(0),
	Name:                pulumi.String("string"),
	NamePrefix:          pulumi.String("string"),
	Path:                pulumi.String("string"),
	PermissionsBoundary: pulumi.String("string"),
	Tags: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
})
resource "aws_iam_role" "roleResource" {
  lifecycle {
    create_before_destroy = true
  }
  assume_role_policy    = "string"
  description           = "string"
  force_detach_policies = false
  inline_policies {
    name   = "string"
    policy = "string"
  }
  managed_policy_arns  = ["string"]
  max_session_duration = 0
  name                 = "string"
  name_prefix          = "string"
  path                 = "string"
  permissions_boundary = "string"
  tags = {
    "string" = "string"
  }
}
var roleResource = new Role("roleResource", RoleArgs.builder()
    .assumeRolePolicy("string")
    .description("string")
    .forceDetachPolicies(false)
    .inlinePolicies(RoleInlinePolicyArgs.builder()
        .name("string")
        .policy("string")
        .build())
    .managedPolicyArns("string")
    .maxSessionDuration(0)
    .name("string")
    .namePrefix("string")
    .path("string")
    .permissionsBoundary("string")
    .tags(Map.of("string", "string"))
    .build());
role_resource = aws.iam.Role("roleResource",
    assume_role_policy="string",
    description="string",
    force_detach_policies=False,
    inline_policies=[{
        "name": "string",
        "policy": "string",
    }],
    managed_policy_arns=["string"],
    max_session_duration=0,
    name="string",
    name_prefix="string",
    path="string",
    permissions_boundary="string",
    tags={
        "string": "string",
    })
const roleResource = new aws.iam.Role("roleResource", {
    assumeRolePolicy: "string",
    description: "string",
    forceDetachPolicies: false,
    inlinePolicies: [{
        name: "string",
        policy: "string",
    }],
    managedPolicyArns: ["string"],
    maxSessionDuration: 0,
    name: "string",
    namePrefix: "string",
    path: "string",
    permissionsBoundary: "string",
    tags: {
        string: "string",
    },
});
type: aws:iam:Role
properties:
    assumeRolePolicy: string
    description: string
    forceDetachPolicies: false
    inlinePolicies:
        - name: string
          policy: string
    managedPolicyArns:
        - string
    maxSessionDuration: 0
    name: string
    namePrefix: string
    path: string
    permissionsBoundary: string
    tags:
        string: string

Role Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Role resource accepts the following input properties:

Assume Role Policy string | Policy Document

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

Description string
Description of the role.
Force Detach Policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
Inline Policies List<Role Inline Policy>
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
Managed Policy Arns List<string>
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
Max Session Duration int
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.
Name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
Name Prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
Path string
Path to the role. See IAM Identifiers for more information.
Permissions Boundary string
ARN of the policy that is used to set the permissions boundary for the role.
Tags Dictionary<string, string>
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Assume Role Policy string | Policy Document Args

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

Description string
Description of the role.
Force Detach Policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
Inline Policies []Role Inline Policy Args
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
Managed Policy Arns []string
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
Max Session Duration int
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.
Name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
Name Prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
Path string
Path to the role. See IAM Identifiers for more information.
Permissions Boundary string
ARN of the policy that is used to set the permissions boundary for the role.
Tags map[string]string
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
assume_ role_ policy string | object

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

description string
Description of the role.
force_ detach_ policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline_ policies list(object)
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed_ policy_ arns list(string)
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max_ session_ duration number
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.
name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name_ prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path string
Path to the role. See IAM Identifiers for more information.
permissions_ boundary string
ARN of the policy that is used to set the permissions boundary for the role.
tags map(string)
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
assume Role Policy String | Policy Document

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

description String
Description of the role.
force Detach Policies Boolean
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline Policies List<Role Inline Policy>
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed Policy Arns List<String>
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max Session Duration Integer
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.
name String
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name Prefix String
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path String
Path to the role. See IAM Identifiers for more information.
permissions Boundary String
ARN of the policy that is used to set the permissions boundary for the role.
tags Map<String,String>
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
assume Role Policy string | Policy Document

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

description string
Description of the role.
force Detach Policies boolean
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline Policies Role Inline Policy[]
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed Policy Arns string[]
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max Session Duration number
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.
name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name Prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path string
Path to the role. See IAM Identifiers for more information.
permissions Boundary string
ARN of the policy that is used to set the permissions boundary for the role.
tags {[key: string]: string}
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
assume_ role_ policy str | Policy Document Args

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

description str
Description of the role.
force_ detach_ policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline_ policies Sequence[Role Inline Policy Args]
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed_ policy_ arns Sequence[str]
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max_ session_ duration int
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.
name str
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name_ prefix str
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path str
Path to the role. See IAM Identifiers for more information.
permissions_ boundary str
ARN of the policy that is used to set the permissions boundary for the role.
tags Mapping[str, str]
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
assume Role Policy String | Property Map

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

description String
Description of the role.
force Detach Policies Boolean
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline Policies List<Property Map>
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed Policy Arns List<String>
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max Session Duration Number
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.
name String
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name Prefix String
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path String
Path to the role. See IAM Identifiers for more information.
permissions Boundary String
ARN of the policy that is used to set the permissions boundary for the role.
tags Map<String>
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Outputs

All input properties are implicitly available as output properties. Additionally, the Role resource produces the following output properties:

Arn string
Amazon Resource Name (ARN) specifying the role.
Create Date string
Creation date of the IAM role.
Id string
The provider-assigned unique ID for this managed resource.
Tags All Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
Unique Id string
Stable and unique string identifying the role.
Arn string
Amazon Resource Name (ARN) specifying the role.
Create Date string
Creation date of the IAM role.
Id string
The provider-assigned unique ID for this managed resource.
Tags All map[string]string
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
Unique Id string
Stable and unique string identifying the role.
arn string
Amazon Resource Name (ARN) specifying the role.
create_ date string
Creation date of the IAM role.
id string
The provider-assigned unique ID for this managed resource.
tags_ all map(string)
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique_ id string
Stable and unique string identifying the role.
arn String
Amazon Resource Name (ARN) specifying the role.
create Date String
Creation date of the IAM role.
id String
The provider-assigned unique ID for this managed resource.
tags All Map<String,String>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique Id String
Stable and unique string identifying the role.
arn string
Amazon Resource Name (ARN) specifying the role.
create Date string
Creation date of the IAM role.
id string
The provider-assigned unique ID for this managed resource.
tags All {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique Id string
Stable and unique string identifying the role.
arn str
Amazon Resource Name (ARN) specifying the role.
create_ date str
Creation date of the IAM role.
id str
The provider-assigned unique ID for this managed resource.
tags_ all Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique_ id str
Stable and unique string identifying the role.
arn String
Amazon Resource Name (ARN) specifying the role.
create Date String
Creation date of the IAM role.
id String
The provider-assigned unique ID for this managed resource.
tags All Map<String>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique Id String
Stable and unique string identifying the role.

Look up Existing Role Resource

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

@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        assume_role_policy: Optional[Union[str, PolicyDocumentArgs]] = None,
        create_date: Optional[str] = None,
        description: Optional[str] = None,
        force_detach_policies: Optional[bool] = None,
        inline_policies: Optional[Sequence[RoleInlinePolicyArgs]] = None,
        managed_policy_arns: Optional[Sequence[str]] = None,
        max_session_duration: Optional[int] = None,
        name: Optional[str] = None,
        name_prefix: Optional[str] = None,
        path: Optional[str] = None,
        permissions_boundary: Optional[str] = None,
        tags: Optional[Mapping[str, str]] = None,
        tags_all: Optional[Mapping[str, str]] = None,
        unique_id: Optional[str] = None) -> Role
public static Role get(String name, Output<String> id, RoleState state, CustomResourceOptions options)
resources:  _:    type: aws:iam:Role    get:      id: ${id}
import {
  to = aws_iam_role.example
  id = "${id}"
}
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Arn string
Amazon Resource Name (ARN) specifying the role.
Assume Role Policy string | Policy Document

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

Create Date string
Creation date of the IAM role.
Description string
Description of the role.
Force Detach Policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
Inline Policies List<Role Inline Policy>
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
Managed Policy Arns List<string>
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
Max Session Duration int
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.
Name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
Name Prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
Path string
Path to the role. See IAM Identifiers for more information.
Permissions Boundary string
ARN of the policy that is used to set the permissions boundary for the role.
Tags Dictionary<string, string>
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags All Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
Unique Id string
Stable and unique string identifying the role.
Arn string
Amazon Resource Name (ARN) specifying the role.
Assume Role Policy string | Policy Document Args

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

Create Date string
Creation date of the IAM role.
Description string
Description of the role.
Force Detach Policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
Inline Policies []Role Inline Policy Args
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
Managed Policy Arns []string
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
Max Session Duration int
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.
Name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
Name Prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
Path string
Path to the role. See IAM Identifiers for more information.
Permissions Boundary string
ARN of the policy that is used to set the permissions boundary for the role.
Tags map[string]string
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags All map[string]string
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
Unique Id string
Stable and unique string identifying the role.
arn string
Amazon Resource Name (ARN) specifying the role.
assume_ role_ policy string | object

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

create_ date string
Creation date of the IAM role.
description string
Description of the role.
force_ detach_ policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline_ policies list(object)
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed_ policy_ arns list(string)
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max_ session_ duration number
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.
name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name_ prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path string
Path to the role. See IAM Identifiers for more information.
permissions_ boundary string
ARN of the policy that is used to set the permissions boundary for the role.
tags map(string)
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags_ all map(string)
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique_ id string
Stable and unique string identifying the role.
arn String
Amazon Resource Name (ARN) specifying the role.
assume Role Policy String | Policy Document

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

create Date String
Creation date of the IAM role.
description String
Description of the role.
force Detach Policies Boolean
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline Policies List<Role Inline Policy>
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed Policy Arns List<String>
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max Session Duration Integer
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.
name String
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name Prefix String
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path String
Path to the role. See IAM Identifiers for more information.
permissions Boundary String
ARN of the policy that is used to set the permissions boundary for the role.
tags Map<String,String>
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags All Map<String,String>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique Id String
Stable and unique string identifying the role.
arn string
Amazon Resource Name (ARN) specifying the role.
assume Role Policy string | Policy Document

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

create Date string
Creation date of the IAM role.
description string
Description of the role.
force Detach Policies boolean
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline Policies Role Inline Policy[]
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed Policy Arns string[]
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max Session Duration number
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.
name string
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name Prefix string
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path string
Path to the role. See IAM Identifiers for more information.
permissions Boundary string
ARN of the policy that is used to set the permissions boundary for the role.
tags {[key: string]: string}
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags All {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique Id string
Stable and unique string identifying the role.
arn str
Amazon Resource Name (ARN) specifying the role.
assume_ role_ policy str | Policy Document Args

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

create_ date str
Creation date of the IAM role.
description str
Description of the role.
force_ detach_ policies bool
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline_ policies Sequence[Role Inline Policy Args]
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed_ policy_ arns Sequence[str]
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max_ session_ duration int
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.
name str
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name_ prefix str
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path str
Path to the role. See IAM Identifiers for more information.
permissions_ boundary str
ARN of the policy that is used to set the permissions boundary for the role.
tags Mapping[str, str]
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags_ all Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique_ id str
Stable and unique string identifying the role.
arn String
Amazon Resource Name (ARN) specifying the role.
assume Role Policy String | Property Map

Policy that grants an entity permission to assume the role.

NOTE: The assumeRolePolicy is very similar to but slightly different than a standard IAM policy and cannot use an aws.iam.Policy resource. However, it can use an aws.iam.getPolicyDocument data source. See the example above of how this works.

The following arguments are optional:

create Date String
Creation date of the IAM role.
description String
Description of the role.
force Detach Policies Boolean
Whether to force detaching any policies the role has before destroying it. Defaults to false.
inline Policies List<Property Map>
Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Pulumi will not manage any inline policies in this resource. Configuring one empty block (i.e., inlinePolicy {}) will cause Pulumi to remove all inline policies added out of band on apply.
managed Policy Arns List<String>
Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Pulumi will ignore policy attachments to this resource. When configured, Pulumi will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managedPolicyArns = []) will cause Pulumi to remove all managed policy attachments.
max Session Duration Number
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.
name String
Friendly name of the role. If omitted, the provider will assign a random, unique name. See IAM Identifiers for more information.
name Prefix String
Creates a unique friendly name beginning with the specified prefix. Conflicts with name.
path String
Path to the role. See IAM Identifiers for more information.
permissions Boundary String
ARN of the policy that is used to set the permissions boundary for the role.
tags Map<String>
Key-value mapping of tags for the IAM role. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
tags All Map<String>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
unique Id String
Stable and unique string identifying the role.

Supporting Types

AWSPrincipal , AWSPrincipal Args

When you use an AWS account identifier as the principal in a policy, the permissions in the policy statement can be granted to all identities contained in that account. This includes IAM users and roles in that account.
AWS string | List<string>
AWS account identifier or ARN.
AWS string | []string
AWS account identifier or ARN.
aws string | list(string)
AWS account identifier or ARN.
AWS String | List<String>
AWS account identifier or ARN.
AWS string | string[]
AWS account identifier or ARN.
aws str | Sequence[str]
AWS account identifier or ARN.
AWS String | List<String>
AWS account identifier or ARN.

Federated Principal , Federated Principal Args

Federated principal for identity providers.
Federated string | List<string>
The federated principal identifier.
Federated string | []string
The federated principal identifier.
federated string | list(string)
The federated principal identifier.
Federated String | List<String>
The federated principal identifier.
Federated string | string[]
The federated principal identifier.
federated str | Sequence[str]
The federated principal identifier.
Federated String | List<String>
The federated principal identifier.

Policy Document , Policy Document Args

Represents an AWS IAM policy document that defines permissions for AWS resources and actions.

Policy Document Version , Policy Document Version Args

Policy Document Version_2012_10_17
2012-10-17
Policy Document Version_2008_10_17
2008-10-17
Policy Document Version_2012_10_17
2012-10-17
Policy Document Version_2008_10_17
2008-10-17
"2012-10-17"
2012-10-17
"2008-10-17"
2008-10-17
_20121017
2012-10-17
_20081017
2008-10-17
Policy Document Version_2012_10_17
2012-10-17
Policy Document Version_2008_10_17
2008-10-17
POLICY_DOCUMENT_VERSION_2012_10_17
2012-10-17
POLICY_DOCUMENT_VERSION_2008_10_17
2008-10-17
"2012-10-17"
2012-10-17
"2008-10-17"
2008-10-17

Policy Statement , Policy Statement Args

The Statement element is the main element for a policy. This element is required. It can include multiple elements (see the subsequent sections in this page). The Statement element contains an array of individual statements.
Effect Pulumi. Aws. Iam. Policy Statement Effect
Indicate whether the policy allows or denies access.
Action string | List<string>
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
Condition Dictionary<string, object>
Specify the circumstances under which the policy grants permission.
Not Action string | List<string>
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
Not Principal string | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which this policy does not apply.
Not Resource string | List<string>
A list of resources that are specifically excluded by this policy.
Principal string | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
Resource string | List<string>
A list of resources to which the actions apply.
Sid string
An optional statement ID to differentiate between your statements.
Effect Policy Statement Effect
Indicate whether the policy allows or denies access.
Action string | []string
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
Condition map[string]interface{}
Specify the circumstances under which the policy grants permission.
Not Action string | []string
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
Not Principal string | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which this policy does not apply.
Not Resource string | []string
A list of resources that are specifically excluded by this policy.
Principal string | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
Resource string | []string
A list of resources to which the actions apply.
Sid string
An optional statement ID to differentiate between your statements.
effect "Allow" | "Deny"
Indicate whether the policy allows or denies access.
action string | list(string)
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
condition map(any)
Specify the circumstances under which the policy grants permission.
not_ action string | list(string)
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
not_ principal string | object | object | object
Indicate the account, user, role, or federated user to which this policy does not apply.
not_ resource string | list(string)
A list of resources that are specifically excluded by this policy.
principal string | object | object | object
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
resource string | list(string)
A list of resources to which the actions apply.
sid string
An optional statement ID to differentiate between your statements.
Effect Policy Statement Effect
Indicate whether the policy allows or denies access.
Action String | List<String>
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
Condition Map<String,Object>
Specify the circumstances under which the policy grants permission.
Not Action String | List<String>
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
Not Principal String | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which this policy does not apply.
Not Resource String | List<String>
A list of resources that are specifically excluded by this policy.
Principal String | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
Resource String | List<String>
A list of resources to which the actions apply.
Sid String
An optional statement ID to differentiate between your statements.
Effect Policy Statement Effect
Indicate whether the policy allows or denies access.
Action string | string[]
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
Condition {[key: string]: any}
Specify the circumstances under which the policy grants permission.
Not Action string | string[]
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
Not Principal string | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which this policy does not apply.
Not Resource string | string[]
A list of resources that are specifically excluded by this policy.
Principal string | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
Resource string | string[]
A list of resources to which the actions apply.
Sid string
An optional statement ID to differentiate between your statements.
effect Policy Statement Effect
Indicate whether the policy allows or denies access.
action str | Sequence[str]
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
condition Mapping[str, Any]
Specify the circumstances under which the policy grants permission.
not_ action str | Sequence[str]
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
not_ principal str | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which this policy does not apply.
not_ resource str | Sequence[str]
A list of resources that are specifically excluded by this policy.
principal str | AWSPrincipal | Service Principal | Federated Principal
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
resource str | Sequence[str]
A list of resources to which the actions apply.
sid str
An optional statement ID to differentiate between your statements.
Effect "Allow" | "Deny"
Indicate whether the policy allows or denies access.
Action String | List<String>
Include a list of actions that the policy allows or denies. Required (either Action or NotAction)
Condition Map<Any>
Specify the circumstances under which the policy grants permission.
Not Action String | List<String>
Include a list of actions that are not covered by this policy. Required (either Action or NotAction)
Not Principal String | Property Map | Property Map | Property Map
Indicate the account, user, role, or federated user to which this policy does not apply.
Not Resource String | List<String>
A list of resources that are specifically excluded by this policy.
Principal String | Property Map | Property Map | Property Map
Indicate the account, user, role, or federated user to which you would like to allow or deny access. If you are creating a policy to attach to a user or role, you cannot include this element. The principal is implied as that user or role.
Resource String | List<String>
A list of resources to which the actions apply.
Sid String
An optional statement ID to differentiate between your statements.

Policy Statement Effect , Policy Statement Effect Args

ALLOW
Allow
DENY
Deny
Policy Statement Effect ALLOW
Allow
Policy Statement Effect DENY
Deny
"Allow"
Allow
"Deny"
Deny
ALLOW
Allow
DENY
Deny
ALLOW
Allow
DENY
Deny
ALLOW
Allow
DENY
Deny
"Allow"
Allow
"Deny"
Deny

Role Inline Policy , Role Inline Policy Args

Name string
Name of the role policy.
Policy string
Policy document as a JSON formatted string.
Name string
Name of the role policy.
Policy string
Policy document as a JSON formatted string.
name string
Name of the role policy.
policy string
Policy document as a JSON formatted string.
name String
Name of the role policy.
policy String
Policy document as a JSON formatted string.
name string
Name of the role policy.
policy string
Policy document as a JSON formatted string.
name str
Name of the role policy.
policy str
Policy document as a JSON formatted string.
name String
Name of the role policy.
policy String
Policy document as a JSON formatted string.

Service Principal , Service Principal Args

IAM roles that can be assumed by an AWS service are called service roles. Service roles must include a trust policy. A service principal is an identifier that is used to grant permissions to a service.
Service string | List<string>
The service principal identifier.
Service string | []string
The service principal identifier.
service string | list(string)
The service principal identifier.
Service String | List<String>
The service principal identifier.
Service string | string[]
The service principal identifier.
service str | Sequence[str]
The service principal identifier.
Service String | List<String>
The service principal identifier.

Import

Identity Schema

Required

  • name (String) Name of the IAM role.

Optional

  • accountId (String) AWS Account where this resource is managed.

Using pulumi import, import IAM Roles using the name. For example:

$ pulumi import aws:iam/role:Role example developer_name

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.

Read the original on pulumi.com ↗