Skip to content

Commit

Permalink
UPDATE
Browse files Browse the repository at this point in the history
  • Loading branch information
mazzasaverio committed Feb 5, 2024
1 parent 98bc9af commit 1808dc9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
35 changes: 35 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,45 @@ resource "google_project_service" "enabled_services" {



# IAM role assignments for an existing service account
resource "google_project_iam_member" "existing_service_account_iam_roles" {
for_each = toset(var.gcp_existing_service_account_roles)
project = var.gcp_project_id
role = "roles/${each.value}"
member = "serviceAccount:${data.google_service_account.existing_service_account.email}"
}

# IAM role assignments for Cloud Build service account with specific roles
resource "google_project_iam_member" "cloud_build_service_account_iam_roles" {
for_each = toset(var.gcp_cloud_build_service_account_roles)
project = var.gcp_project_id
role = "roles/${each.value}"
member = "serviceAccount:${var.gcp_project_number}@cloudbuild.gserviceaccount.com"
}





module "secret_manager" {
source = "./modules/secret_manager"
github_token = var.github_token
}



module "cloud_build" {
source = "./modules/cloud_build"
gcp_project_id = var.gcp_project_id
gcp_project_number = var.gcp_project_number
repo_name = var.repo_name
branch = var.branch
github_gcp_installation_id = var.github_gcp_installation_id
gcp_region = var.gcp_region
github_remote_uri = var.github_remote_uri

depends_on = [

module.secret_manager
]
}
6 changes: 0 additions & 6 deletions terraform/modules/cloud_build/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ variable "gcp_project_number" {
}




variable "repo_name" {
description = "The name of the repository to create the trigger for the Cloud Build."
type = string
Expand All @@ -38,7 +36,3 @@ variable "github_remote_uri" {
description = "The GitHub remote URI."
type = string
}
# variable "github_token_secret_version_id" {
# description = "ID of the secret version containing the GitHub token"
# type = string
# }
2 changes: 1 addition & 1 deletion terraform/modules/secret_manager/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* ----------------------------- GITHUB ACCOUNT ----------------------------- */

resource "google_secret_manager_secret" "github_token_secret" {
secret_id = "github-token-secret"
secret_id = "github-token-secret-2"
replication {
auto {}
}
Expand Down
2 changes: 0 additions & 2 deletions terraform/variabiles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ variable "repo_name" {
type = string
}



variable "branch" {
description = "The branch of the repository to create the trigger for the Cloud Build."
type = string
Expand Down

0 comments on commit 1808dc9

Please sign in to comment.