aws_cloudwatchlogs_log_streams resource
Use the aws_cloudwatchlogs_log_streams InSpec audit resource to test properties of the plural resource of AWS Logs log stream.
The AWS::Logs::LogStream resource specifies an Amazon CloudWatch Logs log stream in a specific log group. A log stream represents the sequence of events coming from an application instance or resource that you are monitoring.
For additional information, including details on parameters and properties, see the AWS documentation on AWS Logs LogStream..
Syntax
Ensure that the log stream exists.
describe aws_cloudwatchlogs_log_streams(log_group_name: "LOG_GROUP_NAME") do
it { should exist }
end
Parameters
log_group_name(required)The name of the log group.
Properties
log_stream_names- The name of the log stream.
Field:
log_stream_namecreation_times- The creation time of the stream, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
Field:
creation_timefirst_event_timestamps- The time of the first event, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
Field:
first_event_timestamplast_event_timestamps- The time of the most recent log event in the log stream in CloudWatch Logs.
Field:
last_event_timestamplast_ingestion_times- The ingestion time, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
Field:
last_ingestion_timeupload_sequence_tokens- The sequence token.
Field:
upload_sequence_tokenarns- The Amazon Resource Name (ARN) of the log stream.
Field:
arnstored_bytes- The number of bytes stored.
Field:
stored_bytes
Examples
Ensure a log stream name is available:
describe aws_cloudwatchlogs_log_streams(log_group_name: "LOG_GROUP_NAME") do
its('log_stream_names') { should include 'LOG_STREAM_NAME' }
end
Ensure a log stream arn is available:
describe aws_cloudwatchlogs_log_streams(log_group_name: "LOG_GROUP_NAME") do
its('arns') { should include 'LOG_STREAM_ARN' }
end
Matchers
For a full list of available matchers, see our Universal Matchers page.The controls will pass if the describe method returns at least one result.
exist
Use should to test that the entity exists.
describe aws_cloudwatchlogs_log_streams(log_group_name: "LOG_GROUP_NAME") do
it { should exist }
end
Use should_not to test the entity does not exist.
describe aws_cloudwatchlogs_log_streams(log_group_name: "LOG_GROUP_NAME") do
it { should_not exist }
end
AWS Permissions
Your AWS principal will need the CloudWatchLogs:Client:DescribeLogStreamsResponse action with Effect set to Allow.