put_resource_policy
async
¶
put_resource_policy(
*,
config_overrides: Optional[AsyncCloudWatchLogsClientConfig] = 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/async_cloud_watch_logs.py
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 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 | |