diff --git a/src/content/docs/aws/developer-tools/security-testing/iam-policy-grammar.md b/src/content/docs/aws/developer-tools/security-testing/iam-policy-grammar.md new file mode 100644 index 00000000..031744d6 --- /dev/null +++ b/src/content/docs/aws/developer-tools/security-testing/iam-policy-grammar.md @@ -0,0 +1,130 @@ +--- +title: IAM Policy Grammar +description: Condition operators and condition keys supported by the LocalStack IAM policy engine. +template: doc +tags: ["Base"] # TODO: confirm tier +sidebar: + order: 5 +--- + + + +## Introduction + +This page lists the IAM policy grammar that the LocalStack policy engine can evaluate: the [condition operators](#condition-operators) and [condition keys](#condition-keys) it understands when checking a request. +The same engine backs both [IAM Policy Enforcement](/aws/developer-tools/security-testing/iam-policy-enforcement/) and the [IAM Policy Simulator](/aws/developer-tools/security-testing/iam-policy-simulator/), so the support described here applies to both. + +Grammar support is expanding over time; operators and keys not listed here may not yet be evaluated. +For which service actions are covered, see the [IAM coverage documentation](/aws/developer-tools/security-testing/iam-coverage/), which tracks action coverage rather than grammar. + +## Condition operators + +The [`Condition`](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) element of a policy statement uses condition operators to compare a condition key against a value. +The tables below list the operators the engine supports, grouped by category. + + + +### String + +| Operator | Supported | +| --- | --- | +| `StringEquals` | Verify | +| `StringNotEquals` | Yes | +| `StringEqualsIgnoreCase` | Verify | +| `StringNotEqualsIgnoreCase` | Yes | +| `StringLike` | Verify | +| `StringNotLike` | Yes | + +### Numeric + +| Operator | Supported | +| --- | --- | +| `NumericEquals` | Yes | +| `NumericNotEquals` | Yes | +| `NumericLessThan` | Yes | +| `NumericLessThanEquals` | Yes | +| `NumericGreaterThan` | Yes | +| `NumericGreaterThanEquals` | Yes | + +### ARN + +| Operator | Supported | +| --- | --- | +| `ArnEquals` | Verify | +| `ArnLike` | Verify | +| `ArnNotEquals` | Yes | +| `ArnNotLike` | Yes | + +### Other categories + + + +## Condition keys + +In addition to the global (`aws:*`) condition keys, the engine evaluates the following service-specific keys. + +| Condition key | Purpose | +| --- | --- | +| `iam:PolicyArn` | Restrict policy attach/detach operations to specific policies. | +| `s3:max-keys` | Numeric key for the maximum number of keys returned by a listing. | + + + +## Examples + +The expanded grammar makes it possible to express organization- and account-level guardrails locally. +The following statement is illustrative; confirm the exact condition-key names against your LocalStack version. + +Limit the page size of an S3 listing by denying requests that ask for more than 100 keys, using a numeric operator with the `s3:max-keys` key: + +```json showLineNumbers +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Deny", + "Action": "s3:ListBucket", + "Resource": "*", + "Condition": { + "NumericGreaterThan": { "s3:max-keys": "100" } + } + } + ] +} +``` + + + +## Known limitations + +Grammar support is rolled out incrementally, so operators and keys not listed above may not yet be evaluated. + + + +## Related + +- [IAM Policy Enforcement](/aws/developer-tools/security-testing/iam-policy-enforcement/) +- [IAM Policy Simulator](/aws/developer-tools/security-testing/iam-policy-simulator/) +- [IAM Coverage](/aws/developer-tools/security-testing/iam-coverage/) +- [Explainable IAM](/aws/developer-tools/security-testing/explainable-iam/) \ No newline at end of file