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

Initial module implementation #1

Merged
merged 32 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
64c7ff1
Initial module implementation
Jberlinsky Dec 20, 2018
d74bc63
Fix typos
Jberlinsky Jan 16, 2019
42a2565
Quote boolean values
Jberlinsky Jan 16, 2019
f552653
Fix Dockerfile build issue
Jberlinsky Jan 16, 2019
5136d3a
Replace data/ directory with templates/
Jberlinsky Jan 16, 2019
035136c
Do not disable project API services when resources are destroyed
Jberlinsky Jan 16, 2019
34374bf
Consolidate gce.tf and jenkins.tf in main.tf
Jberlinsky Jan 16, 2019
31659a8
Clean up and fix user-data script
Jberlinsky Jan 28, 2019
8344970
gitignore generated SSH keys
Jberlinsky Jan 28, 2019
a2ea2ad
Fix path to terraform.tfvars
Jberlinsky Jan 28, 2019
ef21603
Fix packer builds
Jberlinsky Jan 28, 2019
6767363
Use additive IAM associations
Jberlinsky Jan 28, 2019
9e15b21
Extract Bitnami image to variables
Jberlinsky Jan 28, 2019
0c63724
Fix startup-script bootstrapping
Jberlinsky Jan 29, 2019
fddd821
s/credentials_path_relative/credentials_path/g
Jberlinsky Jan 29, 2019
31d3c45
Make tests run in us-east4 by default
Jberlinsky Jan 29, 2019
43f89b4
Add descriptions to test variables and outputs
Jberlinsky Jan 29, 2019
94fb970
Restrict Jenkins SA so it can not edit IAM policies on buckets
Jberlinsky Jan 29, 2019
9a22d58
Add test coverage for firewall rules and IAM bindings
Jberlinsky Jan 29, 2019
dcc1e4e
Fix missing link in README
Jberlinsky Jan 29, 2019
7608340
Fix Markdown formatting
Jberlinsky Jan 29, 2019
e1a6852
Run linter
Jberlinsky Jan 29, 2019
801bdc0
Add CODEOWNERS file
Jberlinsky Jan 29, 2019
9f8d917
Implement Concourse-friendly Docker build pipeline
Jberlinsky Jan 29, 2019
e9cf831
Do not rebuild Docker image as dependency of docker_create
Jberlinsky Jan 29, 2019
54f4915
Do not attach default service account to Packer instance
Jberlinsky Jan 29, 2019
ff1d991
Switch back to devstorage.full_control due to Google Compute Storage …
Jberlinsky Jan 29, 2019
b911cb9
Remove unnecessary service account scope from Jenkins instance
Jberlinsky Feb 16, 2019
e59c327
Disable colored output in CI
Jberlinsky Feb 16, 2019
f7cca41
Extract worker agent startup script to template file
Jberlinsky Feb 17, 2019
8fba12e
Use service accounts instead of network tags for ingress control
Jberlinsky Feb 18, 2019
a2e7f63
Remove default region for Jenkins workers
Jberlinsky Feb 18, 2019
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
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# OSX leaves these everywhere on SMB shares
._*

# OSX trash
.DS_Store

# Python
*.pyc

# Emacs save files
*~
\#*\#
.\#*

# Vim-related files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist

### https://raw.github.com/github/gitignore/90f149de451a5433aebd94d02d11b0e28843a1af/Terraform.gitignore

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Kitchen files
**/inspec.lock
**/.kitchen
**/.kitchen.local.yml
**/Gemfile.lock

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars
**/terraform.tfvars

credentials.json

examples/*/ssh/key
52 changes: 52 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2018 Google LLC
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
driver:
name: "terraform"
command_timeout: 1800

provisioner:
name: "terraform"

platforms:
- name: local

suites:
- name: "simple_example"
lifecycle:
pre_create:
- ./test/fixtures/all_examples/build_image.sh simple_example
driver:
name: "terraform"
command_timeout: 1800
root_module_directory: test/fixtures/simple_example
verifier:
name: terraform
systems:
- name: simple_example
backend: gcp
shell: true
controls:
- gcloud
- name: jenkins
backend: ssh
controls:
- jenkins
hosts_output: jenkins_instance_public_ip
key_files:
- ./test/fixtures/simple_example/ssh/key
user: user
provisioner:
adrienthebo marked this conversation as resolved.
Show resolved Hide resolved
name: terraform
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.3
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed

## [v0.1.0] - 2018-12-20

### Added

* Initial release of module
20 changes: 20 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2018 Google LLC
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ruby '~> 2.5'

source 'https://rubygems.org/' do
gem 'kitchen-terraform', '~> 4.0'
gem 'nokogiri', '~> 1.8'
end
155 changes: 155 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Copyright 2018 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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

# Docker build config variables
BUILD_TERRAFORM_VERSION ?= 0.11.10
BUILD_CLOUD_SDK_VERSION ?= 216.0.0
BUILD_PROVIDER_GOOGLE_VERSION ?= 1.17.1
BUILD_PROVIDER_GSUITE_VERSION ?= 0.1.8
DOCKER_IMAGE_TERRAFORM := cftk/terraform
DOCKER_TAG_TERRAFORM ?= ${BUILD_TERRAFORM_VERSION}_${BUILD_CLOUD_SDK_VERSION}_${BUILD_PROVIDER_GOOGLE_VERSION}_${BUILD_PROVIDER_GSUITE_VERSION}
BUILD_RUBY_VERSION := 2.5.3
DOCKER_IMAGE_KITCHEN_TERRAFORM := cftk/kitchen_terraform
DOCKER_TAG_KITCHEN_TERRAFORM ?= ${BUILD_TERRAFORM_VERSION}_${BUILD_CLOUD_SDK_VERSION}_${BUILD_PROVIDER_GOOGLE_VERSION}_${BUILD_PROVIDER_GSUITE_VERSION}

# All is the first target in the file so it will get picked up when you just run 'make' on its own
all: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace generate_docs

# The .PHONY directive tells make that this isn't a real target and so
# the presence of a file named 'check_shell' won't cause this target to stop
# working
.PHONY: check_shell
check_shell:
@source test/make.sh && check_shell

.PHONY: check_python
check_python:
@source test/make.sh && check_python

.PHONY: check_golang
check_golang:
@source test/make.sh && golang

.PHONY: check_terraform
check_terraform:
@source test/make.sh && check_terraform

.PHONY: check_docker
check_docker:
@source test/make.sh && docker

.PHONY: check_base_files
check_base_files:
@source test/make.sh && basefiles

.PHONY: check_shebangs
check_shebangs:
@source test/make.sh && check_bash

.PHONY: check_trailing_whitespace
check_trailing_whitespace:
@source test/make.sh && check_trailing_whitespace

.PHONY: test_check_headers
test_check_headers:
@echo "Testing the validity of the header check"
@python test/test_verify_boilerplate.py

.PHONY: check_headers
check_headers:
@echo "Checking file headers"
@python test/verify_boilerplate.py

# Integration tests
.PHONY: test_integration
test_integration:
bundle install
bundle exec kitchen create
bundle exec kitchen converge
bundle exec kitchen converge
bundle exec kitchen verify
bundle exec kitchen destroy

.PHONY: generate_docs
generate_docs:
@source test/make.sh && generate_docs

# Versioning
.PHONY: version
version:
@source helpers/version-repo.sh

# Build Docker
.PHONY: docker_build_terraform
docker_build_terraform:
docker build -f build/docker/terraform/Dockerfile \
--build-arg BUILD_TERRAFORM_VERSION=${BUILD_TERRAFORM_VERSION} \
--build-arg BUILD_CLOUD_SDK_VERSION=${BUILD_CLOUD_SDK_VERSION} \
--build-arg BUILD_PROVIDER_GOOGLE_VERSION=${BUILD_PROVIDER_GOOGLE_VERSION} \
--build-arg BUILD_PROVIDER_GSUITE_VERSION=${BUILD_PROVIDER_GSUITE_VERSION} \
-t ${DOCKER_IMAGE_TERRAFORM}:${DOCKER_TAG_TERRAFORM} .

.PHONY: docker_build_kitchen_terraform
docker_build_kitchen_terraform:
docker build -f build/docker/kitchen_terraform/Dockerfile \
--build-arg BUILD_TERRAFORM_IMAGE="${DOCKER_IMAGE_TERRAFORM}:${DOCKER_TAG_TERRAFORM}" \
--build-arg BUILD_RUBY_VERSION="${BUILD_RUBY_VERSION}" \
-t ${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} .

# Run docker
.PHONY: docker_run
docker_run:
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash

.PHONY: docker_create
docker_create: docker_build_terraform docker_build_kitchen_terraform
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen create"

.PHONY: docker_converge
docker_converge:
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen converge"

.PHONY: docker_verify
docker_verify:
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen verify"

.PHONY: docker_destroy
docker_destroy:
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen destroy"

.PHONY: test_integration_docker
test_integration_docker: docker_create docker_converge docker_verify docker_destroy
@echo "Running test-kitchen tests in docker"

.PHONY: prepare_test_variables
prepare_test_variables:
@source test/make.sh && prepare_test_variables
Loading