Skip to content
GitHubXDiscordRSS

RegexPatternSet

Learn how to create, update, and manage AWS WAFRegional RegexPatternSets using Alchemy Cloud Control.

The RegexPatternSet resource lets you manage AWS WAFRegional RegexPatternSets which are used to specify a set of regular expression patterns to inspect web requests.

Create a basic RegexPatternSet with required properties and an optional adopt flag.

import AWS from "alchemy/aws/control";
const regexPatternSet = await AWS.WAFRegional.RegexPatternSet("basicRegexPatternSet", {
Name: "MyRegexPatternSet",
RegexPatternStrings: [
"^.*(badword).*",
".*(malicious).*"
],
adopt: true // Optional: Adopt existing resource if it already exists
});

Configure a RegexPatternSet with additional patterns for more complex use cases.

const enhancedRegexPatternSet = await AWS.WAFRegional.RegexPatternSet("enhancedRegexPatternSet", {
Name: "MyEnhancedRegexPatternSet",
RegexPatternStrings: [
"^.*(spam|scam).*",
".*(phishing).*",
".*(hack).*"
]
});

Create a RegexPatternSet specifically for filtering out malicious requests based on a variety of patterns.

const maliciousRequestPatternSet = await AWS.WAFRegional.RegexPatternSet("maliciousRequestPatternSet", {
Name: "BlockMaliciousPatterns",
RegexPatternStrings: [
"^.*(sqlmap|cmd|shell|eval).*",
".*(select.*from|union.*select).*",
".*(script|<|>).*"
]
});

Define a RegexPatternSet for validating user input against common patterns to prevent XSS and injection attacks.

const inputValidationPatternSet = await AWS.WAFRegional.RegexPatternSet("inputValidationPatternSet", {
Name: "ValidateUserInput",
RegexPatternStrings: [
".*(<script>).*",
".*(javascript:).*",
".*(onerror=).*"
]
});