Interface IamStatement

All Superinterfaces:
ToCopyableBuilder<IamStatement.Builder,IamStatement>
All Known Implementing Classes:
DefaultIamStatement

@ThreadSafe public interface IamStatement extends ToCopyableBuilder<IamStatement.Builder,IamStatement>
A statement is the formal description of a single permission, and is always contained within a policy object.

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: