-
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: Add GitLab support for IM module (#281)
- Loading branch information
1 parent
7fb8b70
commit a9858a9
Showing
23 changed files
with
883 additions
and
70 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Overview | ||
|
||
This example demonstrates the simplest usage of the [im_cloudbuild_workspace](../../modules/im_cloudbuild_workspace/) module. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| im\_gitlab\_pat | GitLab personal access token. | `string` | n/a | yes | | ||
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes | | ||
| repository\_url | The URI of the repo where the Terraform configs are stored. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| cloudbuild\_apply\_trigger\_id | Trigger used for running IM apply | | ||
| cloudbuild\_preview\_trigger\_id | Trigger used for creating IM previews | | ||
| cloudbuild\_sa | Service account used by the Cloud Build triggers | | ||
| gitlab\_api\_secret\_id | The secret ID for the secret containing the GitLab api access token. | | ||
| gitlab\_read\_api\_secret\_id | The secret ID for the secret containing the GitLab read api access token. | | ||
| infra\_manager\_sa | Service account used by Infrastructure Manager | | ||
| project\_id | n/a | | ||
|
||
<!-- 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,30 @@ | ||
/** | ||
* Copyright 2024 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 "enabled_google_apis" { | ||
source = "terraform-google-modules/project-factory/google//modules/project_services" | ||
version = "~> 14.0" | ||
|
||
project_id = var.project_id | ||
disable_services_on_destroy = false | ||
|
||
activate_apis = [ | ||
"iam.googleapis.com", | ||
"compute.googleapis.com", | ||
"cloudbuild.googleapis.com", | ||
"config.googleapis.com", | ||
] | ||
} |
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,32 @@ | ||
/** | ||
* Copyright 2024 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 "im_workspace" { | ||
source = "../../modules/im_cloudbuild_workspace" | ||
|
||
project_id = var.project_id | ||
deployment_id = "im-example-gitlab-deployment" | ||
|
||
tf_repo_type = "GITLAB" | ||
im_deployment_repo_uri = var.repository_url | ||
im_deployment_ref = "main" | ||
im_tf_variables = "project_id=${var.project_id}" | ||
infra_manager_sa_roles = ["roles/compute.networkAdmin"] | ||
tf_version = "1.2.3" | ||
|
||
gitlab_api_access_token = var.im_gitlab_pat | ||
gitlab_read_api_access_token = var.im_gitlab_pat | ||
} |
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,51 @@ | ||
/** | ||
* Copyright 2024 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 "project_id" { | ||
value = var.project_id | ||
} | ||
|
||
output "cloudbuild_preview_trigger_id" { | ||
description = "Trigger used for creating IM previews" | ||
value = module.im_workspace.cloudbuild_preview_trigger_id | ||
} | ||
|
||
output "cloudbuild_apply_trigger_id" { | ||
description = "Trigger used for running IM apply" | ||
value = module.im_workspace.cloudbuild_apply_trigger_id | ||
} | ||
|
||
output "cloudbuild_sa" { | ||
description = "Service account used by the Cloud Build triggers" | ||
value = module.im_workspace.cloudbuild_sa | ||
} | ||
|
||
output "infra_manager_sa" { | ||
description = "Service account used by Infrastructure Manager" | ||
value = module.im_workspace.infra_manager_sa | ||
} | ||
|
||
output "gitlab_api_secret_id" { | ||
description = "The secret ID for the secret containing the GitLab api access token." | ||
value = module.im_workspace.gitlab_api_secret_id | ||
sensitive = true | ||
} | ||
|
||
output "gitlab_read_api_secret_id" { | ||
description = "The secret ID for the secret containing the GitLab read api access token." | ||
value = module.im_workspace.gitlab_read_api_secret_id | ||
sensitive = true | ||
} |
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,31 @@ | ||
/** | ||
* Copyright 2024 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 "project_id" { | ||
description = "The ID of the project in which to provision resources." | ||
type = string | ||
} | ||
|
||
variable "repository_url" { | ||
description = "The URI of the repo where the Terraform configs are stored." | ||
type = string | ||
} | ||
|
||
variable "im_gitlab_pat" { | ||
description = "GitLab personal access token." | ||
type = string | ||
sensitive = true | ||
} |
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
Oops, something went wrong.