Skip to main content

aws_elbs resource

[edit on GitHub]

Use the aws_elbs InSpec audit resource to test the configuration of a collection of AWS Elastic Load Balancers.

Syntax

describe aws_elbs do
  its('load_balancer_names') { should include 'elb-name' }
end

Parameters

This resource does not expect any parameters.

See also the AWS documentation on Elastic Load Balancing.

Properties

PropertyDescription
load_balancer_namesThe name of the load balancer.
dns_namesThe DNS name of the load balancer.
availability_zonesThe Availability Zones for the load balancer.
instance_idsAn array containing all instance ids associated with the ELB.
external_portsAn array of the external ports exposed on the ELB.
internal_portsAn array of the internal ports exposed on the ELB.
security_group_idsThe security groups for the load balancer. Valid only for load balancers in a VPC.
vpc_idsThe ID of the VPC for the load balancer.
subnet_id sThe IDs of the subnets for the load balancer.

Examples

Ensure there are no Load Balancers with an undesired zone.

describe aws_elbs do
  it                             { should exist }
  its('availability_zones')      { should_not include 'us-east-1a'}
end

Ensure all ELBs expose only port 80

aws_elbs.each do |elb|
  describe elb do
    its('external_ports.count') { should cmp 1 }
    its('external_ports')       { should include 80 }
    its('internal_ports.count') { should cmp 1 }
    its('internal_ports')       { should include 80 }
  end
end

Matchers

For a full list of available matchers, please visit our matchers page.

exist

The control will pass if the describe returns at least one result.

Use should_not to test the entity should not exist.

describe aws_elbs.where( <property>: <value>) do
  it { should exist }
end

describe aws_elbs.where( <property>: <value>) do
  it { should_not exist }
end

AWS Permissions

Your Principal will need the elasticloadbalancing:DescribeLoadBalancers action set to Allow.

You can find detailed documentation at Authentication and Access Control for Your Load Balancers

Was this page helpful?