RolePolicy

class RolePolicy : KotlinCustomResource

Provides an IAM role inline policy.

NOTE: For a given role, this resource is incompatible with using the aws.iam.Role resource inline_policy argument. When using that argument and this resource, both will attempt to manage the role's inline policies and the provider will show a permanent difference.

Example Usage

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.RolePolicy;
import com.pulumi.aws.iam.RolePolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var testRole = new Role("testRole", RoleArgs.builder()
.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")
))
)))
)))
.build());
var testPolicy = new RolePolicy("testPolicy", RolePolicyArgs.builder()
.role(testRole.id())
.policy(serializeJson(
jsonObject(
jsonProperty("Version", "2012-10-17"),
jsonProperty("Statement", jsonArray(jsonObject(
jsonProperty("Action", jsonArray("ec2:Describe*")),
jsonProperty("Effect", "Allow"),
jsonProperty("Resource", "*")
)))
)))
.build());
}
}

Import

IAM Role Policies can be imported using the role_name:role_policy_name, e.g.,

$ pulumi import aws:iam/rolePolicy:RolePolicy mypolicy role_of_mypolicy_name:mypolicy_name

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

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

Link copied to clipboard
val namePrefix: Output<String>?

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

Link copied to clipboard
val policy: Output<String>

The inline policy document. This is a JSON formatted string. For more information about building IAM policy documents with the provider, see the AWS IAM Policy Document Guide

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val role: Output<String>

The name of the IAM role to attach to the policy.

Link copied to clipboard
val urn: Output<String>