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
7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 | |