Reputation: 153
I defined some basic Inspec tests to check if a loadbalancer is active:
proxy = attribute('proxy_netlb_arn')
control 'Checks if all the ECE Load balancers are active ' do
impact 1.0
title 'Checks if all the ECE Load balancers are active'
describe command("aws elbv2 describe-load-balancers --load-balancer-arn proxy['value'] | jq -r '.[][].State.Code'") do
its('stdout') { should match "active" }
end
end
I use a variable called "proxy" which contains the ARN of the Loadbalancer. Unfortunately the variable is not recognized as such because it is inside the command.
Upvotes: 0
Views: 1545
Reputation: 10122
you should use string interpolation to get the value of your string variable.
assuming proxy['value']
returns the value of the proxy
variable. then you can do it as follows:
proxy = attribute('proxy_netlb_arn')
control 'Checks if all the ECE Load balancers are active ' do
impact 1.0
title 'Checks if all the ECE Load balancers are active'
describe command("aws elbv2 describe-load-balancers --load-balancer-arn #{proxy['value']} | jq -r '.[][].State.Code'") do
its('stdout') { should match "active" }
end
end
Upvotes: 1