0
I'm trying to perform some testing on infrastructure that's created using Terraform. This specific test is testing an auto scaling group. I don't know the full name of the resource as it's appended with a dynamic token, but I know the start of the resource name which is set in the asg_name
variable. I've got the following code:
asg_name = input('asg_name')
control 'aws_auto_scaling_groups' do
title 'Auto Scale Group'
desc 'Ensures Autoscale Group exists with correct configuration'
describe aws_auto_scaling_group ( name: /^#{asg_name}*/ ) do
it { should exist }
its('min_size') { should be 1}
its('max_size') { should be 1}
end
end
This is failing with the following:
/opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-5.17.4/lib/inspec/profile_context.rb:171:in `instance_eval': aws/controls/loadbalancer.rb:6: syntax error, unexpected tLABEL, expecting ')' (SyntaxError)
... aws_auto_scaling_group ( name: /^#{asg_name}*/ ) do
... ^~~~~
aws/controls/loadbalancer.rb:12: syntax error, unexpected `end', expecting end-of-input
I've tried a number of different options, including using aws_auto_scaling_groups.where
which didn't work as expected as it returned an array, but I still haven't been able to get it working. Please can anyone tell me how I do a match against a name for a single resource like this using InSpec.
Thank you in advance!