createLogGroup method
Creates a log group with the specified name. You can create up to 20,000 log groups per account.
You must use the following guidelines when naming a log group:
- Log group names must be unique within a region for an AWS account.
- Log group names can be between 1 and 512 characters long.
- Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), '/' (forward slash), '.' (period), and '#' (number sign)
If you associate a AWS Key Management Service (AWS KMS) customer master key (CMK) with the log group, ingested data is encrypted using the CMK. This association is stored as long as the data encrypted with the CMK is still within Amazon CloudWatch Logs. This enables Amazon CloudWatch Logs to decrypt this data whenever it is requested.
If you attempt to associate a CMK with the log group but the CMK does not
exist or the CMK is disabled, you receive an
InvalidParameterException
error.
May throw InvalidParameterException. May throw ResourceAlreadyExistsException. May throw LimitExceededException. May throw OperationAbortedException. May throw ServiceUnavailableException.
Parameter logGroupName
:
The name of the log group.
Parameter kmsKeyId
:
The Amazon Resource Name (ARN) of the CMK to use when encrypting log data.
For more information, see Amazon
Resource Names - AWS Key Management Service (AWS KMS).
Parameter tags
:
The key-value pairs to use for the tags.
Implementation
Future<void> createLogGroup({
required String logGroupName,
String? kmsKeyId,
Map<String, String>? tags,
}) async {
ArgumentError.checkNotNull(logGroupName, 'logGroupName');
_s.validateStringLength(
'logGroupName',
logGroupName,
1,
512,
isRequired: true,
);
_s.validateStringLength(
'kmsKeyId',
kmsKeyId,
0,
256,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Logs_20140328.CreateLogGroup'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'logGroupName': logGroupName,
if (kmsKeyId != null) 'kmsKeyId': kmsKeyId,
if (tags != null) 'tags': tags,
},
);
}