Interface IamStatement
- All Superinterfaces:
ToCopyableBuilder<IamStatement.Builder,
IamStatement>
- All Known Implementing Classes:
DefaultIamStatement
A statement describes a rule for allowing or denying access to a specific AWS resource based on how the resource is being accessed, and who is attempting to access the resource. Statements can also optionally contain a list of conditions that specify when a statement is to be honored.
For example, consider a statement that:
- allows access (the effect)
- for a list of specific AWS account IDs (the principals)
- when accessing an SQS queue (the resource)
- using the SendMessage operation (the action)
- and the request occurs before a specific date (a condition)
Statements takes the form: "A has permission to do B to C where D applies".
- A is the principal - the AWS account that is making a request to access or modify one of your AWS resources.
- B is the action - the way in which your AWS resource is being accessed or modified, such as sending a message to an Amazon SQS queue, or storing an object in an Amazon S3 bucket.
- C is the resource - your AWS entity that the principal wants to access, such as an Amazon SQS queue, or an object stored in Amazon S3.
- D is the set of conditions - optional constraints that specify when to allow or deny access for the principal to access your resource. Many expressive conditions are available, some specific to each service. For example you can use date conditions to allow access to your resources only after or before a specific time.
There are many resources and conditions available for use in statements, and you can combine them to form fine grained custom access control polices.
Statements are typically attached to a IamPolicy
.
For more information, see The IAM User guide
Usage Examples
Create an identity-based policy statement that allows a role to write items to an Amazon DynamoDB table.IamStatement statement =
IamStatement.builder()
.sid("GrantWriteBookMetadata")
.effect(IamEffect.ALLOW)
.addAction("dynamodb:PutItem")
.addResource("arn:aws:dynamodb:us-east-2:123456789012:table/books")
.build();
Create a resource-based policy statement that denies access to all users.
IamStatement statement =
IamStatement.builder()
.effect(IamEffect.DENY)
.addPrincipal(IamPrincipal.ALL)
.build();
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionactions()
Retrieve the value set byIamStatement.Builder.actions(Collection)
.static IamStatement.Builder
builder()
Create aIamStatement.Builder
for anIamStatement
.Retrieve the value set byIamStatement.Builder.conditions(Collection)
.effect()
Retrieve the value set byIamStatement.Builder.effect(IamEffect)
.Retrieve the value set byIamStatement.Builder.notActions(Collection)
.Retrieve the value set byIamStatement.Builder.notPrincipals(Collection)
.Retrieve the value set byIamStatement.Builder.notResources(Collection)
.Retrieve the value set byIamStatement.Builder.principals(Collection)
.Retrieve the value set byIamStatement.Builder.resources(Collection)
.sid()
Retrieve the value set byIamStatement.Builder.sid(String)
.Methods inherited from interface software.amazon.awssdk.utils.builder.ToCopyableBuilder
copy, toBuilder
-
Method Details
-
builder
Create aIamStatement.Builder
for anIamStatement
. -
sid
String sid()Retrieve the value set byIamStatement.Builder.sid(String)
. -
effect
IamEffect effect()Retrieve the value set byIamStatement.Builder.effect(IamEffect)
. -
principals
List<IamPrincipal> principals()Retrieve the value set byIamStatement.Builder.principals(Collection)
. -
notPrincipals
List<IamPrincipal> notPrincipals()Retrieve the value set byIamStatement.Builder.notPrincipals(Collection)
. -
actions
Retrieve the value set byIamStatement.Builder.actions(Collection)
. -
notActions
Retrieve the value set byIamStatement.Builder.notActions(Collection)
. -
resources
List<IamResource> resources()Retrieve the value set byIamStatement.Builder.resources(Collection)
. -
notResources
List<IamResource> notResources()Retrieve the value set byIamStatement.Builder.notResources(Collection)
. -
conditions
List<IamCondition> conditions()Retrieve the value set byIamStatement.Builder.conditions(Collection)
.
-