BytePane

AWS Access Key Regex Pattern

Matches AWS access key IDs that always start with AKIA (long-term) or ASIA (temporary STS) followed by 16 uppercase alphanumeric characters.

🔐
Security & Auth
Intermediate
Difficulty
Universal
Language
none
Flags
// Regular Expression
/(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}/

Live Regex Tester

Pattern Breakdown

(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}
Character class [ ]
Group ( )
Quantifier { }
Anchor ^ $
Repetition * + ?
Escape \
Alternation |
Any char .

Code Examples

JavaScript

const regex = /(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}/;
const test = "AKIAIOSFODNN7EXAMPLE";
console.log(regex.test(test)); // true

// Extract matches
const matches = test.match(regex);
console.log(matches);

Python

import re

pattern = r'(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}'
test = "AKIAIOSFODNN7EXAMPLE"
match = re.search(pattern, test)
print(match)  # Found!

Go

package main

import (
    "fmt"
    "regexp"
)

func main() {
    re := regexp.MustCompile(`(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}`)
    fmt.Println(re.MatchString("AKIAIOSFODNN7EXAMPLE")) // true
}

Common Use Cases

Secret detectionsecurity scanningcompliance checks

Match Examples

InputResult
AKIAIOSFODNN7EXAMPLEMatch
BKIAIOSFODNN7EXAMPLENo Match

About the AWS Access Key Regex

Matches AWS access key IDs that always start with AKIA (long-term) or ASIA (temporary STS) followed by 16 uppercase alphanumeric characters.

Regular expressions (regex) are powerful pattern matching tools used across virtually all programming languages. The aws access key pattern is classified as intermediate difficulty in the security & auth category. It works in all major programming languages.

When using this regex, always consider edge cases and test thoroughly with real-world data. Use the interactive tester above to validate the pattern against your specific inputs before deploying to production.

Need More Regex Patterns?

Browse our complete library of 100+ regex patterns with interactive testers.

Frequently Asked Questions

What is the AWS Access Key regex pattern?

Matches AWS access key IDs that always start with AKIA (long-term) or ASIA (temporary STS) followed by 16 uppercase alphanumeric characters.

How do I use the AWS Access Key regex?

Use the pattern /(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}/ in your code. In JavaScript: new RegExp('(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}', ''). Test it above with your own input.

What does this AWS Access Key regex match?

This pattern matches: "AKIAIOSFODNN7EXAMPLE". It does NOT match: "BKIAIOSFODNN7EXAMPLE". Secret detection, security scanning, compliance checks.

Is the AWS Access Key regex beginner-friendly?

This pattern is rated Intermediate. It uses some advanced features like character classes and quantifiers.

What languages support the AWS Access Key regex?

This pattern works in all major programming languages including JavaScript, Python, Java, C#, Go, Ruby, PHP, and more. Syntax may vary slightly between regex engines.

Can I modify the AWS Access Key regex for my use case?

Yes! Use the interactive tester above to modify the pattern and test with your own data. Common modifications include making it case-insensitive (add 'i' flag), matching globally (add 'g' flag), or adjusting character classes.

Related Tools