Skip to content

Commit 0edd677

Browse files
authored
Merge pull request #1 from terraform-google-modules/feature/initial-implementation
Initial module implementation
2 parents aad6a0d + a2e7f63 commit 0edd677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2778
-1
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @morgante @aaron-lane @Jberlinsky @adrienthebo

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# OSX leaves these everywhere on SMB shares
2+
._*
3+
4+
# OSX trash
5+
.DS_Store
6+
7+
# Python
8+
*.pyc
9+
10+
# Emacs save files
11+
*~
12+
\#*\#
13+
.\#*
14+
15+
# Vim-related files
16+
[._]*.s[a-w][a-z]
17+
[._]s[a-w][a-z]
18+
*.un~
19+
Session.vim
20+
.netrwhist
21+
22+
### https://raw.github.com/github/gitignore/90f149de451a5433aebd94d02d11b0e28843a1af/Terraform.gitignore
23+
24+
# Local .terraform directories
25+
**/.terraform/*
26+
27+
# .tfstate files
28+
*.tfstate
29+
*.tfstate.*
30+
31+
# Crash log files
32+
crash.log
33+
34+
# Kitchen files
35+
**/inspec.lock
36+
**/.kitchen
37+
**/.kitchen.local.yml
38+
**/Gemfile.lock
39+
40+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
41+
# .tfvars files are managed as part of configuration and so should be included in
42+
# version control.
43+
#
44+
# example.tfvars
45+
**/terraform.tfvars
46+
47+
credentials.json
48+
49+
test/fixtures/*/ssh/key

.kitchen.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---
16+
driver:
17+
name: "terraform"
18+
command_timeout: 1800
19+
20+
provisioner:
21+
name: "terraform"
22+
23+
platforms:
24+
- name: local
25+
26+
suites:
27+
- name: "simple_example"
28+
lifecycle:
29+
pre_create:
30+
- ./test/fixtures/all_examples/build_image.sh simple_example
31+
driver:
32+
name: "terraform"
33+
command_timeout: 1800
34+
root_module_directory: test/fixtures/simple_example
35+
verifier:
36+
name: terraform
37+
color: false
38+
systems:
39+
- name: simple_example
40+
backend: gcp
41+
shell: true
42+
controls:
43+
- gcloud
44+
- name: jenkins
45+
backend: ssh
46+
controls:
47+
- jenkins
48+
hosts_output: jenkins_instance_public_ip
49+
key_files:
50+
- ./test/fixtures/simple_example/ssh/key
51+
user: user
52+
provisioner:
53+
name: terraform

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.5.3

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
6+
project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
## [Unreleased]
9+
### Changed
10+
11+
## [v0.1.0] - 2018-12-20
12+
13+
### Added
14+
15+
* Initial release of module

Gemfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ruby '~> 2.5'
16+
17+
source 'https://rubygems.org/' do
18+
gem 'kitchen-terraform', '~> 4.0'
19+
gem 'nokogiri', '~> 1.8'
20+
end

Makefile

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Make will use bash instead of sh
16+
SHELL := /usr/bin/env bash
17+
18+
# Docker build config variables
19+
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
20+
DOCKER_ORG := gcr.io/cloud-foundation-cicd
21+
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.10_216.0.0_1.19.1_0.1.10
22+
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
23+
DOCKER_TAG_KITCHEN_TERRAFORM ?= ${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
24+
DOCKER_IMAGE_KITCHEN_TERRAFORM := cft/kitchen-terraform_terraform-google-jenkins-gce
25+
26+
# All is the first target in the file so it will get picked up when you just run 'make' on its own
27+
all: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace generate_docs
28+
29+
# The .PHONY directive tells make that this isn't a real target and so
30+
# the presence of a file named 'check_shell' won't cause this target to stop
31+
# working
32+
.PHONY: check_shell
33+
check_shell:
34+
@source test/make.sh && check_shell
35+
36+
.PHONY: check_python
37+
check_python:
38+
@source test/make.sh && check_python
39+
40+
.PHONY: check_golang
41+
check_golang:
42+
@source test/make.sh && golang
43+
44+
.PHONY: check_terraform
45+
check_terraform:
46+
@source test/make.sh && check_terraform
47+
48+
.PHONY: check_docker
49+
check_docker:
50+
@source test/make.sh && docker
51+
52+
.PHONY: check_base_files
53+
check_base_files:
54+
@source test/make.sh && basefiles
55+
56+
.PHONY: check_shebangs
57+
check_shebangs:
58+
@source test/make.sh && check_bash
59+
60+
.PHONY: check_trailing_whitespace
61+
check_trailing_whitespace:
62+
@source test/make.sh && check_trailing_whitespace
63+
64+
.PHONY: test_check_headers
65+
test_check_headers:
66+
@echo "Testing the validity of the header check"
67+
@python test/test_verify_boilerplate.py
68+
69+
.PHONY: check_headers
70+
check_headers:
71+
@echo "Checking file headers"
72+
@python test/verify_boilerplate.py
73+
74+
# Integration tests
75+
.PHONY: test_integration
76+
test_integration:
77+
bundle install
78+
bundle exec kitchen create
79+
bundle exec kitchen converge
80+
bundle exec kitchen converge
81+
bundle exec kitchen verify
82+
bundle exec kitchen destroy
83+
84+
.PHONY: generate_docs
85+
generate_docs:
86+
@source test/make.sh && generate_docs
87+
88+
# Versioning
89+
.PHONY: version
90+
version:
91+
@source helpers/version-repo.sh
92+
93+
# Build Docker
94+
.PHONY: docker_build_kitchen_terraform
95+
docker_build_kitchen_terraform:
96+
docker build -f build/docker/kitchen_terraform/Dockerfile \
97+
--build-arg BASE_IMAGE=${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
98+
-t ${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} .
99+
100+
# Push Docker image
101+
.PHONY: docker_push_kitchen_terraform
102+
docker_push_kitchen_terraform:
103+
docker tag ${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} ${DOCKER_ORG}/${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM}
104+
docker push ${DOCKER_ORG}/${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM}
105+
106+
# Run docker
107+
.PHONY: docker_run
108+
docker_run:
109+
docker run --rm -it \
110+
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
111+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
112+
-v $(CURDIR):/cft/workdir \
113+
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
114+
/bin/bash
115+
116+
.PHONY: docker_create
117+
docker_create:
118+
docker run --rm -it \
119+
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
120+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
121+
-v $(CURDIR):/cft/workdir \
122+
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
123+
/bin/bash -c "kitchen create"
124+
125+
.PHONY: docker_converge
126+
docker_converge:
127+
docker run --rm -it \
128+
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
129+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
130+
-v $(CURDIR):/cft/workdir \
131+
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
132+
/bin/bash -c "kitchen converge"
133+
134+
.PHONY: docker_verify
135+
docker_verify:
136+
docker run --rm -it \
137+
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
138+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
139+
-v $(CURDIR):/cft/workdir \
140+
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
141+
/bin/bash -c "kitchen verify"
142+
143+
.PHONY: docker_destroy
144+
docker_destroy:
145+
docker run --rm -it \
146+
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
147+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
148+
-v $(CURDIR):/cft/workdir \
149+
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
150+
/bin/bash -c "kitchen destroy"
151+
152+
.PHONY: test_integration_docker
153+
test_integration_docker: docker_create docker_converge docker_verify docker_destroy
154+
@echo "Running test-kitchen tests in docker"

0 commit comments

Comments
 (0)