2018-10-25 18:16:31 +00:00
|
|
|
# copyright: 2018, The Authors
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
title "Sample Section"
|
2018-10-25 18:16:31 +00:00
|
|
|
|
2021-03-17 14:15:10 +00:00
|
|
|
gcp_project_id = input("gcp_project_id")
|
2018-10-25 18:16:31 +00:00
|
|
|
|
|
|
|
# you add controls here
|
2019-06-11 22:24:35 +00:00
|
|
|
control "gcp-single-region-1.0" do # A unique ID for this control
|
2018-10-25 18:16:31 +00:00
|
|
|
impact 1.0 # The criticality, if this control fails.
|
2019-06-11 22:24:35 +00:00
|
|
|
title "Ensure single region has the correct properties." # A human-readable title
|
|
|
|
desc "An optional description..."
|
|
|
|
describe google_compute_region(project: gcp_project_id, name: "europe-west2") do # The actual test
|
|
|
|
its("zone_names") { should include "europe-west2-a" }
|
2018-10-25 18:16:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# plural resources can be leveraged to loop across many resources
|
2019-06-11 22:24:35 +00:00
|
|
|
control "gcp-regions-loop-1.0" do # A unique ID for this control
|
2018-10-25 18:16:31 +00:00
|
|
|
impact 1.0 # The criticality, if this control fails.
|
2019-06-11 22:24:35 +00:00
|
|
|
title "Ensure regions have the correct properties in bulk." # A human-readable title
|
|
|
|
desc "An optional description..."
|
2018-10-25 18:16:31 +00:00
|
|
|
google_compute_regions(project: gcp_project_id).region_names.each do |region_name| # Loop across all regions by name
|
|
|
|
describe google_compute_region(project: gcp_project_id, name: region_name) do # The test for a single region
|
|
|
|
it { should be_up }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|