Back to all operators

StringNotEqualsIfExists

StringNotEqualsIfExists

compares a string in a request to a list of strings in your policy. The comparison is case sensitive.

To match a request, the context key can be absent, but if present it must NOT match any of the strings in your policy.

You can use policy variables in the value of this operator.

So you know

StringNotEqualsIfExists behaves exactly the same as StringNotEquals. "Negative" operators such as StringNotEquals already match requests when the key is not present, so the IfExists suffix has no effect. There is no harm in adding IfExists — it arguably makes the intent clearer.

StringNotEqualsIfExists in an Allow Statement

Simulate in IAM Simulate
Policy ConditionRequest ContextResult
"StringNotEqualsIfExists": {
"aws:RequestTag/DataClass": [
"public",
"internal"
]
}
aws:RequestTag/DataClass: null✓ Allowed Assuming no explicit Deny elsewhere
"StringNotEqualsIfExists": {
"aws:RequestTag/DataClass": [
"public",
"internal"
]
}
aws:RequestTag/DataClass: private✓ Allowed Assuming no explicit Deny elsewhere
"StringNotEqualsIfExists": {
"aws:RequestTag/DataClass": [
"public",
"internal"
]
}
aws:RequestTag/DataClass: public− Not Allowed Statement does not apply

StringNotEqualsIfExists in a Deny Statement

Simulate in IAM Simulate
Policy ConditionRequest ContextResult
"StringNotEqualsIfExists": {
"aws:RequestTag/DataClass": [
"public",
"internal"
]
}
aws:RequestTag/DataClass: null✕ Denied
"StringNotEqualsIfExists": {
"aws:RequestTag/DataClass": [
"public",
"internal"
]
}
aws:RequestTag/DataClass: private✕ Denied
"StringNotEqualsIfExists": {
"aws:RequestTag/DataClass": [
"public",
"internal"
]
}
aws:RequestTag/DataClass: public− Not Denied May be allowed by another statement