2018-02-01 18:09:48 +00:00
|
|
|
class AwsIamGroups < Inspec.resource(1)
|
|
|
|
name 'aws_iam_groups'
|
|
|
|
desc 'Verifies settings for AWS IAM groups in bulk'
|
|
|
|
example '
|
|
|
|
describe aws_iam_groups do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
'
|
2018-02-08 04:26:37 +00:00
|
|
|
supports platform: 'aws'
|
|
|
|
|
|
|
|
include AwsPluralResourceMixin
|
|
|
|
|
|
|
|
def validate_params(resource_params)
|
|
|
|
unless resource_params.empty?
|
|
|
|
raise ArgumentError, 'aws_iam_groups does not accept resource parameters.'
|
|
|
|
end
|
|
|
|
resource_params
|
|
|
|
end
|
2018-02-01 18:09:48 +00:00
|
|
|
|
|
|
|
# Underlying FilterTable implementation.
|
|
|
|
filter = FilterTable.create
|
2018-06-26 19:14:21 +00:00
|
|
|
filter.register_column(:group_names, field: :group_name)
|
|
|
|
filter.install_filter_methods_on_resource(self, :table)
|
2018-02-01 18:09:48 +00:00
|
|
|
|
|
|
|
def to_s
|
|
|
|
'IAM Groups'
|
|
|
|
end
|
|
|
|
|
2018-02-08 04:26:37 +00:00
|
|
|
def fetch_from_api
|
|
|
|
backend = BackendFactory.create(inspec_runner)
|
2018-03-02 18:45:17 +00:00
|
|
|
@table = []
|
|
|
|
pagination_opts = {}
|
|
|
|
loop do
|
|
|
|
api_result = backend.list_groups(pagination_opts)
|
|
|
|
@table += api_result.groups.map(&:to_h)
|
|
|
|
pagination_opts = { marker: api_result.marker }
|
|
|
|
break unless api_result.is_truncated
|
|
|
|
end
|
2018-02-01 18:09:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class Backend
|
2018-02-08 04:26:37 +00:00
|
|
|
class AwsClientApi < AwsBackendBase
|
2018-02-01 18:09:48 +00:00
|
|
|
BackendFactory.set_default_backend(self)
|
2018-02-08 04:26:37 +00:00
|
|
|
self.aws_client_class = Aws::IAM::Client
|
2018-02-01 18:09:48 +00:00
|
|
|
|
|
|
|
def list_groups(query = {})
|
2018-02-08 04:26:37 +00:00
|
|
|
aws_service_client.list_groups(query)
|
2018-02-01 18:09:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|