put_resource_policy
¶
put_resource_policy(
*,
config_overrides: Optional[CloudWatchLogsClientConfig] = None,
policy_name: Optional[PolicyName] = None,
policy_document: Optional[PolicyDocument] = None,
resource_arn: Optional[Arn] = None,
expected_revision_id: Optional[ExpectedRevisionId] = None,
) -> PutResourcePolicyResponse
Creates or updates a resource policy allowing other Amazon Web Services services to put log events to this account, such as Amazon Route 53. This API has the following restrictions:
-
Supported actions - Policy only supports
logs:PutLogEventsandlogs:CreateLogStreamactions -
Supported principals - Policy only applies when operations are invoked by Amazon Web Services service principals (not IAM users, roles, or cross-account principals)
-
Policy limits - An account can have a maximum of 10 policies without resourceARN and one per LogGroup resourceARN
Resource policies with actions invoked by non-Amazon Web Services service principals (such as IAM users, roles, or other Amazon Web Services accounts) will not be enforced. For access control involving these principals, use the IAM policies.
Parameters:
-
policy_name(Optional[PolicyName], default:None) –Name of the new policy. This parameter is required.
-
policy_document(Optional[PolicyDocument], default:None) –Details of the new policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. This parameter is required.
The following example creates a resource policy enabling the Route 53 service to put DNS query logs in to the specified log group. Replace
"logArn"with the ARN of your CloudWatch Logs resource, such as a log group or log stream.CloudWatch Logs also supports aws:SourceArn and aws:SourceAccount condition context keys.
In the example resource policy, you would replace the value of
SourceArnwith the resource making the call from Route 53 to CloudWatch Logs. You would also replace the value ofSourceAccountwith the Amazon Web Services account ID making that call.{ "Version": "2012-10-17", "Statement": [ { "Sid": "Route53LogsToCloudWatchLogs", "Effect": "Allow", "Principal": { "Service": [ "route53.amazonaws.com" ] }, "Action": "logs:PutLogEvents", "Resource": "logArn", "Condition": { "ArnLike": { "aws:SourceArn": "myRoute53ResourceArn" }, "StringEquals": { "aws:SourceAccount": "myAwsAccountId" } } } ] } -
resource_arn(Optional[Arn], default:None) –The ARN of the CloudWatch Logs resource to which the resource policy needs to be added or attached. Currently only supports LogGroup ARN.
-
expected_revision_id(Optional[ExpectedRevisionId], default:None) –The expected revision ID of the resource policy. Required when
resourceArnis provided to prevent concurrent modifications. Usenullwhen creating a resource policy for the first time.
Raises:
-
InvalidParameterException–A parameter is specified incorrectly.
-
LimitExceededException–You have reached the maximum number of resources that can be created.
-
OperationAbortedException–Multiple concurrent requests to update the same resource were in conflict.
-
ResourceNotFoundException–The specified resource does not exist.
-
ServiceUnavailableException–The service cannot complete the request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudwatch_logs/_services/cloud_watch_logs.py
6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 | |