-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: option to target bootstrap module at a folder (#40)
- Loading branch information
1 parent
0e06b29
commit fa923a5
Showing
17 changed files
with
493 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,11 @@ steps: | |
- id: verify-simple | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-default'] | ||
- id: destroy-simple | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-default'] | ||
# Required to rerun to reinstate ci-integration account as project creator as not member of group_org_admins. | ||
- id: prepare-rerun | ||
- id: prepare-rerun-cloudbuild-enabled | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment'] | ||
env: | ||
|
@@ -48,9 +51,28 @@ steps: | |
- id: verify-cloudbuild-enabled | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify cloudbuild-enabled-default'] | ||
- id: destroy | ||
- id: destroy-cloudbuild-enabled | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy cloudbuild-enabled-default'] | ||
# Required to rerun to reinstate ci-integration account as project creator as not member of group_org_admins. | ||
- id: prepare-rerun-simple-folder | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment'] | ||
env: | ||
- 'TF_VAR_org_id=$_ORG_ID' | ||
- 'TF_VAR_folder_id=$_FOLDER_ID' | ||
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT' | ||
- '[email protected]' | ||
- 'TF_VAR_group_billing_admins=test-gcp-billing-admins@test.infra.cft.tips' | ||
- id: converge-simple-folder | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-folder-default'] | ||
- id: verify-simple-folder | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-folder-default'] | ||
- id: destroy-simple-folder | ||
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy'] | ||
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-folder-default'] | ||
tags: | ||
- 'ci' | ||
- 'integration' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Overview | ||
|
||
This example demonstrates the simplest usage of the GCP organization bootstrap module targeting a folder. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| billing\_account | The ID of the billing account to associate projects with. | string | n/a | yes | | ||
| default\_region | Default region to create resources where applicable. | string | `"us-central1"` | no | | ||
| group\_billing\_admins | Google Group for GCP Billing Administrators | string | n/a | yes | | ||
| group\_org\_admins | Google Group for GCP Organization Administrators | string | n/a | yes | | ||
| org\_id | GCP Organization ID | string | n/a | yes | | ||
| org\_project\_creators | Additional list of members to have project creator role accross the organization. Prefix of group: user: or serviceAccount: is required. | list(string) | `<list>` | no | | ||
| parent | GCP parent folder id of form folders/{id} | string | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| gcs\_bucket\_tfstate | Bucket used for storing terraform state for foundations pipelines in seed project. | | ||
| seed\_project\_id | Project where service accounts and core APIs will be enabled. | | ||
| terraform\_sa\_email | Email for privileged service account for Terraform. | | ||
| terraform\_sa\_name | Fully qualified name for privileged service account for Terraform. | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright 2019 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. | ||
*/ | ||
|
||
provider "google" { | ||
version = "~> 3.5.0" | ||
} | ||
|
||
provider "google-beta" { | ||
version = "~> 3.5.0" | ||
} | ||
|
||
provider "null" { | ||
version = "~> 2.1" | ||
} | ||
|
||
provider "random" { | ||
version = "~> 2.2" | ||
} | ||
|
||
/************************************************* | ||
Bootstrap GCP Folder. | ||
*************************************************/ | ||
|
||
module "seed_bootstrap" { | ||
source = "../.." | ||
org_id = var.org_id | ||
parent_folder = var.parent | ||
billing_account = var.billing_account | ||
group_org_admins = var.group_org_admins | ||
group_billing_admins = var.group_billing_admins | ||
default_region = var.default_region | ||
org_project_creators = var.org_project_creators | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright 2019 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. | ||
*/ | ||
|
||
output "seed_project_id" { | ||
description = "Project where service accounts and core APIs will be enabled." | ||
value = module.seed_bootstrap.seed_project_id | ||
} | ||
|
||
output "terraform_sa_email" { | ||
description = "Email for privileged service account for Terraform." | ||
value = module.seed_bootstrap.terraform_sa_email | ||
} | ||
|
||
output "terraform_sa_name" { | ||
description = "Fully qualified name for privileged service account for Terraform." | ||
value = module.seed_bootstrap.terraform_sa_name | ||
} | ||
|
||
output "gcs_bucket_tfstate" { | ||
description = "Bucket used for storing terraform state for foundations pipelines in seed project." | ||
value = module.seed_bootstrap.gcs_bucket_tfstate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2019 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. | ||
*/ | ||
|
||
variable "org_id" { | ||
description = "GCP Organization ID" | ||
type = string | ||
} | ||
|
||
variable "parent" { | ||
description = "GCP parent folder id of form folders/{id}" | ||
type = string | ||
} | ||
|
||
variable "billing_account" { | ||
description = "The ID of the billing account to associate projects with." | ||
type = string | ||
} | ||
|
||
variable "group_org_admins" { | ||
description = "Google Group for GCP Organization Administrators" | ||
type = string | ||
} | ||
|
||
variable "group_billing_admins" { | ||
description = "Google Group for GCP Billing Administrators" | ||
type = string | ||
} | ||
|
||
variable "default_region" { | ||
description = "Default region to create resources where applicable." | ||
type = string | ||
default = "us-central1" | ||
} | ||
|
||
variable "org_project_creators" { | ||
description = "Additional list of members to have project creator role accross the organization. Prefix of group: user: or serviceAccount: is required." | ||
type = list(string) | ||
default = [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
module "simple" { | ||
source = "../../../examples/simple-folder" | ||
|
||
org_id = var.org_id | ||
parent = var.parent_folder | ||
billing_account = var.billing_account | ||
group_org_admins = var.group_org_admins | ||
group_billing_admins = var.group_billing_admins | ||
default_region = var.default_region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
output "seed_project_id" { | ||
description = "Project where service accounts and core APIs will be enabled." | ||
value = module.simple.seed_project_id | ||
} | ||
|
||
output "terraform_sa_email" { | ||
description = "Email for privileged service account for Terraform." | ||
value = module.simple.terraform_sa_email | ||
} | ||
|
||
output "terraform_sa_name" { | ||
description = "Fully qualified name for privileged service account for Terraform." | ||
value = module.simple.terraform_sa_name | ||
} | ||
|
||
output "gcs_bucket_tfstate" { | ||
description = "Bucket used for storing terraform state for foundations pipelines in seed project." | ||
value = module.simple.gcs_bucket_tfstate | ||
} | ||
|
||
output "parent_folder" { | ||
description = "Parent folder" | ||
value = var.parent_folder | ||
} | ||
|
||
output "org_id" { | ||
description = "Org id" | ||
value = var.org_id | ||
} |
Oops, something went wrong.