@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:39.774Z") @Stability(value=Stable) public class LazyRole extends Resource implements IRole
This construct can be used to simplify logic in other constructs which need to create a role but only if certain configurations occur (such as when AutoScaling is configured). The role can be configured in one place, but if it never gets used it doesn't get instantiated and will not be synthesized or deployed.
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.iam.*;
ManagedPolicy managedPolicy;
PolicyDocument policyDocument;
IPrincipal principal;
LazyRole lazyRole = LazyRole.Builder.create(this, "MyLazyRole")
.assumedBy(principal)
// the properties below are optional
.description("description")
.externalIds(List.of("externalIds"))
.inlinePolicies(Map.of(
"inlinePoliciesKey", policyDocument))
.managedPolicies(List.of(managedPolicy))
.maxSessionDuration(Duration.minutes(30))
.path("path")
.permissionsBoundary(managedPolicy)
.roleName("roleName")
.build();
| Modifier and Type | Class and Description |
|---|---|
static class |
LazyRole.Builder
A fluent builder for
LazyRole. |
software.amazon.jsii.JsiiObject.InitializationModeIRole.Jsii$Default, IRole.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
LazyRole(software.constructs.Construct scope,
String id,
LazyRoleProps props) |
protected |
LazyRole(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
LazyRole(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addManagedPolicy(IManagedPolicy policy)
Attaches a managed policy to this role.
|
Boolean |
addToPolicy(PolicyStatement statement)
Add to the policy of this principal.
|
AddToPrincipalPolicyResult |
addToPrincipalPolicy(PolicyStatement statement)
Adds a permission to the role's default policy document.
|
void |
attachInlinePolicy(Policy policy)
Attaches a policy to this role.
|
String |
getAssumeRoleAction()
When this Principal is used in an AssumeRole policy, the action to use.
|
IPrincipal |
getGrantPrincipal()
The principal to grant permissions to.
|
PrincipalPolicyFragment |
getPolicyFragment()
Return the policy fragment that identifies this principal in a Policy.
|
String |
getPrincipalAccount()
The AWS account ID of this principal.
|
String |
getRoleArn()
Returns the ARN of this role.
|
String |
getRoleId()
Returns the stable and unique string identifying the role (i.e.
|
String |
getRoleName()
Returns the name of this role.
|
Grant |
grant(IPrincipal identity,
String... actions)
Grant the actions defined in actions to the identity Principal on this resource.
|
Grant |
grantAssumeRole(IPrincipal identity)
Grant permissions to the given principal to assume this role.
|
Grant |
grantPassRole(IPrincipal identity)
Grant permissions to the given principal to pass this role.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackprotected LazyRole(software.amazon.jsii.JsiiObjectRef objRef)
protected LazyRole(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public LazyRole(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
LazyRoleProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable)
public void addManagedPolicy(@NotNull
IManagedPolicy policy)
addManagedPolicy in interface IIdentitypolicy - The managed policy to attach. This parameter is required.@Stability(value=Stable) @NotNull public Boolean addToPolicy(@NotNull PolicyStatement statement)
statement - This parameter is required.@Stability(value=Stable) @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=Stable)
public void attachInlinePolicy(@NotNull
Policy policy)
attachInlinePolicy in interface IIdentitypolicy - The policy to attach. This parameter is required.@Stability(value=Stable) @NotNull public Grant grant(@NotNull IPrincipal identity, @NotNull String... actions)
@Stability(value=Stable) @NotNull public Grant grantAssumeRole(@NotNull IPrincipal identity)
grantAssumeRole in interface IRoleidentity - This parameter is required.@Stability(value=Stable) @NotNull public Grant grantPassRole(@NotNull IPrincipal identity)
grantPassRole in interface IRoleidentity - This parameter is required.@Stability(value=Stable) @NotNull public String getAssumeRoleAction()
getAssumeRoleAction in interface IPrincipal@Stability(value=Stable) @NotNull public IPrincipal getGrantPrincipal()
getGrantPrincipal in interface IGrantable@Stability(value=Stable) @NotNull public PrincipalPolicyFragment getPolicyFragment()
getPolicyFragment in interface IPrincipal@Stability(value=Stable) @NotNull public String getRoleArn()
getRoleArn in interface IRole@Stability(value=Stable) @NotNull public String getRoleId()
@Stability(value=Stable) @NotNull public String getRoleName()
getRoleName in interface IRole@Stability(value=Stable) @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 © 2022. All rights reserved.