Skip to content

Commit

Permalink
Remove unnecessary boilerplate; fix network provider
Browse files Browse the repository at this point in the history
  • Loading branch information
zefdelgadillo committed Sep 26, 2019
1 parent 136acf2 commit 381fc21
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 99 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
# Please note that this file was generated from [terraform-google-module-template](https://github.com/terraform-google-modules/terraform-google-module-template).
# Please make sure to contribute relevant changes upstream!

SHELL := /usr/bin/env bash # Make will use bash instead of sh
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.0.1
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.1.0
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

# Enter docker container for local development
.PHONY: docker_run
docker_run:
docker run --rm -it \
Expand All @@ -41,7 +43,7 @@ docker_test_prepare:
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/usr/local/bin/execute_with_credentials.sh prepare_environment

# Cleanup tests within the docker container
# Clean up test environment within the docker container
.PHONY: docker_test_cleanup
docker_test_cleanup:
docker run --rm -it \
Expand All @@ -53,7 +55,7 @@ docker_test_cleanup:
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/usr/local/bin/execute_with_credentials.sh cleanup_environment

# Execute integration tests within the docker container
# Execute integration tests within the docker container
.PHONY: docker_test_integration
docker_test_integration:
docker run --rm -it \
Expand All @@ -62,7 +64,7 @@ docker_test_integration:
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/usr/local/bin/test_integration.sh

# Execute lint tests within the docker container
# Execute lint tests within the docker container
.PHONY: docker_test_lint
docker_test_lint:
docker run --rm -it \
Expand All @@ -78,5 +80,6 @@ docker_generate_docs:
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'

# Alias for backwards compatibility
.PHONY: generate_docs
generate_docs: docker_generate_docs
generate_docs: docker_generate_docs
2 changes: 1 addition & 1 deletion examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "google_service_account" "instance-group" {
module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 1.0.0"
subnetwork = google_compute_subnetwork.subnetwork.name
subnetwork = google_compute_subnetwork.subnetwork.self_link
source_image_family = var.image_family
source_image_project = var.image_project
startup_script = data.template_file.instance_startup_script.rendered
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ resource "google_compute_network" "network" {

resource "google_compute_subnetwork" "subnetwork" {
name = "load-balancer-module-subnetwork"
region = var.region
network = google_compute_network.network.self_link
ip_cidr_range = "10.0.0.0/16"
}

resource "google_compute_router" "router" {
name = "load-balancer-module-router"
region = var.region
network = google_compute_network.network.self_link
}

Expand Down
2 changes: 0 additions & 2 deletions examples/basic/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
provider "google" {
version = ">= 2.7.0"
project = var.project_id
region = var.region
}

provider "google-beta" {
version = ">= 2.7.0"
project = var.project_id
region = var.region
}
3 changes: 1 addition & 2 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ suites:
driver:
root_module_directory: test/fixtures/basic/
verifier:
name: terraform
color: false
systems:
- name: system
- name: basic local
backend: local
controls:
- gcloud
24 changes: 11 additions & 13 deletions test/integration/basic/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

project_id = attribute('project_id')

control "gcloud" do
title "gcloud"
describe command("gcloud compute forwarding-rules list --format json") do
its('exit_status') { should be 0 }
its('stderr') { should eq '' }
title "gcloud"
describe command("gcloud compute forwarding-rules list --project=#{attribute("project_id")} --format json") do
its('exit_status') { should be 0 }
its('stderr') { should eq '' }

let(:data) do
if subject.exit_status == 0
JSON.parse(subject.stdout, symbolize_names: true)
else
{}
end
let(:data) do
if subject.exit_status == 0
JSON.parse(subject.stdout, symbolize_names: true)
else
{}
end
it { expect(data.first).to include(IPProtocol: 'TCP') }
end
it { expect(data.first).to include(IPProtocol: 'TCP') }
end
end
4 changes: 4 additions & 0 deletions test/integration/basic/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: basic
depends:
- name: inspec-gcp
git: https://github.com/inspec/inspec-gcp.git
tag: v0.10.0
attributes:
- name: project_id
required: true
Expand Down
1 change: 0 additions & 1 deletion test/setup/make_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
echo "#!/usr/bin/env bash" > ../source.sh

project_id=$(terraform output project_id)
echo "gcloud config set project $project_id" >> ../source.sh
echo "export TF_VAR_project_id='$project_id'" >> ../source.sh

sa_json=$(terraform output sa_key)
Expand Down
74 changes: 0 additions & 74 deletions test/task_helper_functions.sh

This file was deleted.

0 comments on commit 381fc21

Please sign in to comment.