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

1.0 - G Suite Refactor #94

Merged
merged 117 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
af62340
Add v1.0.0 migration document
adrienthebo Dec 20, 2018
a89d266
Work on unifying migration instructions.
morgante Jan 3, 2019
0f84b77
Add some troubleshooting notes... temporarily borked
morgante Jan 3, 2019
aee71c2
Unify instructions
morgante Jan 3, 2019
e178be6
Update upgrading_to_project_factory_v1.0.md
morgante Jan 3, 2019
7fa06ff
adding gke shared vpc functionality and some cleanup
Jul 31, 2018
56322b2
first pass at making gsuite optional
Aug 23, 2018
aa6d2e5
first run at making the gsuite provider optional
Aug 29, 2018
4a3b236
changing example
Aug 29, 2018
759a96c
cleanup
Aug 29, 2018
74c95f4
removing unecessary dependencies
Sep 5, 2018
183bf5f
+using module outputs instead of re-adding resource +deleting comment…
Sep 6, 2018
b0fec4e
+using module outputs instead of re-adding resource +deleting comment…
Sep 6, 2018
d2e097d
removing gsuite from simple project example
Sep 7, 2018
12a7385
getting up to date with master v2
Sep 7, 2018
e51e572
Update main.tf
cpearring Sep 12, 2018
1862dad
Update variables.tf
cpearring Sep 12, 2018
5b451fb
keeping up to date with master, adding in migrate.sh script as first …
Sep 14, 2018
488c9e7
removing set variables
Sep 19, 2018
6c413cb
Fix duplicate variable
morgante Sep 21, 2018
e65e55a
Fixups for moved modules and deleted variables
adrienthebo Sep 24, 2018
7aad8a2
terraform fmt and moving group email to locals
Oct 4, 2018
c200547
Fix reference to removed null_data_source with local
adrienthebo Oct 5, 2018
c7a5607
Synchronize args_missing logic
aaron-lane Nov 29, 2018
c017a0a
Use gsuite_enabled module in full fixture
aaron-lane Nov 29, 2018
98e6aab
Remove argument check from root, gsuite_enabled
aaron-lane Nov 30, 2018
3f92372
Remove unused locals from gsuite_enabled
aaron-lane Nov 30, 2018
b4f013a
Extract domain calculation logic to module
aaron-lane Nov 30, 2018
cc93cfc
Pass full var.domain to gsuite_enabled
aaron-lane Nov 30, 2018
7cbde2c
Remove argument check from core_project_factory
aaron-lane Nov 30, 2018
cdaff2f
Extract group identity logic to module
aaron-lane Nov 30, 2018
2b866b7
Refactor gsuite_enabled to use google_group
aaron-lane Dec 3, 2018
d38be7d
Ignore VS Code directory
aaron-lane Dec 3, 2018
cd4385d
Generate documentation
aaron-lane Dec 3, 2018
b66ecb8
Ignore pyenv directory
aaron-lane Dec 3, 2018
966a5d0
Print name of file in combine_docfiles.py
aaron-lane Dec 3, 2018
bb6fc1d
Add name generation to google_group
aaron-lane Dec 3, 2018
7f5cf8c
Move G Suite group role to gsuite_enabled
aaron-lane Dec 3, 2018
124bff3
Use google_group.email in gsuite_enabled
aaron-lane Dec 3, 2018
213a2c6
Refactor unnecessary local in gsuite_enabled
aaron-lane Dec 3, 2018
6b1e404
Remove G Suite from minimal fixture
aaron-lane Dec 3, 2018
67cf72c
Remove group_role from core_project_factory
aaron-lane Dec 3, 2018
e96a53f
Grant group serviceAccountUser in gsuite_enabled
aaron-lane Dec 3, 2018
6380d21
Move G Suite networkUser role to gsuite_enabled
aaron-lane Dec 3, 2018
ecbbc22
Move networkUser for VPC subnets to gsuite_enabled
aaron-lane Dec 3, 2018
60e1ad7
Move bucket admin for group to gsuite_enabled
aaron-lane Dec 3, 2018
4325f64
Remove obsolete code from core_project_factory
aaron-lane Dec 3, 2018
b92126c
Update generated documentation
aaron-lane Dec 3, 2018
d1c1c5c
Remove obsolete attributes use in gsuite_enabled
aaron-lane Dec 4, 2018
f7bc912
Fix multiline split of service_account_id
aaron-lane Dec 4, 2018
f675a37
Remove obsolete variables from root module
aaron-lane Dec 4, 2018
7e047c8
Update Read Mes of root, gsuite_enabled
aaron-lane Dec 7, 2018
cde56e0
Remove obsolete reference to group_email
aaron-lane Dec 12, 2018
5a133b3
Update generated documentation
aaron-lane Dec 12, 2018
26ffa95
Inline google_group to gsuite_enabled
aaron-lane Dec 13, 2018
40879df
Add scaffolding for python migration script
adrienthebo Sep 28, 2018
b9705d7
Implement GSuiteMigration class
adrienthebo Sep 29, 2018
97f4fe2
Only migrate resources into core_project_factory
adrienthebo Oct 1, 2018
405d3c8
Add boilerplate to migrate.py and tests
adrienthebo Oct 1, 2018
59f70ac
Prefer arrays over multiline strings for test fixtures
adrienthebo Dec 6, 2018
248bb69
Add test coverage for `Resource.from_path`
adrienthebo Dec 6, 2018
056f47b
Add validation and negative test case for `.from_path`
adrienthebo Dec 6, 2018
dbf879d
Remove extraneous resources and list comprehension filter
adrienthebo Dec 6, 2018
6ce03c7
Improve command hint to use new terraform state
adrienthebo Dec 13, 2018
227e4a5
Improve name of `group_by_module` function
adrienthebo Dec 13, 2018
174fef2
Extract function for computing per-module migration commands
adrienthebo Dec 13, 2018
2ecb092
Refactor migrations to better handle multiple destination modules
adrienthebo Dec 13, 2018
e7bbd27
Migrate resources with a count > 1
adrienthebo Dec 14, 2018
a2ce7ef
Remove obsolete migration script
aaron-lane Dec 17, 2018
bd01441
Update tests to reflect new migrations, clean up assertions
adrienthebo Dec 17, 2018
6bff8ee
Revert order of Read Me sample module arguments
aaron-lane Jan 4, 2019
af21297
Highlight how to include G Sutie in Read Me
aaron-lane Jan 4, 2019
5aebb40
Add group_name, group_role back to root module
aaron-lane Jan 4, 2019
c5f2043
Manage all non G Suite resources in core
aaron-lane Jan 7, 2019
1f37c10
Generate documentation
aaron-lane Jan 7, 2019
7e64a82
Restore G Suite group documentation in root module
aaron-lane Jan 7, 2019
7566ad8
Reimplement arguments check
aaron-lane Jan 7, 2019
c4081ca
Move missing arguments check to gsuite_group
aaron-lane Jan 7, 2019
acfad02
Make var.org_id required
aaron-lane Jan 7, 2019
2bbac4d
Remove reference to obsolete local.gsuite_group_id
aaron-lane Jan 8, 2019
ddeb8f0
Fix descriptions of group_email outputs
aaron-lane Jan 8, 2019
414d71a
Merge pull request #73 from terraform-google-modules/aaron-lane/gsuit…
morgante Jan 8, 2019
e545548
Add gsuite_group_role to migrations
aaron-lane Jan 9, 2019
6f5ffb6
Add service_account_grant_to_group to migrations
aaron-lane Jan 9, 2019
5f5336f
Merge pull request #95 from terraform-google-modules/aaron-lane/fix-m…
morgante Jan 9, 2019
191d9a6
Fix path to migrate.py in upgrade instructions
aaron-lane Jan 10, 2019
9f5daed
Restore migrate.py download instructions
morgante Jan 10, 2019
097860e
Add group_role_to_vpc_subnets to migration
aaron-lane Jan 10, 2019
7acfc29
Add lien to migration
aaron-lane Jan 10, 2019
7542083
Make migration script idempotent
adrienthebo Jan 10, 2019
b31fe64
Merge pull request #99 from terraform-google-modules/aaron-lane/fix-m…
morgante Jan 10, 2019
bb2b842
Merge pull request #100 from terraform-google-modules/adrienthebo/1.0…
morgante Jan 10, 2019
c2a5cd6
Minor updates to migration docs around preconditions and org_id
morgante Jan 11, 2019
4bff404
Add clean up steps
morgante Jan 11, 2019
0258e73
Merge pull request #103 from terraform-google-modules/morgantep/1.0/d…
morgante Jan 11, 2019
4ff2d26
Merge branch 'master' into 1.0-rc1
morgante Jan 11, 2019
f51a2ad
Incorporate changes from #91
morgante Jan 11, 2019
29e3a45
Update CHANGELOG
morgante Jan 11, 2019
ee2357d
Try to fix example
morgante Jan 11, 2019
803892d
Set default group-name
morgante Jan 11, 2019
89c4a13
Merge branch 'master' into 1.0-rc1
morgante Jan 11, 2019
6b2029d
Remove random_string suffix from fixture modules
aaron-lane Jan 14, 2019
3738754
Merge branch 'master' into 1.0-rc1
aaron-lane Jan 14, 2019
ab49539
Merge branch 'master' into 1.0-rc1
morgante Jan 15, 2019
ad6b467
Fix counts which can not be computed
aaron-lane Jan 16, 2019
c786760
Generate documentation
aaron-lane Jan 16, 2019
673f652
Remove interpolation from module source
aaron-lane Jan 16, 2019
6226158
Merge pull request #114 from terraform-google-modules/aaron-lane/fix-…
morgante Jan 16, 2019
50aa1d8
Only manage group if it is existent
aaron-lane Jan 16, 2019
c347a37
Remove redundant boolean logic
aaron-lane Jan 16, 2019
f142904
Merge pull request #115 from terraform-google-modules/aaron-lane/only…
aaron-lane Jan 16, 2019
d061ec4
Merge branch 'master' into 1.0-rc1
morgante Jan 16, 2019
beb050f
Capitalize Changed header in CHANGELOG
aaron-lane Jan 17, 2019
633ffc8
Remove brackets from 1.0.0 header in CHANGELOG
aaron-lane Jan 17, 2019
383b5cb
Pin module to 1.0 in README example
aaron-lane Jan 17, 2019
ae652cb
Target v1.0.0 in migration script download
aaron-lane Jan 17, 2019
574ca00
Pin gsuite_enabled module to 1.0 in README
aaron-lane Jan 17, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ terraform.tfstate.d/
credentials.json
.vscode/
env/
test/fixtures/shared/terraform.tfvars
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ platforms:

verifier:
name: terraform
color: false
systems:
- name: system
backend: local
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.3
63 changes: 25 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@
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.19.1
BUILD_PROVIDER_GSUITE_VERSION ?= 0.1.10
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}

CREDENTIALS_PATH ?= /cft/workdir/credentials.json
DOCKER_ORG := gcr.io/cloud-foundation-cicd
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.10_216.0.0_1.19.1_0.1.10
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}

all: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace generate_docs ## Run all linters and update documentation

Expand All @@ -46,7 +40,7 @@ check_golang: ## Lint Go source files

.PHONY: check_terraform
check_terraform:
@source ## Lint Terraform source files
@source test/make.sh && check_terraform ## Lint Terraform source files

.PHONY: check_docker
check_docker: ## Lint Dockerfiles
Expand Down Expand Up @@ -92,57 +86,50 @@ generate_docs: ## Update README documentation for Terraform variables and output
release-new-version:
@source helpers/release-new-version.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: ## Launch a shell within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash

.PHONY: docker_create
docker_create: ## Run `kitchen create` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen create"

.PHONY: docker_converge
docker_converge: ## Run `kitchen converge` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen converge && bundle exec kitchen converge"

.PHONY: docker_verify
docker_verify: ## Run `kitchen verify` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen verify"

.PHONY: docker_destroy
docker_destroy: ## Run `kitchen destroy` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen destroy"

.PHONY: test_integration_docker
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ The project has the following folders and files:

- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [terraform-provider-google] plugin 1.19.x
- [terraform-provider-google-beta] plugin 1.19.x
- [terraform-provider-gsuite] plugin 0.1.x if GSuite functionality is desired

### Permissions
Expand Down Expand Up @@ -326,13 +327,12 @@ test steps non-interactively.
#### Test configuration

Each test-kitchen instance is configured with a `terraform.tfvars` file in the
test fixture directory.
test fixture directory. For convenience, these are symlinked to a single shared file:

```sh
for instance in full minimal; do
cp "test/fixtures/$instance/terraform.tfvars.example" \
"test/fixtures/$instance/terraform.tfvars"
$EDITOR "test/fixtures/$instance/terraform.tfvars"
cp "test/fixtures/shared/terraform.tfvars.example" \
"test/fixtures/shared/terraform.tfvars"
$EDITOR "test/fixtures/shared/terraform.tfvars"
done
```

Expand Down Expand Up @@ -397,6 +397,7 @@ versions][release-new-version].

[gsuite-enabled-module]: modules/gsuite_enabled/README.md
[terraform-provider-google]: https://github.com/terraform-providers/terraform-provider-google
[terraform-provider-google-beta]: https://github.com/terraform-providers/terraform-provider-google-beta
[terraform-provider-gsuite]: https://github.com/DeviaVir/terraform-provider-gsuite
[glossary]: /docs/GLOSSARY.md
[release-new-version]: https://www.terraform.io/docs/registry/modules/publish.html#releasing-new-versions
[release-new-version]: https://www.terraform.io/docs/registry/modules/publish.html#releasing-new-versions
61 changes: 0 additions & 61 deletions build/docker/kitchen_terraform/Dockerfile

This file was deleted.

102 changes: 0 additions & 102 deletions build/docker/terraform/Dockerfile

This file was deleted.

34 changes: 33 additions & 1 deletion docs/upgrading_to_project_factory_v1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ index d876954..ebb3b1e 100755
org_id = "${var.org_id}"
```

Additionally, `org_id` is now required so you will need to add
it as an argument if you didn't already specify it on your projects.

### Download the state migration script

```
Expand Down Expand Up @@ -154,7 +157,8 @@ terraform plan -state terraform.tfstate.new

The G Suite refactor adds an additional IAM membership and needs to re-create
two resources, due to how resources were split up between the `gsuite_enabled`
and `core_project_factory` modules.
and `core_project_factory` modules. Depending on the version
you are upgrading from, it might also add a `null_resource` for `preconditions` checks.

```txt

Expand Down Expand Up @@ -260,6 +264,20 @@ After restoring remote state, you need to re-initialize Terraform and push your
terraform init -force-copy
```

### Clean up

Once you are done with the migration, you can safely remove `migrate.py`.

```
rm migrate.py
```

If you are using remote state, you can also remove the local state copies.

```
rm -rf terraform.tfstate*
```

## Troubleshooting

### Errors about invalid arguments
Expand All @@ -275,6 +293,20 @@ Error: module "project-pfactory-development": "create_group" is not a valid argu
These are related to projects which depend on G Suite functionality.
Make sure to update the source of such projects to point to the [G Suite module](../modules/gsuite_enabled)

### Missing `org_id`

If your existing configuration doesn't specify the `org_id`,
you might see some errors on upgrade:

```
Initializing the backend...

Error: module "project_factory": missing required argument "org_id"
```

The fix for this is to explicitly set the `org_id` argument
on your projects.

### The migration script fails to run

If you get an error like this when running the migration script, it means you need upgrade
Expand Down
5 changes: 5 additions & 0 deletions examples/gke_shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ provider "google" {
version = "~> 1.19"
}

provider "google-beta" {
credentials = "${file(local.credentials_file_path)}"
version = "~> 1.19"
}

module "project-factory" {
source = "../../"
random_project_id = "true"
Expand Down
Loading