putDestination method

Future<PutDestinationResponse> putDestination({
  1. required String destinationName,
  2. required String roleArn,
  3. required String targetArn,
})

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) and enables you to 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.

Implementation

Future<PutDestinationResponse> putDestination({
  required String destinationName,
  required String roleArn,
  required String targetArn,
}) async {
  ArgumentError.checkNotNull(destinationName, 'destinationName');
  _s.validateStringLength(
    'destinationName',
    destinationName,
    1,
    512,
    isRequired: true,
  );
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(targetArn, 'targetArn');
  _s.validateStringLength(
    'targetArn',
    targetArn,
    1,
    1152921504606846976,
    isRequired: true,
  );
  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,
    },
  );

  return PutDestinationResponse.fromJson(jsonResponse.body);
}