Interface IamPolicy
-
- All Superinterfaces:
ToCopyableBuilder<IamPolicy.Builder,IamPolicy>
- All Known Implementing Classes:
DefaultIamPolicy
@ThreadSafe public interface IamPolicy extends ToCopyableBuilder<IamPolicy.Builder,IamPolicy>
An AWS access control policy is a object that acts as a container for one or more statements, which specify fine grained rules for allowing or denying various types of actions from being performed on your AWS resources.By default, all requests to use your resource coming from anyone but you are denied. Access control polices can override that by allowing different types of access to your resources, or by explicitly denying different types of access.
Each statement in an AWS access control policy 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.
For more information, see The IAM User Guide
Usage Examples
Create a new IAM identity policy that allows a role to write items to an Amazon DynamoDB table.Download the policy uploaded in the previous example and create a new policy with "read" access added to it.
- See Also:
IamPolicyReader,IamPolicyWriter,IamStatement, IAM User Guide
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceIamPolicy.Builder
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static IamPolicy.Builderbuilder()Create aIamPolicy.Builderfor anIamPolicy.static IamPolicycreate(Collection<IamStatement> statements)Create anIamPolicycontaining the provided statements.static IamPolicyfromJson(String json)Create anIamPolicyfrom an IAM policy in JSON form.Stringid()Retrieve the value set byIamPolicy.Builder.id(String).List<IamStatement>statements()Retrieve the value set byIamPolicy.Builder.statements(Collection).StringtoJson()Convert this policy to the JSON format that is accepted by AWS services.StringtoJson(IamPolicyWriter writer)Convert this policy to the JSON format that is accepted by AWS services, using the provided writer.Stringversion()Retrieve the value set byIamPolicy.Builder.version(String).-
Methods inherited from interface software.amazon.awssdk.utils.builder.ToCopyableBuilder
copy, toBuilder
-
-
-
-
Method Detail
-
fromJson
static IamPolicy fromJson(String json)
Create anIamPolicyfrom an IAM policy in JSON form.This will raise an exception if the provided JSON is invalid or does not appear to represent a valid policy document.
This is equivalent to
IamPolicyReader.create().read(json).
-
create
static IamPolicy create(Collection<IamStatement> statements)
Create anIamPolicycontaining the provided statements.At least one statement is required.
This is equivalent to
IamPolicy.builder().statements(statements).build()
-
builder
static IamPolicy.Builder builder()
Create aIamPolicy.Builderfor anIamPolicy.
-
id
String id()
Retrieve the value set byIamPolicy.Builder.id(String).
-
version
String version()
Retrieve the value set byIamPolicy.Builder.version(String).
-
statements
List<IamStatement> statements()
Retrieve the value set byIamPolicy.Builder.statements(Collection).
-
toJson
String toJson()
Convert this policy to the JSON format that is accepted by AWS services.This is equivalent to
IamPolicyWriter.create().writeToString(policy)
-
toJson
String toJson(IamPolicyWriter writer)
Convert this policy to the JSON format that is accepted by AWS services, using the provided writer.This is equivalent to
writer.writeToString(policy)
-
-