Class CfnRole
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.CfnElement
software.amazon.awscdk.CfnRefElement
software.amazon.awscdk.CfnResource
software.amazon.awscdk.services.iam.CfnRole
- All Implemented Interfaces:
IEnvironmentAware,IInspectable,ITaggable,IRoleRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.118.0 (build 02eec31)",
date="2025-11-10T13:40:07.249Z")
@Stability(Stable)
public class CfnRole
extends CfnResource
implements IInspectable, IRoleRef, ITaggable
Creates a new role for your AWS account .
For more information about roles, see IAM roles in the IAM User Guide . For information about quotas for role names and the number of roles you can create, see IAM and AWS STS quotas in the IAM User Guide .
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.iam.*;
Object assumeRolePolicyDocument;
Object policyDocument;
CfnRole cfnRole = CfnRole.Builder.create(this, "MyCfnRole")
.assumeRolePolicyDocument(assumeRolePolicyDocument)
// the properties below are optional
.description("description")
.managedPolicyArns(List.of("managedPolicyArns"))
.maxSessionDuration(123)
.path("path")
.permissionsBoundary("permissionsBoundary")
.policies(List.of(PolicyProperty.builder()
.policyDocument(policyDocument)
.policyName("policyName")
.build()))
.roleName("roleName")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCfnRole.static interfaceContains information about an attached policy.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IRoleRef
IRoleRef.Jsii$Default, IRoleRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnRole(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnRole(software.amazon.jsii.JsiiObjectRef objRef) CfnRole(software.constructs.Construct scope, String id, CfnRoleProps props) -
Method Summary
Modifier and TypeMethodDescriptionThe trust policy that is associated with this role.Returns the Amazon Resource Name (ARN) for the role.Returns the stable and unique string identifying the role.A description of the role that you provide.A list of Amazon Resource Names (ARNs) of the IAM managed policies that you want to attach to the role.The maximum session duration (in seconds) that you want to set for the specified role.getPath()The path to the role.The ARN of the policy used to set the permissions boundary for the role.Adds or updates an inline policy document that is embedded in the specified IAM role.A name for the IAM role, up to 64 characters in length.A reference to a Role resource.getTags()Tag Manager which manages the tags for this resource.A list of tags that are attached to the role.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidThe trust policy that is associated with this role.voidsetDescription(String value) A description of the role that you provide.voidsetManagedPolicyArns(List<String> value) A list of Amazon Resource Names (ARNs) of the IAM managed policies that you want to attach to the role.voidsetMaxSessionDuration(Number value) The maximum session duration (in seconds) that you want to set for the specified role.voidThe path to the role.voidsetPermissionsBoundary(String value) The ARN of the policy used to set the permissions boundary for the role.voidsetPolicies(List<Object> value) Adds or updates an inline policy document that is embedded in the specified IAM role.voidsetPolicies(IResolvable value) Adds or updates an inline policy document that is embedded in the specified IAM role.voidsetRoleName(String value) A name for the IAM role, up to 64 characters in length.voidsetTagsRaw(List<CfnTag> value) A list of tags that are attached to the role.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnRole
protected CfnRole(software.amazon.jsii.JsiiObjectRef objRef) -
CfnRole
protected CfnRole(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnRole
@Stability(Stable) public CfnRole(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnRoleProps props) - Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrArn
Returns the Amazon Resource Name (ARN) for the role. For example:.{"Fn::GetAtt" : ["MyRole", "Arn"] }This will return a value such as
arn:aws:iam::1234567890:role/MyRole-AJJHDSKSDF. -
getAttrRoleId
Returns the stable and unique string identifying the role. For example,AIDAJQABLZS4A3QDU576Q.For more information about IDs, see IAM Identifiers in the IAM User Guide .
-
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getRoleRef
A reference to a Role resource.- Specified by:
getRoleRefin interfaceIRoleRef
-
getTags
Tag Manager which manages the tags for this resource. -
getAssumeRolePolicyDocument
The trust policy that is associated with this role. -
setAssumeRolePolicyDocument
The trust policy that is associated with this role. -
getDescription
A description of the role that you provide. -
setDescription
A description of the role that you provide. -
getManagedPolicyArns
A list of Amazon Resource Names (ARNs) of the IAM managed policies that you want to attach to the role. -
setManagedPolicyArns
A list of Amazon Resource Names (ARNs) of the IAM managed policies that you want to attach to the role. -
getMaxSessionDuration
The maximum session duration (in seconds) that you want to set for the specified role. -
setMaxSessionDuration
The maximum session duration (in seconds) that you want to set for the specified role. -
getPath
The path to the role.For more information about paths, see IAM Identifiers in the IAM User Guide .
-
setPath
The path to the role.For more information about paths, see IAM Identifiers in the IAM User Guide .
-
getPermissionsBoundary
The ARN of the policy used to set the permissions boundary for the role. -
setPermissionsBoundary
The ARN of the policy used to set the permissions boundary for the role. -
getPolicies
Adds or updates an inline policy document that is embedded in the specified IAM role.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnRole.PolicyProperty> -
setPolicies
Adds or updates an inline policy document that is embedded in the specified IAM role. -
setPolicies
Adds or updates an inline policy document that is embedded in the specified IAM role. -
getRoleName
A name for the IAM role, up to 64 characters in length. -
setRoleName
A name for the IAM role, up to 64 characters in length. -
getTagsRaw
A list of tags that are attached to the role. -
setTagsRaw
A list of tags that are attached to the role.
-