mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
add aws connection helper
This commit is contained in:
parent
46b65ba490
commit
89209a91f8
3 changed files with 24 additions and 5 deletions
|
@ -8,7 +8,3 @@ describe aws_ec2(name: 'aws-inspec') do
|
|||
its('vpc_id') { should eq 'vpc-1234567' }
|
||||
its('subnet_id') { should eq 'subnet-1234567' }
|
||||
end
|
||||
|
||||
describe aws_ec2(name: 'aws-opsworks-cm-serdar2') do
|
||||
it { should_not be_running }
|
||||
end
|
||||
|
|
23
libraries/aws_conn.rb
Normal file
23
libraries/aws_conn.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# author: Christoph Hartmann
|
||||
|
||||
class AWSConnection
|
||||
def initialize
|
||||
require 'aws-sdk'
|
||||
opts = {
|
||||
region: ENV['AWS_DEFAULT_REGION'],
|
||||
credentials: Aws::Credentials.new(
|
||||
ENV['AWS_ACCESS_KEY_ID'],
|
||||
ENV['AWS_SECRET_ACCESS_KEY'],
|
||||
),
|
||||
}
|
||||
Aws.config.update(opts)
|
||||
end
|
||||
|
||||
def ec2_resource
|
||||
@ec2_resource ||= Aws::EC2::Resource.new
|
||||
end
|
||||
|
||||
def ec2_client
|
||||
@ec2_client ||= Aws::EC2::Client.new
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ require 'aws_conn'
|
|||
|
||||
class Ec2 < Inspec.resource(1)
|
||||
name 'aws_ec2'
|
||||
desc 'Returns information about an EC2 instance'
|
||||
desc 'Verifies settings for an EC2 instance'
|
||||
|
||||
example "
|
||||
describe aws_ec2('i-123456') do
|
||||
|
|
Loading…
Reference in a new issue