Skip to content

AWS::IAM::Role

Creates a new role for your AWS-account.

Generated by cfn-typegen --out cfn_types AWS::IAM::Role into cfn_types/iam.py:

# Generated by cfn-typegen from the CloudFormation registry schemas. Do not edit.
# fmt: off
# ruff: noqa
"""AWS::IAM resources."""

from collections.abc import Mapping, Sequence
from typing import Any, Literal, NotRequired, Unpack
from typing_extensions import TypedDict
from cfn_typed.base import DeletionPolicy, DependsOn, ResourceAttrs, Tag, UpdateReplacePolicy, build
from cfn_typed.intrinsics import Expr


CONSTRAINTS:dict[str,Any]={
}


ATTRIBUTES:dict[str,Any]={"AWS::IAM::Role":["Arn","RoleId","RoleName"]}


RULES:dict[str,Any]={}
Nested types (4)

These are defined above the properties in the generated module.

class RolePolicy(TypedDict, closed=True):
    'Contains information about an attached policy.'
    PolicyDocument: Expr[str] | Expr[Mapping[str, Any]]
    'The entire contents of the policy that defines permissions.'
    PolicyName: Expr[str]
    'The friendly name (not ARN) identifying the policy.'


class RoleProps(TypedDict, closed=True):
    'Creates a new role for your AWS-account.'
    AssumeRolePolicyDocument: Expr[Mapping[str, Any]] | Expr[str]
    'The trust policy that is associated with this role.'
    Description: NotRequired[Expr[str]]
    'A description of the role that you provide.'
    ManagedPolicyArns: NotRequired[Expr[list[Expr[str]]]]
    'A list of Amazon Resource Names (ARNs) of the IAM managed policies that you want to attach to the role.'
    MaxSessionDuration: NotRequired[Expr[int]]
    'The maximum session duration (in seconds) that you want to set for the specified role.'
    Path: NotRequired[Expr[str]]
    'The path to the role.'
    PermissionsBoundary: NotRequired[Expr[str]]
    'The ARN of the policy used to set the permissions boundary for the role.'
    Policies: NotRequired[Expr[Sequence[Expr[RolePolicy]]]]
    'Adds or updates an inline policy document that is embedded in the specified IAM role.'
    RoleName: NotRequired[Expr[str]]
    'A name for the IAM role, up to 64 characters in length.'
    Tags: NotRequired[Expr[Sequence[Expr[Tag]]]]
    'A list of tags that are attached to the role.'


class Role(ResourceAttrs):
    'Creates a new role for your AWS-account.'
    Type: Literal['AWS::IAM::Role']
    Properties: RoleProps


def role(
    *,
    depends_on: DependsOn | None = None,
    deletion_policy: DeletionPolicy | None = None,
    update_replace_policy: UpdateReplacePolicy | None = None,
    condition: str | None = None,
    metadata: dict[str, Any] | None = None,
    **props: Unpack[RoleProps],
) -> Role:
    return build('AWS::IAM::Role', props, depends_on, deletion_policy, update_replace_policy, condition, metadata)

Attributes

Read-only values for get_att(logical_id, attribute). They are not accepted as inputs.

  • Arn
  • RoleId