inspec/test/integration/verify/controls/aws_ec2_instance.rb
Chris Redekop c8d4244ef4 Add has_roles to aws_ec2_instance (#90)
* Rename EC2-instance resources

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Add interim updates

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* testing for issue 82

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* completed integration for EC2 roles

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* adding in the beginning of the unit test for issue 82

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* Fix unit tests

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Add has_roles? examples

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Remove redundant gsub

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* corrected OpenStruct format

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* setting up variable for InstanceProfile

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* Updated the unit test so all variables are at the top

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* Fixed Rubocop issues that were detected

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* Updating README.md to include changes to aws_ec2

Signed-off-by: Simon Varlow <simon.varlow@d2l.com>

* Add failing IT for has_roles?

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Add negative IT and fix uncovered issue

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Fix Rubocop issue

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Fix integration test

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Fix Rubocop issues and unit tests

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>

* Pin AWS dependency to '~> 2'

Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
2017-10-26 15:56:32 -04:00

37 lines
1 KiB
Ruby

example_ec2_id = attribute(
'example_ec2_id',
default: 'default.example_ec2_id',
description: 'ID of example ec2 instance')
example_ec2_name = attribute(
'example_ec2_name',
default: 'default.Example',
description: 'Name of example ec2 instance')
no_roles_ec2_id = attribute(
'no_roles_ec2_id',
default: 'default.no_roles_ec2_id',
description: 'ID of no-roles ec2 instance')
describe aws_ec2_instance(name: example_ec2_name) do
it { should exist }
its('image_id') { should eq 'ami-0d729a60' }
its('instance_type') { should eq 't2.micro' }
end
describe aws_ec2_instance(example_ec2_id) do
it { should exist }
its('image_id') { should eq 'ami-0d729a60' }
its('instance_type') { should eq 't2.micro' }
it { should have_roles }
end
describe aws_ec2_instance(no_roles_ec2_id) do
it { should exist }
it { should_not have_roles }
end
# must use a real EC2 instance name, as the SDK will first check to see if it's well formed before sending requests
describe aws_ec2_instance('i-06b4bc106e0d03dfd') do
it { should_not exist }
end