Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a default limit = 1 value to aws_cloudwatch_log_group.rb #928

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ end
: This resource accepts a single parameter, the log group name which uniquely identifies the CloudWatch Log Group.
This can be passed either as a string or as a `log_group_name: 'value'` key-value entry in a hash.

`limit` _(optional)_

: This resource accepts a single parameter, an integer representing the number of results allowed to return. If not passed, in, this defaults to `1`, which will only return the first match to the `log_group_name`.
This can be passed as a `limit: 'value'` key-value entry in a hash.

## Properties

`retention_in_days`
Expand Down
5 changes: 3 additions & 2 deletions libraries/aws_cloudwatch_log_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AwsCloudWatchLogGroup < AwsResourceBase
name 'aws_cloudwatch_log_group'
desc 'Verifies settings for an AWS CloudWatch Log Group.'

attr_reader :log_group_name, :retention_in_days, :metric_filter_count, :kms_key_id, :tags, :arn
attr_reader :log_group_name, :limit, :retention_in_days, :metric_filter_count, :kms_key_id, :tags, :arn

def initialize(opts = {})
opts = { log_group_name: opts } if opts.is_a?(String)
Expand All @@ -18,9 +18,10 @@ def initialize(opts = {})
end

@log_group_name = opts[:log_group_name]
@limit = opts[:limit] ? opts[:limit].to_i : 1

catch_aws_errors do
resp = @aws.cloudwatchlogs_client.describe_log_groups({ log_group_name_prefix: @log_group_name })
resp = @aws.cloudwatchlogs_client.describe_log_groups({ log_group_name_prefix: @log_group_name, limit: @limit })
@log_groups = resp.log_groups
end

Expand Down