As per the link for additional properties for resource "aws_ec2_instance" in the docs give the attribute
name for checking the monitoring status of instance but on using it it throws error as undefined method. please help
describe aws_ec2_instance(instanceid) do
its('monitoring') { should cmp "enabled"}
end
the above test throws error as "monitoring method is undefined"
Hi sudhakar,
It looks like you have two issues.
First, and most importantly, you are not importing the inspec-aws resource pack as a dependency. You must do this to get access to the current methods and features documented. To include inspec-aws, add the following to your inspec.yml file:
This will cause your profile to rely on the new resource definitions included in the inspec-aws resource pack, and your experience will be much smoother.
Secondly, the syntax for checking the status of monitoring is:
control "my_control" do
describe aws_ec2_instance(instance_id) do
it { should exist } # It is recommended to perform an existence check before checking a property
its("monitoring.state") { should cmp "enabled" } # Note ".state"
end
end