putDestination method
Creates or updates a destination. This operation is used only to create destinations for cross-account subscriptions.
A destination encapsulates a physical resource (such as an Amazon Kinesis stream). With a destination, you can subscribe to a real-time stream of log events for a different account, ingested using PutLogEvents.
Through an access policy, a destination controls what is written to it. By
default, PutDestination does not set any access policy with
the destination, which means a cross-account user cannot call PutSubscriptionFilter
against this destination. To enable this, the destination owner must call
PutDestinationPolicy
after PutDestination.
To perform a PutDestination operation, you must also have the
iam:PassRole permission.
May throw InvalidParameterException.
May throw OperationAbortedException.
May throw ServiceUnavailableException.
Parameter destinationName :
A name for the destination.
Parameter roleArn :
The ARN of an IAM role that grants CloudWatch Logs permissions to call the
Amazon Kinesis PutRecord operation on the destination stream.
Parameter targetArn :
The ARN of an Amazon Kinesis stream to which to deliver matching log
events.
Parameter tags :
An optional list of key-value pairs to associate with the resource.
For more information about tagging, see Tagging Amazon Web Services resources
Implementation
Future<PutDestinationResponse> putDestination({
required String destinationName,
required String roleArn,
required String targetArn,
Map<String, String>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Logs_20140328.PutDestination'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'destinationName': destinationName,
'roleArn': roleArn,
'targetArn': targetArn,
if (tags != null) 'tags': tags,
},
);
return PutDestinationResponse.fromJson(jsonResponse.body);
}