Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compute global address to InSpec #1309

Merged
merged 2 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions products/compute/inspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
end
ForwardingRule: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
GlobalAddress: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
GlobalForwardingRule: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
Image: !ruby/object:Overrides::Inspec::ResourceOverride
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.')
global_address = attribute('global_address', default: <%= JSON.pretty_generate(grab_attributes['global_address']) -%>, description: 'Compute Global Address definition')
10 changes: 10 additions & 0 deletions templates/inspec/examples/google_compute_global_address.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% global_address = grab_attributes['global_address'] -%>
describe google_compute_global_address(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{global_address['name']}'" : "global_address['name']" -%>) do
it { should exist }
its('ip_version') { should eq <%= doc_generation ? "'#{global_address['ip_version']}'" : "global_address['ip_version']" -%> }
end

describe google_compute_global_address(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: 'nonexistent') do
it { should_not exist }
end
7 changes: 7 additions & 0 deletions templates/inspec/examples/google_compute_global_addresses.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% global_address = grab_attributes['global_address'] -%>
describe google_compute_global_addresses(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{global_address['name']}'" : "global_address['name']" -%>) do
its('count') { should be >= 1 }
its('names') { should include <%= doc_generation ? "'#{global_address['name']}'" : "global_address['name']" -%> }
its('ip_versions') { should include <%= doc_generation ? "'#{global_address['ip_version']}'" : "global_address['ip_version']" -%> }
end
10 changes: 10 additions & 0 deletions templates/inspec/tests/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ variable "instance_template" {
type = "map"
}

variable "global_address" {
type = "map"
}

resource "google_compute_ssl_policy" "custom-ssl-policy" {
name = "${var.ssl_policy["name"]}"
min_tls_version = "${var.ssl_policy["min_tls_version"]}"
Expand Down Expand Up @@ -223,4 +227,10 @@ resource "google_compute_instance_template" "gcp-inspec-instance-template" {
service_account {
scopes = ["${var.instance_template["service_account_scope"]}"]
}
}

resource "google_compute_global_address" "gcp-inspec-global-address" {
project = "${var.gcp_project_id}"
name = "${var.global_address["name"]}"
ip_version = "${var.global_address["ip_version"]}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ instance_template:
disk_auto_delete: true
disk_boot: true
network_interface_network: default
service_account_scope: storage-ro
service_account_scope: storage-ro

global_address:
name: inspec-gcp-global-address
ip_version: IPV6