Skip to content

Add Cloud Build for GCP CI env #58

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

Merged
merged 11 commits into from
Nov 22, 2024

Conversation

roger2hk
Copy link
Contributor

Towards #53

@roger2hk roger2hk marked this pull request as ready for review November 21, 2024 21:12
@roger2hk roger2hk requested review from phbnf and AlCutter November 21, 2024 21:12
locals {
env = path_relative_to_include()
project_id = get_env("GOOGLE_PROJECT", "transparency-dev")
location = get_env("GOOGLE_REGION", "us-central1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nit, region to align with tessera repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the location cannot be changed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that this local / variable is called "region" instead of "location" in the tessera repo, we might as well use the same. I think that one spanner label also have a different name. Nothing too important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. They seem to be interchangeable. Most terraform resources use location as the arguments.

@roger2hk roger2hk requested a review from phbnf November 22, 2024 16:32
Comment on lines +41 to +71
resource "google_service_account" "cloudbuild_service_account" {
account_id = "cloudbuild-${var.env}-sa"
display_name = "Service Account for Cloud Build (${var.env})"
}

resource "google_project_iam_member" "logging_log_writer" {
project = var.project_id
role = "roles/logging.logWriter"
member = "serviceAccount:${google_service_account.cloudbuild_service_account.email}"
}

resource "google_artifact_registry_repository_iam_member" "artifactregistry_writer" {
project = google_artifact_registry_repository.docker.project
location = google_artifact_registry_repository.docker.location
repository = google_artifact_registry_repository.docker.name
role = "roles/artifactregistry.writer"
member = "serviceAccount:${google_service_account.cloudbuild_service_account.email}"
}

# TODO: Use google_cloud_run_service_iam_member to limit the service scope.
resource "google_project_iam_member" "run_developer" {
project = var.project_id
role = "roles/run.developer"
member = "serviceAccount:${google_service_account.cloudbuild_service_account.email}"
}

resource "google_project_iam_member" "iam_service_account_user" {
project = var.project_id
role = "roles/iam.serviceAccountUser"
member = "serviceAccount:${google_service_account.cloudbuild_service_account.email}"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this all defined in overground, no need to define this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're useful when setting up the cloud build in other GCP projects. I'm inclined to keep these. Perhaps we can use conditional IAM resources creation or provide the terraform import command.

Comment on lines +22 to +27
resource "google_project_iam_member" "run_service_agent" {
project = var.project_id
role = "roles/run.serviceAgent"
member = "serviceAccount:${google_service_account.cloudrun_service_account.email}"
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, and for the other membership below actually (I had missed this in a previous PR). I don't think they should live here, but in Overground rather. Then, terraform can add biding to the GCS and Spanner resources for the right users to have the right roles on these resources. Let's clean that all up in a followup PR?

Or one could argue that we want to leave them around for transparency and to show to the world what's our IAM structure, at the cost of having two sources for this... TBD speaking with the team I'd say.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's talk about this with the team.

locals {
env = path_relative_to_include()
project_id = get_env("GOOGLE_PROJECT", "transparency-dev")
location = get_env("GOOGLE_REGION", "us-central1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that this local / variable is called "region" instead of "location" in the tessera repo, we might as well use the same. I think that one spanner label also have a different name. Nothing too important.

@roger2hk roger2hk merged commit 214f5b1 into transparency-dev:main Nov 22, 2024
7 checks passed
@roger2hk roger2hk deleted the gcp-cloudbuild branch November 22, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants