diff --git a/build/inspec b/build/inspec index 226fac41a2c5..1753ef973bf0 160000 --- a/build/inspec +++ b/build/inspec @@ -1 +1 @@ -Subproject commit 226fac41a2c59afa4cf2be0220ad6bddd190a351 +Subproject commit 1753ef973bf0b4b777fcbb9ddd9bb4a08cf16eb8 diff --git a/products/compute/inspec.yaml b/products/compute/inspec.yaml index bdba437e40e6..def5191d469c 100644 --- a/products/compute/inspec.yaml +++ b/products/compute/inspec.yaml @@ -31,8 +31,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides end ForwardingRule: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true - GlobalForwardingRule: !ruby/object:Overrides::Inspec::ResourceOverride - exclude: true Image: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true Instance: !ruby/object:Overrides::Inspec::ResourceOverride diff --git a/templates/inspec/examples/attributes/google_compute_global_forwarding_rule.erb b/templates/inspec/examples/attributes/google_compute_global_forwarding_rule.erb new file mode 100644 index 000000000000..b28de737a3de --- /dev/null +++ b/templates/inspec/examples/attributes/google_compute_global_forwarding_rule.erb @@ -0,0 +1,2 @@ +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') +global_forwarding_rule = attribute('global_forwarding_rule', default: <%= JSON.pretty_generate(grab_attributes['global_forwarding_rule']) -%>, description: 'Compute global forwarding rule definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_global_forwarding_rule.erb b/templates/inspec/examples/google_compute_global_forwarding_rule.erb new file mode 100644 index 000000000000..451617be56bd --- /dev/null +++ b/templates/inspec/examples/google_compute_global_forwarding_rule.erb @@ -0,0 +1,11 @@ +<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% global_forwarding_rule = grab_attributes['global_forwarding_rule'] -%> +describe google_compute_global_forwarding_rule(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{global_forwarding_rule['name']}'" : "global_forwarding_rule['name']" -%>) do + it { should exist } + its('port_range') { should eq <%= doc_generation ? "'#{global_forwarding_rule['port_range']}'" : "global_forwarding_rule['port_range']" -%> } + its('target') { should match /\/<%= "#{grab_attributes['http_proxy']['name']}" -%>$/ } +end + +describe google_compute_global_forwarding_rule(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: 'nonexistent') do + it { should_not exist } +end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_global_forwarding_rules.erb b/templates/inspec/examples/google_compute_global_forwarding_rules.erb new file mode 100644 index 000000000000..109c4857056a --- /dev/null +++ b/templates/inspec/examples/google_compute_global_forwarding_rules.erb @@ -0,0 +1,6 @@ +<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% global_forwarding_rule = grab_attributes['global_forwarding_rule'] -%> +describe google_compute_global_forwarding_rules(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do + its('count') { should be >= 1 } + its('port_ranges') { should include <%= doc_generation ? "'#{global_forwarding_rule['port_range']}'" : "global_forwarding_rule['port_range']" -%> } +end \ No newline at end of file diff --git a/templates/inspec/tests/integration/build/gcp-mm.tf b/templates/inspec/tests/integration/build/gcp-mm.tf index 9420d8e4a24b..c214ce73692c 100644 --- a/templates/inspec/tests/integration/build/gcp-mm.tf +++ b/templates/inspec/tests/integration/build/gcp-mm.tf @@ -66,6 +66,10 @@ variable "http_proxy" { type = "map" } +variable "global_forwarding_rule" { + type = "map" +} + resource "google_compute_ssl_policy" "custom-ssl-policy" { name = "${var.ssl_policy["name"]}" min_tls_version = "${var.ssl_policy["min_tls_version"]}" @@ -277,4 +281,11 @@ resource "google_compute_target_http_proxy" "gcp-inspec-http-proxy" { name = "${var.http_proxy["name"]}" url_map = "${google_compute_url_map.gcp-inspec-url-map.self_link}" description = "${var.http_proxy["description"]}" +} + +resource "google_compute_global_forwarding_rule" "gcp-inspec-global-forwarding-rule" { + project = "${var.gcp_project_id}" + name = "${var.global_forwarding_rule["name"]}" + target = "${google_compute_target_http_proxy.gcp-inspec-http-proxy.self_link}" + port_range = "${var.global_forwarding_rule["port_range"]}" } \ No newline at end of file diff --git a/templates/inspec/tests/integration/configuration/mm-attributes.yml b/templates/inspec/tests/integration/configuration/mm-attributes.yml index afb998ff0b14..76bf03a268a6 100644 --- a/templates/inspec/tests/integration/configuration/mm-attributes.yml +++ b/templates/inspec/tests/integration/configuration/mm-attributes.yml @@ -106,3 +106,7 @@ url_map: http_proxy: name: inspec-gcp-http-proxy description: A HTTP proxy + +global_forwarding_rule: + name: inspec-gcp-global-forwarding-rule + port_range: 80-80 \ No newline at end of file