Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::WAFRegional::SqlInjectionMatchSet

The AWS::WAFRegional::SqlInjectionMatchSet resource creates an AWS WAF Regional SqlInjectionMatchSet, which you use to allow, block, or count requests that contain malicious SQL code in a specific part of web requests. For more information, see CreateSqlInjectionMatchSet in the AWS WAF Regional API Reference.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

Copy
{ "Type" : "AWS::WAFRegional::SqlInjectionMatchSet", "Properties" : { "Name" : String, "SqlInjectionMatchTuples" : [ SqlInjectionMatchTuple, ... ] } }

YAML

Copy
Type: "AWS::WAFRegional::SqlInjectionMatchSet" Properties: Name: String SqlInjectionMatchTuples: - SqlInjectionMatchTuple

Properties

Name

A friendly name or description of the SqlInjectionMatchSet.

Required: Yes

Type: String

Update requires: Replacement

SqlInjectionMatchTuples

The parts of web requests that you want AWS WAF to inspect for malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.

Required: No

Type: List of AWS WAF Regional SqlInjectionMatchSet SqlInjectionMatchTuples

Update requires: No interruption

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the resource physical ID, such as 1234a1a-a1b1-12a1-abcd-a123b123456.

For more information about using the Ref function, see Ref.

Examples

Find SQL Injections

The following example looks for snippets of SQL code in the query string of an HTTP request.

JSON

Copy
"SqlInjDetection": { "Type": "AWS::WAFRegional::SqlInjectionMatchSet", "Properties": { "Name": "Find SQL injections in the query string", "SqlInjectionMatchTuples": [ { "FieldToMatch" : { "Type": "QUERY_STRING" }, "TextTransformation" : "URL_DECODE" } ] } }

YAML

Copy
SqlInjDetection: Type: "AWS::WAFRegional::SqlInjectionMatchSet" Properties: Name: "Find SQL injections in the query string" SqlInjectionMatchTuples: - FieldToMatch: Type: "QUERY_STRING" TextTransformation: "URL_DECODE"

Associate a SQL Injection Match Set with a Web ACL Rule

The following example associates the SqlInjDetection match set with a web access control list (ACL) rule.

JSON

Copy
"SqlInjRule" : { "Type": "AWS::WAFRegional::Rule", "Properties": { "Name": "SqlInjRule", "MetricName" : "SqlInjRule", "Predicates": [ { "DataId" : { "Ref" : "SqlInjDetection" }, "Negated" : false, "Type" : "SqlInjectionMatch" } ] } }

YAML

Copy
SqlInjRule: Type: "AWS::WAFRegional::Rule" Properties: Name: "SqlInjRule" MetricName: "SqlInjRule" Predicates: - DataId: Ref: "SqlInjDetection" Negated: false Type: "SqlInjectionMatch"

Create a Web ACL

The following example associates the SqlInjRule rule with a web ACL. The web ACL allows all requests except for ones with SQL code in the query string of a request.

JSON

Copy
"MyWebACL": { "Type": "AWS::WAFRegional::WebACL", "Properties": { "Name": "Web ACL to block SQL injection in the query string", "DefaultAction": { "Type": "ALLOW" }, "MetricName" : "SqlInjWebACL", "Rules": [ { "Action" : { "Type" : "BLOCK" }, "Priority" : 1, "RuleId" : { "Ref" : "SqlInjRule" } } ] } }

YAML

Copy
MyWebACL: Type: "AWS::WAFRegional::WebACL" Properties: Name: "Web ACL to block SQL injection in the query string" DefaultAction: Type: "ALLOW" MetricName: "SqlInjWebACL" Rules: - Action: Type: "BLOCK" Priority: 1 RuleId: Ref: "SqlInjRule"