AWS Access Key ID
Match AWS access key IDs (both long-term AKIA and temporary ASIA prefixes).
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b", "g");
const input = "AKIAIOSFODNN7EXAMPLE";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"\b(?:AKIA|ASIA)[0-9A-Z]{16}\b")
input_text = "AKIAIOSFODNN7EXAMPLE"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\b(?:AKIA|ASIA)[0-9A-Z]{16}\b`)
input := `AKIAIOSFODNN7EXAMPLE`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
\b(?:AKIA|ASIA)[0-9A-Z]{16}\b (flags: g)Raw source: \b(?:AKIA|ASIA)[0-9A-Z]{16}\b
How it works
Examples
Input
AKIAIOSFODNN7EXAMPLEMatches
AKIAIOSFODNN7EXAMPLE
Input
ASIAIOSFODNN7EXAMPLEMatches
ASIAIOSFODNN7EXAMPLE
Input
not a keyNo match
—Common use cases
- •Secret scanning in git repos
- •Preventing accidental AWS credential commits
- •Log redaction pipelines
- •Security audit tooling
Related patterns
Generic API Key
SecurityMatch generic long alphanumeric tokens (32+ chars) typical of API keys and access tokens.
GitHub Personal Access Token
SecurityMatch GitHub Personal Access Tokens (classic + fine-grained) and OAuth tokens by their `ghX_` prefix.
PEM Private Key Block
SecurityMatch PEM-encoded private key blocks across the common variants (RSA, EC, DSA, OpenSSH, encrypted, PGP).
SSH Public Key
SecurityMatch SSH public keys in OpenSSH `authorized_keys` format, including the optional comment field.