An AWS policy JSON is a structured document that specifies permissions for users, roles, or groups within Amazon Web Services. It defines what actions are allowed or denied, on which resources, under what conditions, and for which principals. This format enables precise control over access to AWS services and resources.
Every AWS policy JSON follows a strict syntax based on JavaScript Object Notation (JSON). It contains key elements such as Version, Statement, Effect, Principal, Action, Resource, and optional Condition. These components work together to enforce fine-grained access rules across AWS environments.
For example, a policy allowing a user to list S3 buckets but not delete them would include:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*"
}
]
}
The Version field must be set to "2012-10-17"-all current AWS policies use this version identifier. Using an older or incorrect version results in validation errors during policy attachment.
Each Statement block describes a single permission rule. The Effect value determines whether access is granted (Allow) or blocked (Deny). Multiple statements can exist in a single policy, and they are evaluated sequentially. If any statement allows access, the action may proceed unless explicitly denied later.
Actions are specified using service-specific prefixes. For S3, actions start with s3:-such as s3:GetObject or s3:PutBucketPolicy. Resource identifiers follow the ARN (Amazon Resource Name) format: arn:aws:s3:::bucket-name. Wildcards (*) apply broadly-for example, "Resource": "*" grants access to all resources.
| Field | Purpose | Example Value |
|---|---|---|
Version |
Specifies the policy language version | "2012-10-17" |
Statement |
Range of individual permission rules | [{...}] |
Effect |
Whether the rule allows or denies access | "Allow" or "Deny" |
Action |
List of allowed operations | "ec2:StartInstances" |
Resource |
Target AWS resource(s) | "arn:aws:ec2:us-east-1:123456789012:instance/i-12345678" |
Condition |
Optional rules based on time, IP, or tags | {"IpAddress": {"aws:SourceIp": ["192.0.2.0/24"]}} |
Conditions enable context-aware access. A policy can restrict access to specific IP ranges, require MFA, or limit actions to certain times. For instance, a condition requiring MFA for EC2 termination:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:TerminateInstances",
"Resource": "arn:aws:ec2:us-west-2:123456789012:instance/*",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "true"
}
}
}
]
}
Without the Condition block, anyone with the required permissions could terminate instances. With it, the request must come from a device that has verified multi-factor authentication.
Common mistakes include missing commas between fields, using incorrect service prefixes, or applying wildcards too broadly. Overly permissive policies-especially those with "Resource": "*" and "Action": "*"-can lead to unintended access exposure. According to AWS's own documentation, misconfigured policies are among the top causes of data breaches in cloud environments.
A non-obvious fact: AWS evaluates policies in a "deny-by-default" model. If no explicit allow or deny exists, access is denied-even if the user belongs to a group with broad permissions. This means every permission must be explicitly granted in a policy, either through identity-based policies (attached to users/roles) or resource-based policies (attached to resources like S3 buckets).
I once audited a customer's environment where a developer had attached a policy granting full S3 access to a role. The policy used "Action": "*" and "Resource": "*". After enabling CloudTrail logging, we discovered the role was being used to upload sensitive logs to public buckets. Fixing the policy to only allow s3:PutObject on a specific bucket resolved the issue.
When creating AWS policy JSON, always follow the principle of least privilege. Grant only the minimum permissions needed. Use managed policies from AWS when possible-such as AmazonS3ReadOnlyAccess-to reduce configuration errors. Custom policies should be validated using the AWS Policy Simulator before deployment.
Validating AWS policy JSON is critical. Use the AWS CLI command aws iam validate-policy or the online AWS Policy Generator to test syntax and logic. A malformed policy fails to attach and triggers immediate errors during deployment.
Aws policy json is not just a technical artifact-it's a security foundation. Misconfigurations can result in data leaks, unauthorized spending, or compliance violations. Regular audits using tools like AWS Config or third-party solutions ensure policies remain aligned with organizational needs and regulatory standards.