2018-01-23 04:22:37 +00:00
|
|
|
require '_aws'
|
|
|
|
|
2018-01-18 15:51:06 +00:00
|
|
|
class AwsVpcs < Inspec.resource(1)
|
|
|
|
name 'aws_vpcs'
|
|
|
|
desc 'Verifies settings for AWS VPCs in bulk'
|
|
|
|
example '
|
|
|
|
describe aws_vpcs do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
'
|
2018-02-08 04:26:37 +00:00
|
|
|
supports platform: 'aws'
|
|
|
|
|
|
|
|
include AwsPluralResourceMixin
|
2018-01-18 15:51:06 +00:00
|
|
|
|
|
|
|
# Underlying FilterTable implementation.
|
|
|
|
filter = FilterTable.create
|
|
|
|
filter.add_accessor(:entries)
|
|
|
|
.add(:exists?) { |x| !x.entries.empty? }
|
2018-02-08 04:26:37 +00:00
|
|
|
filter.connect(self, :table)
|
2018-01-18 15:51:06 +00:00
|
|
|
|
2018-02-08 04:26:37 +00:00
|
|
|
def validate_params(raw_params)
|
|
|
|
# No params yet
|
|
|
|
unless raw_params.empty?
|
|
|
|
raise ArgumentError, 'aws_vpcs does not accept resource parameters'
|
|
|
|
end
|
|
|
|
raw_params
|
2018-01-18 15:51:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
'VPCs'
|
|
|
|
end
|
|
|
|
|
2018-02-08 04:26:37 +00:00
|
|
|
def fetch_from_api
|
|
|
|
@table = BackendFactory.create(inspec_runner).describe_vpcs.to_h[:vpcs]
|
2018-01-18 15:51:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class Backend
|
2018-02-08 04:26:37 +00:00
|
|
|
class AwsClientApi < AwsBackendBase
|
2018-01-18 15:51:06 +00:00
|
|
|
BackendFactory.set_default_backend(self)
|
2018-02-08 04:26:37 +00:00
|
|
|
self.aws_client_class = Aws::EC2::Client
|
2018-01-18 15:51:06 +00:00
|
|
|
|
|
|
|
def describe_vpcs(query = {})
|
2018-02-08 04:26:37 +00:00
|
|
|
aws_service_client.describe_vpcs(query)
|
2018-01-18 15:51:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|