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

Inspec regional cluster #1295

Merged
merged 11 commits into from
Jan 30, 2019
Prev Previous commit
Next Next commit
Add inspec tests for regional clusters
  • Loading branch information
slevenick authored and modular-magician committed Jan 30, 2019
commit 3232c358496e681747670f29d20592a11c6639e1
2 changes: 1 addition & 1 deletion products/container/inspec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Google Inc.
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
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.')
regional_cluster = attribute('regional_cluster', default: <%= JSON.pretty_generate(grab_attributes['regional_cluster']) -%>, description: 'Regional container cluster definition')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% regional_cluster = grab_attributes['regional_cluster'] -%>
describe google_container_regional_cluster(project: <%= gcp_project_id -%>, location: <%= doc_generation ? "'#{regional_cluster['region']}'" : "regional_cluster['region']" -%>, name: <%= doc_generation ? "'#{regional_cluster['name']}'" : "regional_cluster['name']" -%>) do
it { should exist }
its('initial_node_count') { should eq <%= doc_generation ? "'#{regional_cluster['initial_node_count']}'" : "regional_cluster['initial_node_count']" -%>}
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% regional_cluster = grab_attributes['regional_cluster'] -%>
describe google_container_regional_cluster(project: <%= gcp_project_id -%>, location: <%= doc_generation ? "'#{regional_cluster['region']}'" : "regional_cluster['region']" -%>, name: <%= doc_generation ? "'#{regional_cluster['name']}'" : "regional_cluster['name']" -%>) do
it { should exist }
end
11 changes: 11 additions & 0 deletions templates/inspec/tests/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ variable "target_tcp_proxy" {
type = "map"
}

variable "regional_cluster" {
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 @@ -308,4 +312,11 @@ resource "google_compute_target_tcp_proxy" "gcp-inspec-target-tcp-proxy" {
name = "${var.target_tcp_proxy["name"]}"
proxy_header = "${var.target_tcp_proxy["proxy_header"]}"
backend_service = "${google_compute_backend_service.gcp-inspec-tcp-backend-service.self_link}"
}

resource "google_container_cluster" "gcp-inspec-regional-cluster" {
project = "${var.gcp_project_id}"
name = "${var.regional_cluster["name"]}"
region = "${var.regional_cluster["region"]}"
initial_node_count = "${var.regional_cluster["initial_node_count"]}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ global_forwarding_rule:
target_tcp_proxy:
name: inspec-gcp-target-tcp-proxy
proxy_header: NONE
tcp_backend_service_name: gcp-inspec-tcp-backend-service
tcp_backend_service_name: gcp-inspec-tcp-backend-service

regional_cluster:
name: inspec-gcp-regional-cluster
region: europe-west2
initial_node_count: 3