-
Notifications
You must be signed in to change notification settings - Fork 0
ci: publish busybox binaries to GCS public builds bucket #1
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8057ec6
ci: publish busybox binaries to GCS public builds bucket
tomassrnka ca4a1d4
fix: include version in GCS upload path
tomassrnka 47063d4
fix: upgrade Google actions to v3 and prevent GCS failure from blocki…
tomassrnka ca64b47
fix: upload SHA256 sidecar alongside busybox binary in GCS
tomassrnka fe8115f
infra: add Terraform for WIF, service account, and GitHub secrets
tomassrnka b3d6488
fix: remove unused random provider from Terraform
tomassrnka dc8070c
chore: terraform
jakubno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,3 @@ | ||
| .env | ||
| .tfplan | ||
| .terraform |
This file contains hidden or 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,2 @@ | ||
| GCP_PROJECT_ID= | ||
| PREFIX= |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| -include .env | ||
|
|
||
| TERRAFORM_STATE_BUCKET ?= $(GCP_PROJECT_ID)-terraform-state | ||
|
|
||
| tf_vars := TF_VAR_gcp_project_id=$(GCP_PROJECT_ID) \ | ||
| TF_VAR_prefix=$(PREFIX) | ||
|
|
||
|
|
||
| .PHONY: init | ||
| init: | ||
| @ printf "Initializing Terraform\n\n" | ||
| terraform init -reconfigure -input=false -backend-config="bucket=${TERRAFORM_STATE_BUCKET}" | ||
|
|
||
| .PHONY: plan | ||
| plan: | ||
| @ printf "Planning Terraform\n\n" | ||
| terraform fmt -recursive | ||
| $(tf_vars) terraform plan -out=.tfplan -compact-warnings -detailed-exitcode | ||
|
|
||
| .PHONY: apply | ||
| apply: | ||
| @ printf "Applying Terraform\n\n" | ||
| $(tf_vars) \ | ||
| terraform apply \ | ||
| -auto-approve \ | ||
| -input=false \ | ||
| -compact-warnings \ | ||
| -parallelism=20 \ | ||
| .tfplan | ||
| @ rm .tfplan |
This file contains hidden or 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,91 @@ | ||
| terraform { | ||
| required_version = ">= 1.5.0, < 1.6.0" | ||
| backend "gcs" { | ||
| prefix = "terraform/fc-busybox-github/state" | ||
| } | ||
| required_providers { | ||
| google = { | ||
| source = "hashicorp/google" | ||
| version = "5.6.0" | ||
| } | ||
| github = { | ||
| source = "integrations/github" | ||
| version = "5.42.0" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "google" { | ||
| project = var.gcp_project_id | ||
| } | ||
|
|
||
| data "google_project" "gcp_project" {} | ||
|
|
||
| // Workload Identity Federation for GitHub Actions | ||
| resource "google_iam_workload_identity_pool" "github_actions_deployment" { | ||
| workload_identity_pool_id = "${var.prefix}gha-fc-busybox" | ||
| display_name = "GHA for ${var.github_repository} FC BusyBox" | ||
| description = "OIDC identity pool for build FC BusyBox ${var.github_repository} via GitHub Actions" | ||
| } | ||
|
|
||
| resource "google_iam_workload_identity_pool_provider" "gha_identity_pool_provider" { | ||
| workload_identity_pool_id = google_iam_workload_identity_pool.github_actions_deployment.workload_identity_pool_id | ||
| workload_identity_pool_provider_id = "${var.prefix}gh-provider" | ||
| display_name = "E2B GHA identity pool provider" | ||
| attribute_mapping = { | ||
| "google.subject" = "assertion.sub" | ||
| "attribute.actor" = "assertion.actor" | ||
| "attribute.repository" = "assertion.repository" | ||
| "attribute.repository_owner" = "assertion.repository_owner" | ||
| } | ||
| attribute_condition = "assertion.repository == \"${var.github_organization}/${var.github_repository}\"" | ||
|
|
||
| oidc { | ||
| issuer_uri = "https://token.actions.githubusercontent.com" | ||
| } | ||
| } | ||
|
|
||
| resource "google_service_account" "fc_busybox" { | ||
| account_id = "${var.prefix}fc-busybox" | ||
| display_name = "Service account for ${var.github_repository} FC BusyBox" | ||
| } | ||
|
|
||
| resource "google_storage_bucket_iam_member" "fc_busybox_bucket_iam" { | ||
| bucket = var.gcs_bucket_name | ||
| role = "roles/storage.objectUser" | ||
| member = "serviceAccount:${google_service_account.fc_busybox.email}" | ||
| } | ||
|
|
||
| resource "google_service_account_iam_member" "gha_service_account_wif_tokencreator_iam_member" { | ||
| service_account_id = google_service_account.fc_busybox.name | ||
| role = "roles/iam.workloadIdentityUser" | ||
| member = "principalSet://iam.googleapis.com/projects/${data.google_project.gcp_project.number}/locations/global/workloadIdentityPools/${google_iam_workload_identity_pool.github_actions_deployment.workload_identity_pool_id}/attribute.repository/${var.github_organization}/${var.github_repository}" | ||
| } | ||
|
|
||
| // GitHub secrets and variables | ||
| data "google_secret_manager_secret_version" "github_token" { | ||
| secret = "${var.prefix}github-repo-token" | ||
| } | ||
|
|
||
| provider "github" { | ||
| owner = var.github_organization | ||
| token = data.google_secret_manager_secret_version.github_token.secret_data | ||
| } | ||
|
|
||
| resource "github_actions_secret" "workload_identity_provider_secret" { | ||
| repository = var.github_repository | ||
| secret_name = "GCP_WORKLOAD_IDENTITY_PROVIDER" | ||
| plaintext_value = "projects/${data.google_project.gcp_project.number}/locations/global/workloadIdentityPools/${google_iam_workload_identity_pool.github_actions_deployment.workload_identity_pool_id}/providers/${google_iam_workload_identity_pool_provider.gha_identity_pool_provider.workload_identity_pool_provider_id}" | ||
| } | ||
|
|
||
| resource "github_actions_secret" "service_account_email_secret" { | ||
| repository = var.github_repository | ||
| secret_name = "GCP_SERVICE_ACCOUNT_EMAIL" | ||
| plaintext_value = google_service_account.fc_busybox.email | ||
| } | ||
|
|
||
| resource "github_actions_variable" "gcs_bucket_name" { | ||
| repository = var.github_repository | ||
| value = var.gcs_bucket_name | ||
| variable_name = "GCP_BUCKET_NAME" | ||
| } |
This file contains hidden or 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,25 @@ | ||
| variable "github_organization" { | ||
| type = string | ||
| default = "e2b-dev" | ||
| } | ||
|
|
||
| variable "github_repository" { | ||
| type = string | ||
| default = "fc-busybox" | ||
| } | ||
|
|
||
| variable "gcp_project_id" { | ||
| description = "The project to deploy the cluster in" | ||
| type = string | ||
| } | ||
|
|
||
| variable "prefix" { | ||
| description = "The prefix to use for all resources in this module" | ||
| type = string | ||
| } | ||
|
|
||
| variable "gcs_bucket_name" { | ||
| description = "The name of the GCS bucket to store the busybox binaries" | ||
| type = string | ||
| default = "e2b-prod-public-builds" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.