@Generated(value="jsii-pacmak/1.29.0 (build 41df200)", date="2021-06-02T09:55:31.426Z") @Stability(value=Experimental) public class Role extends Resource implements IRole
Defines an IAM role. The role is created with an assume policy document associated with
the specified AWS service principal defined in serviceAssumeRole.
| Modifier and Type | Class and Description |
|---|---|
static class |
Role.Builder
(experimental) A fluent builder for
Role. |
software.amazon.jsii.JsiiObject.InitializationModeIRole.Jsii$Default, IRole.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
Role(software.constructs.Construct scope,
String id,
RoleProps props) |
protected |
Role(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Role(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addManagedPolicy(IManagedPolicy policy)
(experimental) Attaches a managed policy to this role.
|
Boolean |
addToPolicy(PolicyStatement statement)
(experimental) Add to the policy of this principal.
|
AddToPrincipalPolicyResult |
addToPrincipalPolicy(PolicyStatement statement)
(experimental) Adds a permission to the role's default policy document.
|
void |
attachInlinePolicy(Policy policy)
(experimental) Attaches a policy to this role.
|
static IRole |
fromRoleArn(software.constructs.Construct scope,
String id,
String roleArn)
(experimental) Import an external role by ARN.
|
static IRole |
fromRoleArn(software.constructs.Construct scope,
String id,
String roleArn,
FromRoleArnOptions options)
(experimental) Import an external role by ARN.
|
String |
getAssumeRoleAction()
(experimental) When this Principal is used in an AssumeRole policy, the action to use.
|
PolicyDocument |
getAssumeRolePolicy()
(experimental) The assume role policy document associated with this role.
|
IPrincipal |
getGrantPrincipal()
(experimental) The principal to grant permissions to.
|
IManagedPolicy |
getPermissionsBoundary()
(experimental) Returns the permissions boundary attached to this role.
|
PrincipalPolicyFragment |
getPolicyFragment()
(experimental) Returns the role.
|
String |
getPrincipalAccount()
(experimental) The AWS account ID of this principal.
|
String |
getRoleArn()
(experimental) Returns the ARN of this role.
|
String |
getRoleId()
(experimental) Returns the stable and unique string identifying the role.
|
String |
getRoleName()
(experimental) Returns the name of the role.
|
Grant |
grant(IPrincipal grantee,
String... actions)
(experimental) Grant the actions defined in actions to the identity Principal on this resource.
|
Grant |
grantPassRole(IPrincipal identity)
(experimental) Grant permissions to the given principal to pass this role.
|
IRole |
withoutPolicyUpdates()
(experimental) Return a copy of this Role object whose Policies will not be updated.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Role(software.amazon.jsii.JsiiObjectRef objRef)
protected Role(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Experimental) @NotNull public static IRole fromRoleArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String roleArn, @Nullable FromRoleArnOptions options)
If the imported Role ARN is a Token (such as a
CfnParameter.valueAsString or a Fn.importValue()) and the referenced
role has a path (like arn:...:role/AdminRoles/Alice), the
roleName property will not resolve to the correct value. Instead it
will resolve to the first path component. We unfortunately cannot express
the correct calculation of the full path name as a CloudFormation
expression. In this scenario the Role ARN should be supplied without the
path in order to resolve the correct role resource.
scope - construct scope. This parameter is required.id - construct id. This parameter is required.roleArn - the ARN of the role to import. This parameter is required.options - allow customizing the behavior of the returned role.@Stability(value=Experimental) @NotNull public static IRole fromRoleArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String roleArn)
If the imported Role ARN is a Token (such as a
CfnParameter.valueAsString or a Fn.importValue()) and the referenced
role has a path (like arn:...:role/AdminRoles/Alice), the
roleName property will not resolve to the correct value. Instead it
will resolve to the first path component. We unfortunately cannot express
the correct calculation of the full path name as a CloudFormation
expression. In this scenario the Role ARN should be supplied without the
path in order to resolve the correct role resource.
scope - construct scope. This parameter is required.id - construct id. This parameter is required.roleArn - the ARN of the role to import. This parameter is required.@Stability(value=Experimental)
public void addManagedPolicy(@NotNull
IManagedPolicy policy)
addManagedPolicy in interface IIdentitypolicy - The the managed policy to attach. This parameter is required.@Stability(value=Experimental) @NotNull public Boolean addToPolicy(@NotNull PolicyStatement statement)
statement - This parameter is required.@Stability(value=Experimental) @NotNull public AddToPrincipalPolicyResult addToPrincipalPolicy(@NotNull PolicyStatement statement)
If there is no default policy attached to this role, it will be created.
addToPrincipalPolicy in interface IPrincipalstatement - The permission statement to add to the policy document. This parameter is required.@Stability(value=Experimental)
public void attachInlinePolicy(@NotNull
Policy policy)
attachInlinePolicy in interface IIdentitypolicy - The policy to attach. This parameter is required.@Stability(value=Experimental) @NotNull public Grant grant(@NotNull IPrincipal grantee, @NotNull String... actions)
@Stability(value=Experimental) @NotNull public Grant grantPassRole(@NotNull IPrincipal identity)
grantPassRole in interface IRoleidentity - This parameter is required.@Stability(value=Experimental) @NotNull public IRole withoutPolicyUpdates()
Use the object returned by this method if you want this Role to be used by a construct without it automatically updating the Role's Policies.
If you do, you are responsible for adding the correct statements to the Role's policies yourself.
@Stability(value=Experimental) @NotNull public String getAssumeRoleAction()
getAssumeRoleAction in interface IPrincipal@Stability(value=Experimental) @NotNull public IPrincipal getGrantPrincipal()
getGrantPrincipal in interface IGrantable@Stability(value=Experimental) @NotNull public PrincipalPolicyFragment getPolicyFragment()
getPolicyFragment in interface IPrincipal@Stability(value=Experimental) @NotNull public String getRoleArn()
getRoleArn in interface IRole@Stability(value=Experimental) @NotNull public String getRoleId()
For example, AIDAJQABLZS4A3QDU576Q.
@Stability(value=Experimental) @NotNull public String getRoleName()
getRoleName in interface IRole@Stability(value=Experimental) @Nullable public PolicyDocument getAssumeRolePolicy()
@Stability(value=Experimental) @Nullable public IManagedPolicy getPermissionsBoundary()
@Stability(value=Experimental) @Nullable public String getPrincipalAccount()
Can be undefined when the account is not known (for example, for service principals). Can be a Token - in that case, it's assumed to be AWS::AccountId.
getPrincipalAccount in interface IPrincipalCopyright © 2021. All rights reserved.