Class PolicyDocument
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.iam.PolicyDocument
- All Implemented Interfaces:
IResolvable
,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-11-22T02:24:02.798Z")
@Stability(Stable)
public class PolicyDocument
extends software.amazon.jsii.JsiiObject
implements IResolvable
A PolicyDocument is a collection of statements.
Example:
import software.amazon.awscdk.services.iam.*; PolicyDocument myFileSystemPolicy = PolicyDocument.Builder.create() .statements(List.of(PolicyStatement.Builder.create() .actions(List.of("elasticfilesystem:ClientWrite", "elasticfilesystem:ClientMount")) .principals(List.of(new AccountRootPrincipal())) .resources(List.of("*")) .conditions(Map.of( "Bool", Map.of( "elasticfilesystem:AccessedViaMountTarget", "true"))) .build())) .build(); FileSystem fileSystem = FileSystem.Builder.create(this, "MyEfsFileSystem") .vpc(new Vpc(this, "VPC")) .fileSystemPolicy(myFileSystemPolicy) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResolvable
IResolvable.Jsii$Default, IResolvable.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionprotected
PolicyDocument
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
PolicyDocument
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatements
(@NotNull PolicyStatement... statement) Adds a statement to the policy document.static PolicyDocument
Creates a new PolicyDocument based on the object provided.The creation stack of this resolvable which will be appended to errors thrown during resolution.Whether the policy document contains any statements.The number of statements already added to this policy.resolve
(IResolveContext context) Produce the Token's value at resolution time.toJSON()
JSON-ify the document.toString()
Encode the policy document as a string.Validate that all policy statements in the policy document satisfies the requirements for any policy.Validate that all policy statements in the policy document satisfies the requirements for an identity-based policy.Validate that all policy statements in the policy document satisfies the requirements for a resource-based policy.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.awscdk.IResolvable
getTypeHint
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
PolicyDocument
protected PolicyDocument(software.amazon.jsii.JsiiObjectRef objRef) -
PolicyDocument
protected PolicyDocument(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
PolicyDocument
- Parameters:
props
-
-
PolicyDocument
@Stability(Stable) public PolicyDocument()
-
-
Method Details
-
fromJson
Creates a new PolicyDocument based on the object provided.This will accept an object created from the
.toJSON()
call- Parameters:
obj
- the PolicyDocument in object form. This parameter is required.
-
addStatements
Adds a statement to the policy document.- Parameters:
statement
- the statement to add. This parameter is required.
-
resolve
Produce the Token's value at resolution time.- Specified by:
resolve
in interfaceIResolvable
- Parameters:
context
- This parameter is required.
-
toJSON
JSON-ify the document.Used when JSON.stringify() is called
-
toString
Encode the policy document as a string.- Specified by:
toString
in interfaceIResolvable
- Overrides:
toString
in classObject
-
validateForAnyPolicy
Validate that all policy statements in the policy document satisfies the requirements for any policy.- Returns:
- An array of validation error messages, or an empty array if the document is valid.
- See Also:
-
validateForIdentityPolicy
Validate that all policy statements in the policy document satisfies the requirements for an identity-based policy.- Returns:
- An array of validation error messages, or an empty array if the document is valid.
- See Also:
-
validateForResourcePolicy
Validate that all policy statements in the policy document satisfies the requirements for a resource-based policy.- Returns:
- An array of validation error messages, or an empty array if the document is valid.
- See Also:
-
getCreationStack
The creation stack of this resolvable which will be appended to errors thrown during resolution.This may return an array with a single informational element indicating how to get this property populated, if it was skipped for performance reasons.
- Specified by:
getCreationStack
in interfaceIResolvable
-
getIsEmpty
Whether the policy document contains any statements. -
getStatementCount
The number of statements already added to this policy.Can be used, for example, to generate unique "sid"s within the policy.
-