IAM policy variables — placeholders like ${aws:username} that AWS substitutes at evaluation time — are a small piece of syntax with two easy ways to get wrong: typing a variable name that does not exist or is misspelled, and simply forgetting the closing brace, which turns a working policy into one with a literal, useless ${aws:usern string sitting in a Resource ARN. IAM Policy Variable Syntax Checker catches both classes of mistake by scanning pasted text for every ${...} token, reporting each one's name and whether it matches a curated list of common AWS policy variables, and separately flagging any unclosed ${ that never found its matching brace.
The scan itself works directly on the raw text you paste — a full policy document or just a Resource/Condition snippet — using a token-matching pass that finds every substring starting with ${ and ending at the next }. For each token found, the text between the braces is extracted as the variable's name and checked against a curated list of roughly a dozen common IAM policy variable prefixes: the identity variables aws:username and aws:userid; the tag-based families aws:PrincipalTag/, aws:RequestTag/, and aws:ResourceTag/, matched as prefixes so any tag name after the slash is accepted; the EC2-specific ec2:SourceInstanceARN and ec2:ResourceTag/; and the federation variables saml:sub, saml:aud, saml:namequalifier, oidc:sub, and oidc:aud used in SAML- and OIDC-federated identity policies. Each token is reported with its full literal text, its extracted name, and a known/unknown badge.
As with the other tools in this category that use a curated reference list, "unknown" is scoped honestly: AWS documents additional policy variables beyond this list, particularly newer or less common federation and service-specific variables, and this tool does not claim to enumerate all of them. A variable flagged unknown may be a real, valid AWS policy variable this tool simply was not built to recognize — treat it as a prompt to check AWS's policy-variable reference, not as a confirmed mistake. Where this tool is unambiguous, and where it earns its keep, is the unclosed-brace check: an unclosed ${ is a hard syntax defect regardless of which variable was intended. It happens most often from a stray backspace while editing a long Resource ARN, or from copy-pasting a partial line. The check counts every ${ occurrence in the text and compares it against the number of complete, properly-closed ${...} tokens found; any shortfall is reported as an unclosed-brace count, prompting you to scan the raw text for the dangling ${ AWS's own policy validation would otherwise reject (or, worse, silently treat as a literal string that never resolves to anything useful) at attach time.
This tool does not evaluate or substitute variables — it never tries to compute what ${aws:username} would actually expand to for a specific caller, and it does not check whether a given variable makes semantic sense in the specific field it appears in (a variable is scanned for wherever it shows up in the text, Resource, Condition, or anywhere else). It is a fast, local, honest first pass over the syntax layer only: does this token look like a real variable name, and is every brace properly closed.
The included sample deliberately includes one known variable (${aws:username} inside a Resource ARN, the single most common real-world use of policy variables — scoping each caller to their own S3 prefix) and one made-up, unknown variable, so loading it demonstrates both outcomes side by side without having to write your own test case first.