Enables the specified LoggingConfiguration, to start logging from a web ACL, according to the configuration provided.
If you configure data protection for the web ACL, the protection applies to the data that WAF sends to the logs.
This operation completely replaces any mutable specifications that you already have for a logging configuration with the ones that you provide to this call.
To modify an existing logging configuration, do the following:
-
Retrieve it by calling GetLoggingConfiguration
-
Update its settings as needed
-
Provide the complete logging configuration specification to this call
You can define one logging destination per web ACL.
You can access information about the traffic that WAF inspects using the following steps:
-
Create your logging destination. You can use an Amazon CloudWatch Logs log group, an Amazon Simple Storage Service (Amazon S3) bucket, or an Amazon Kinesis Data Firehose.
The name that you give the destination must start with aws-waf-logs-. Depending on the type of destination, you might need to configure additional settings or permissions.
For configuration requirements and pricing information for each destination type, see Logging web ACL traffic in the WAF Developer Guide.
-
Associate your logging destination to your web ACL using a PutLoggingConfiguration request.
When you successfully enable logging using a PutLoggingConfiguration request, WAF creates an additional role or policy that is required to write logs to the logging destination. For an Amazon CloudWatch Logs log group, WAF creates a resource policy on the log group. For an Amazon S3 bucket, WAF creates a bucket policy. For an Amazon Kinesis Data Firehose, WAF creates a service-linked role.
For additional information about web ACL logging, see Logging web ACL traffic information in the WAF Developer Guide.
Parameters:
Raises:
-
WAFFeatureNotIncludedInPricingPlanException
–
The operation failed because the specified WAF feature isn't supported by the CloudFront pricing plan associated with the web ACL.
-
WAFInternalErrorException
–
Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request.
-
WAFInvalidOperationException
–
The operation isn't valid.
-
WAFInvalidParameterException
–
The operation failed because WAF didn't recognize a parameter in the request. For example:
-
You specified a parameter name or value that isn't valid.
-
Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested.
-
You tried to update a WebACL with a DefaultAction that isn't among the types available at DefaultAction.
-
Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.
-
WAFLimitsExceededException
–
WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of WebACL objects that you can create for an Amazon Web Services account. For more information, see WAF quotas in the WAF Developer Guide.
-
WAFLogDestinationPermissionIssueException
–
The operation failed because you don't have the permissions that your logging configuration requires. For information, see Logging web ACL traffic information in the WAF Developer Guide.
-
WAFNonexistentItemException
–
WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate.
-
WAFOptimisticLockException
–
WAF couldn’t save your changes because you tried to update or delete a resource that has changed since you last retrieved it. Get the resource again, make any changes you need to make to the new copy, and retry your operation.
-
WAFServiceLinkedRoleErrorException
–
WAF is not able to access the service linked role. This can be caused by a previous PutLoggingConfiguration request, which can lock the service linked role for about 20 seconds. Please try your request again. The service linked role can also be locked by a previous DeleteServiceLinkedRole request, which can lock the role for 15 minutes or more. If you recently made a call to DeleteServiceLinkedRole, wait at least 15 minutes and try the request again. If you receive this same exception again, you will have to wait additional time until the role is unlocked.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_wafv2/_services/async_wafv2.py
| async def put_logging_configuration(
self,
logging_configuration: "capo_wafv2.types.logging_configuration.LoggingConfiguration",
*,
config_overrides: Optional[AsyncWAFV2ClientConfig] = None,
) -> "capo_wafv2.types.put_logging_configuration_response.PutLoggingConfigurationResponse":
"""<p>Enables the specified <a>LoggingConfiguration</a>, to start logging from a web ACL, according to the configuration provided. </p> <p>If you configure data protection for the web ACL, the protection applies to the data that WAF sends to the logs. </p> <note> <p>This operation completely replaces any mutable specifications that you already have for a logging configuration with the ones that you provide to this call. </p> <p>To modify an existing logging configuration, do the following: </p> <ol> <li> <p>Retrieve it by calling <a>GetLoggingConfiguration</a> </p> </li> <li> <p>Update its settings as needed</p> </li> <li> <p>Provide the complete logging configuration specification to this call</p> </li> </ol> </note> <note> <p>You can define one logging destination per web ACL.</p> </note> <p>You can access information about the traffic that WAF inspects using the following steps:</p> <ol> <li> <p>Create your logging destination. You can use an Amazon CloudWatch Logs log group, an Amazon Simple Storage Service (Amazon S3) bucket, or an Amazon Kinesis Data Firehose. </p> <p>The name that you give the destination must start with <code>aws-waf-logs-</code>. Depending on the type of destination, you might need to configure additional settings or permissions. </p> <p>For configuration requirements and pricing information for each destination type, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/logging.html">Logging web ACL traffic</a> in the <i>WAF Developer Guide</i>.</p> </li> <li> <p>Associate your logging destination to your web ACL using a <code>PutLoggingConfiguration</code> request.</p> </li> </ol> <p>When you successfully enable logging using a <code>PutLoggingConfiguration</code> request, WAF creates an additional role or policy that is required to write logs to the logging destination. For an Amazon CloudWatch Logs log group, WAF creates a resource policy on the log group. For an Amazon S3 bucket, WAF creates a bucket policy. For an Amazon Kinesis Data Firehose, WAF creates a service-linked role.</p> <p>For additional information about web ACL logging, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/logging.html">Logging web ACL traffic information</a> in the <i>WAF Developer Guide</i>.</p>
Args:
logging_configuration: <p></p>
Raises:
capo_wafv2.errors.waf_feature_not_included_in_pricing_plan_exception.WAFFeatureNotIncludedInPricingPlanException: <p>The operation failed because the specified WAF feature isn't supported by the CloudFront pricing plan associated with the web ACL.</p>
capo_wafv2.errors.waf_internal_error_exception.WAFInternalErrorException: <p>Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request. </p>
capo_wafv2.errors.waf_invalid_operation_exception.WAFInvalidOperationException: <p>The operation isn't valid. </p>
capo_wafv2.errors.waf_invalid_parameter_exception.WAFInvalidParameterException: <p>The operation failed because WAF didn't recognize a parameter in the request. For example: </p> <ul> <li> <p>You specified a parameter name or value that isn't valid.</p> </li> <li> <p>Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested. </p> </li> <li> <p>You tried to update a <code>WebACL</code> with a <code>DefaultAction</code> that isn't among the types available at <a>DefaultAction</a>.</p> </li> <li> <p>Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.</p> </li> </ul>
capo_wafv2.errors.waf_limits_exceeded_exception.WAFLimitsExceededException: <p>WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of <code>WebACL</code> objects that you can create for an Amazon Web Services account. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/limits.html">WAF quotas</a> in the <i>WAF Developer Guide</i>.</p>
capo_wafv2.errors.waf_log_destination_permission_issue_exception.WAFLogDestinationPermissionIssueException: <p>The operation failed because you don't have the permissions that your logging configuration requires. For information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/logging.html">Logging web ACL traffic information</a> in the <i>WAF Developer Guide</i>.</p>
capo_wafv2.errors.waf_nonexistent_item_exception.WAFNonexistentItemException: <p>WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate. </p>
capo_wafv2.errors.waf_optimistic_lock_exception.WAFOptimisticLockException: <p>WAF couldn’t save your changes because you tried to update or delete a resource that has changed since you last retrieved it. Get the resource again, make any changes you need to make to the new copy, and retry your operation. </p>
capo_wafv2.errors.waf_service_linked_role_error_exception.WAFServiceLinkedRoleErrorException: <p>WAF is not able to access the service linked role. This can be caused by a previous <code>PutLoggingConfiguration</code> request, which can lock the service linked role for about 20 seconds. Please try your request again. The service linked role can also be locked by a previous <code>DeleteServiceLinkedRole</code> request, which can lock the role for 15 minutes or more. If you recently made a call to <code>DeleteServiceLinkedRole</code>, wait at least 15 minutes and try the request again. If you receive this same exception again, you will have to wait additional time until the role is unlocked.</p>
capo_wafv2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_wafv2.types.put_logging_configuration_request.PutLoggingConfigurationRequest]",
) -> AsyncOperationResponse[
"capo_wafv2.types.put_logging_configuration_response.PutLoggingConfigurationResponse"
]:
import capo_wafv2._operations.awswaf_20190729.put_logging_configuration
(
output,
http_response,
) = await capo_wafv2._operations.awswaf_20190729.put_logging_configuration.async_put_logging_configuration(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutLoggingConfiguration")
)
input_: capo_wafv2.types.put_logging_configuration_request.PutLoggingConfigurationRequest = {
"logging_configuration": logging_configuration
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|