AWS::WAFv2::LoggingConfiguration - AWS CloudFormation

AWS::WAFv2::LoggingConfiguration

Defines an association between Amazon Kinesis Data Firehose destinations and a web ACL resource, for logging from AWS WAF. As part of the association, you can specify parts of the standard logging fields to keep out of the logs and you can specify filters so that you log only a subset of the logging records.

Syntax

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

JSON

{ "Type" : "AWS::WAFv2::LoggingConfiguration", "Properties" : { "LogDestinationConfigs" : [ String, ... ], "LoggingFilter" : Json, "RedactedFields" : [ FieldToMatch, ... ], "ResourceArn" : String } }

YAML

Type: AWS::WAFv2::LoggingConfiguration Properties: LogDestinationConfigs: - String LoggingFilter: Json RedactedFields: - FieldToMatch ResourceArn: String

Properties

LogDestinationConfigs

The Amazon Kinesis Data Firehose Amazon Resource Name (ARNs) that you want to associate with the web ACL.

Required: Yes

Type: List of String

Maximum: 100

Update requires: No interruption

LoggingFilter

Filtering that specifies which web requests are kept in the logs and which are dropped. You can filter on the rule action and on the web request labels that were applied by matching rules during web ACL evaluation.

Required: No

Type: Json

Update requires: No interruption

RedactedFields

The parts of the request that you want to keep out of the logs. For example, if you redact the SingleHeader field, the HEADER field in the firehose will be xxx.

Note

You can specify only the following fields for redaction: UriPath, QueryString, SingleHeader, Method, and JsonBody.

Required: No

Type: List of FieldToMatch

Maximum: 100

Update requires: No interruption

ResourceArn

The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs.

Required: Yes

Type: String

Minimum: 20

Maximum: 2048

Pattern: .*\S.*

Update requires: Replacement

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the Amazon Resource Name (ARN) of the web ACL.

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

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

ManagedByFirewallManager

Indicates whether the logging configuration was created by AWS Firewall Manager, as part of an AWS WAF policy configuration. If true, only Firewall Manager can modify or delete the configuration.

Examples

Create a logging configuration with redacted fields

The following shows an example logging configuration with redacted fields.

YAML

LoggingConfiguration: Type: AWS::WAFv2::LoggingConfiguration Properties: ResourceArn: arn:aws:wafv2:us-east-1:123456789000:regional/webacl/test-webaclv2/abcd1234-123b-1234-1234-123456789abc LogDestinationConfigs: - arn:aws:firehose:us-east-1:123456789000:deliverystream/aws-waf-logs-firehose RedactedFields: - JsonBody: InvalidFallbackBehavior: EVALUATE_AS_STRING MatchPattern: IncludedPaths: - "/path/0/name" - "/path/1/name" MatchScope: ALL - Method: {} - QueryString: {} - SingleHeader: Name: password - UriPath: {}

JSON

"LoggingConfiguration": { "Type": "AWS::WAFv2::LoggingConfiguration", "Properties": { "ResourceArn": "arn:aws:wafv2:us-east-1:123456789000:regional/webacl/test-webaclv2/abcd1234-123b-1234-1234-123456789abc", "LogDestinationConfigs": [ "arn:aws:firehose:us-east-1:123456789000:deliverystream/aws-waf-logs-firehose" ], "RedactedFields": [ { "JsonBody": { "InvalidFallbackBehavior": "EVALUATE_AS_STRING", "MatchPattern": { "IncludedPaths": [ "/path/0/name", "/path/1/name" ] }, "MatchScope": "ALL" } }, { "Method": {} }, { "QueryString": {} }, { "SingleHeader": { "Name": "password" } }, { "UriPath": {} } ] } }

Create a logging configuration with a filter

The following shows an example logging configuration with a logging filter.

YAML

LoggingConfiguration: Type: AWS::WAFv2::LoggingConfiguration Properties: ResourceArn: arn:aws:wafv2:us-east-1:123456789000:regional/webacl/test-webaclv2/abcd1234-123b-1234-1234-123456789abc LogDestinationConfigs: - arn:aws:firehose:us-east-1:123456789000:deliverystream/aws-waf-logs-firehose RedactedFields: - JsonBody: InvalidFallbackBehavior: EVALUATE_AS_STRING MatchPattern: IncludedPaths: - "/path/0/name" - "/path/1/name" MatchScope: ALL - Method: {} - QueryString: {} - SingleHeader: Name: password - UriPath: {} LoggingFilter: DefaultBehavior: KEEP Filters: - Behavior: KEEP Conditions: - ActionCondition: Action: BLOCK - LabelNameCondition: LabelName: fooLabel Requirement: MEETS_ANY

JSON

"LoggingConfiguration": { "Type": "AWS::WAFv2::LoggingConfiguration", "Properties": { "ResourceArn": "arn:aws:wafv2:us-east-1:123456789000:regional/webacl/test-webaclv2/abcd1234-123b-1234-1234-123456789abc", "LogDestinationConfigs": [ "arn:aws:firehose:us-east-1:123456789000:deliverystream/aws-waf-logs-firehose" ], "RedactedFields": [ { "JsonBody": { "InvalidFallbackBehavior": "EVALUATE_AS_STRING", "MatchPattern": { "IncludedPaths": [ "/path/0/name", "/path/1/name" ] }, "MatchScope": "ALL" } }, { "Method": {} }, { "QueryString": {} }, { "SingleHeader": { "Name": "password" } }, { "UriPath": {} } ], "LoggingFilter": { "DefaultBehavior": "KEEP", "Filters": [ { "Behavior": "KEEP", "Conditions": [ { "ActionCondition": { "Action": "BLOCK" } }, { "LabelNameCondition": { "LabelName": "fooLabel" } } ], "Requirement": "MEETS_ANY" } ] } } }