2018-11-27 21:55:03 +00:00
|
|
|
# copyright: 2018, The Authors
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
title "Sample Section"
|
2018-11-27 21:55:03 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
aws_vpc_id = attribute("aws_vpc_id", default: "", description: "Optional AWS VPC identifier.")
|
2018-11-27 21:55:03 +00:00
|
|
|
|
2019-02-22 14:55:50 +00:00
|
|
|
# You add controls here
|
2019-06-11 22:24:35 +00:00
|
|
|
control "aws-single-vpc-exists-check" do # A unique ID for this control.
|
|
|
|
only_if { aws_vpc_id != "" } # Only run this control if the `aws_vpc_id` attribute is provided.
|
2018-11-27 21:55:03 +00:00
|
|
|
impact 1.0 # The criticality, if this control fails.
|
2019-06-11 22:24:35 +00:00
|
|
|
title "Check to see if custom VPC exists." # A human-readable title.
|
2018-11-27 21:55:03 +00:00
|
|
|
describe aws_vpc(aws_vpc_id) do # The test itself.
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-08 15:55:46 +00:00
|
|
|
# Plural resources can be inspected to check for specific resource details.
|
2019-06-11 22:24:35 +00:00
|
|
|
control "aws-vpcs-check" do
|
2019-03-08 15:55:46 +00:00
|
|
|
impact 1.0
|
2019-06-11 22:24:35 +00:00
|
|
|
title "Check in all the VPCs for default sg not allowing 22 inwards"
|
2019-03-08 15:55:46 +00:00
|
|
|
aws_vpcs.vpc_ids.each do |vpc_id|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe aws_security_group(vpc_id: vpc_id, group_name: "default") do
|
2019-03-08 15:55:46 +00:00
|
|
|
it { should allow_in(port: 22) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
control "aws-vpcs-multi-region-status-check" do # A unique ID for this control.
|
2019-02-22 14:55:50 +00:00
|
|
|
impact 1.0 # The criticality, if this control fails.
|
|
|
|
title 'Check AWS VPCs in all regions have status "available"' # A human-readable title.
|
|
|
|
aws_regions.region_names.each do |region| # Loop over all available AWS regions
|
|
|
|
aws_vpcs(aws_region: region).vpc_ids.each do |vpc| # Find all VPCs in a single AWS region
|
|
|
|
describe aws_vpc(aws_region: region, vpc_id: vpc) do # The test itself.
|
|
|
|
it { should exist } # Confirms AWS VPC exists
|
|
|
|
it { should be_available } # Confirms AWS VPC has status "available"
|
|
|
|
end
|
2018-11-27 21:55:03 +00:00
|
|
|
end
|
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
end
|