Creates and assigns an IAM policy that grants permissions to CloudWatch Logs to deliver logs cross-account to a specified destination in this account. To configure the delivery of logs from an Amazon Web Services service in another account to a logs delivery destination in the current account, you must do the following:
-
Create a delivery source, which is a logical object that represents the resource that is actually sending the logs. For more information, see PutDeliverySource.
-
Create a delivery destination, which is a logical object that represents the actual delivery destination. For more information, see PutDeliveryDestination.
-
Use this operation in the destination account to assign an IAM policy to the destination. This policy allows delivery to that destination.
-
Create a delivery by pairing exactly one delivery source and one delivery destination. For more information, see CreateDelivery.
Only some Amazon Web Services services support being configured as a delivery source. These services are listed as Supported [V2 Permissions] in the table at Enabling logging from Amazon Web Services services.
The contents of the policy must include two statements. One statement enables general logs delivery, and the other allows delivery to the chosen destination. See the examples for the needed policies.
Parameters:
Raises:
Source code in docs_src/capo_cloudwatch_logs/_services/cloud_watch_logs.py
| def put_delivery_destination_policy(
self,
delivery_destination_name: "capo_cloudwatch_logs.types.delivery_destination_name.DeliveryDestinationName",
delivery_destination_policy: "capo_cloudwatch_logs.types.delivery_destination_policy.DeliveryDestinationPolicy",
*,
config_overrides: Optional[CloudWatchLogsClientConfig] = None,
) -> "capo_cloudwatch_logs.types.put_delivery_destination_policy_response.PutDeliveryDestinationPolicyResponse":
"""<p>Creates and assigns an IAM policy that grants permissions to CloudWatch Logs to deliver logs cross-account to a specified destination in this account. To configure the delivery of logs from an Amazon Web Services service in another account to a logs delivery destination in the current account, you must do the following:</p> <ul> <li> <p>Create a delivery source, which is a logical object that represents the resource that is actually sending the logs. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDeliverySource.html">PutDeliverySource</a>.</p> </li> <li> <p>Create a <i>delivery destination</i>, which is a logical object that represents the actual delivery destination. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDeliveryDestination.html">PutDeliveryDestination</a>.</p> </li> <li> <p>Use this operation in the destination account to assign an IAM policy to the destination. This policy allows delivery to that destination. </p> </li> <li> <p>Create a <i>delivery</i> by pairing exactly one delivery source and one delivery destination. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateDelivery.html">CreateDelivery</a>.</p> </li> </ul> <p>Only some Amazon Web Services services support being configured as a delivery source. These services are listed as <b>Supported [V2 Permissions]</b> in the table at <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html">Enabling logging from Amazon Web Services services.</a> </p> <p>The contents of the policy must include two statements. One statement enables general logs delivery, and the other allows delivery to the chosen destination. See the examples for the needed policies.</p>
Args:
delivery_destination_name: <p>The name of the delivery destination to assign this policy to.</p>
delivery_destination_policy: <p>The contents of the policy.</p>
Raises:
capo_cloudwatch_logs.errors.conflict_exception.ConflictException: <p>This operation attempted to create a resource that already exists.</p>
capo_cloudwatch_logs.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
capo_cloudwatch_logs.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service cannot complete the request.</p>
capo_cloudwatch_logs.errors.validation_exception.ValidationException: <p>One of the parameters for the request is not valid.</p>
capo_cloudwatch_logs.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudwatch_logs.types.put_delivery_destination_policy_request.PutDeliveryDestinationPolicyRequest]",
) -> OperationResponse[
"capo_cloudwatch_logs.types.put_delivery_destination_policy_response.PutDeliveryDestinationPolicyResponse"
]:
import capo_cloudwatch_logs._operations.logs_20140328.put_delivery_destination_policy
output, http_response = (
capo_cloudwatch_logs._operations.logs_20140328.put_delivery_destination_policy.put_delivery_destination_policy(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutDeliveryDestinationPolicy")
)
input_: capo_cloudwatch_logs.types.put_delivery_destination_policy_request.PutDeliveryDestinationPolicyRequest = {
"delivery_destination_name": delivery_destination_name,
"delivery_destination_policy": delivery_destination_policy,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|