Skip to content

Commit 10631b2

Browse files
Android Build Filesystem (ABFS) Teamsce-taid
authored andcommitted
feat: introduce new GCS and Spanner backends
Please apply the spanner database schema via `gcloud --project [PROJECT_ID] spanner databases ddl update --instance abfs abfs --ddl-file ../../files/schemas/0.0.31-schema.sql` once `terraform apply` is finished. The final command can be seen in the outputs. PiperOrigin-RevId: 773700345
1 parent c35bf6d commit 10631b2

28 files changed

+298
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This module is divided into two distinct submodules which creates the following:
2626
Systemd config and scripts are created on the VM by the built-in cloud-init
2727
tool, which pulls a cloud-init config file from the metatdata server.
2828

29-
The cloud-init config is generated in the server's [main.tf](./modules/server/main.tf) and the uploaders [main.tf](./modules/uploaders/main.tf) and is assembled from this [systemd configuration](./cloud-init) and [associated bash scripts](./cloud-init/scripts).
29+
The cloud-init config is generated in the server's [main.tf](./modules/server/main.tf) and the uploaders [main.tf](./modules/uploaders/main.tf) and is assembled from this [systemd configuration](./files/cloud-init) and [associated bash scripts](./files/cloud-init/scripts).
3030

3131
Systemd is highly configurable and parallelized to allow for optimal and rapid VM
3232
startup. The visualization below shows the order and dependencies of the relevant

examples/simple/iam.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ module "project-iam-bindings" {
2323

2424
projects = [data.google_project.project.project_id]
2525
mode = "authoritative"
26+
2627
bindings = {
2728
"roles/artifactregistry.reader" = [data.google_service_account.abfs.member],
2829
"roles/logging.logWriter" = [data.google_service_account.abfs.member],
2930
"roles/monitoring.metricWriter" = [data.google_service_account.abfs.member],
3031
"roles/monitoring.viewer" = [data.google_service_account.abfs.member],
32+
"roles/spanner.databaseUser" = [data.google_service_account.abfs.member],
3133
"roles/stackdriver.resourceMetadata.writer" = [data.google_service_account.abfs.member],
34+
"roles/storage.objectAdmin" = [data.google_service_account.abfs.member],
3235
}
3336

3437
depends_on = [

examples/simple/main.tf

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,33 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
module "abfs-deployment" {
15+
moved {
16+
from = module.abfs-deployment
17+
to = module.abfs_server
18+
}
19+
20+
moved {
21+
from = module.abfs-uploaders
22+
to = module.abfs_uploaders
23+
}
24+
25+
module "abfs_server" {
1626
source = "../../modules/server"
1727

18-
project_id = var.project_id
19-
zone = var.zone
20-
service_account_email = data.google_service_account.abfs.email
21-
subnetwork = module.abfs-vpc.subnets["${var.region}/abfs-subnet"].name
22-
abfs_docker_image_uri = var.abfs_docker_image_uri
23-
abfs_license = var.abfs_license
28+
project_id = data.google_project.project.project_id
29+
zone = var.zone
30+
service_account_email = data.google_service_account.abfs.email
31+
subnetwork = module.abfs-vpc.subnets["${var.region}/abfs-subnet"].name
32+
abfs_docker_image_uri = var.abfs_docker_image_uri
33+
abfs_license = var.abfs_license
34+
abfs_bucket_location = var.abfs_bucket_location
35+
abfs_spanner_instance_config = var.abfs_spanner_instance_config
2436
}
2537

26-
module "abfs-uploaders" {
38+
module "abfs_uploaders" {
2739
source = "../../modules/uploaders"
2840

29-
project_id = var.project_id
41+
project_id = data.google_project.project.project_id
3042
zone = var.zone
3143
service_account_email = data.google_service_account.abfs.email
3244
subnetwork = module.abfs-vpc.subnets["${var.region}/abfs-subnet"].name
@@ -36,7 +48,7 @@ module "abfs-uploaders" {
3648
abfs_manifest_project_name = var.abfs_manifest_project_name
3749
abfs_manifest_file = var.abfs_manifest_file
3850
abfs_license = var.abfs_license
39-
abfs_server_name = module.abfs-deployment.abfs_server_name
51+
abfs_server_name = module.abfs_server.abfs_server_name
4052
}
4153

4254
module "monitoring" {

examples/simple/network.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "abfs-vpc" {
1919
project_id = data.google_project.project.project_id
2020
network_name = "abfs-network"
2121
routing_mode = "GLOBAL"
22+
2223
firewall_rules = [
2324
{
2425
description = "Allow egress to Google APIs via Private Google Access"
@@ -76,6 +77,7 @@ module "abfs-vpc" {
7677
]
7778
}
7879
]
80+
7981
subnets = [
8082
{
8183
subnet_name = "abfs-subnet"

examples/simple/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ output "license_information" {
2020
service_account_unique_id = data.google_service_account.abfs.unique_id
2121
}
2222
}
23+
24+
output "spanner_database_schema_creation" {
25+
description = "The CLI command for creating the Spanner database schema"
26+
value = "gcloud --project ${data.google_project.project.project_id} spanner databases ddl update --instance ${module.abfs_server.abfs_spanner_instance.name} ${module.abfs_server.abfs_spanner_database.name} --ddl-file ${path.module}/../../files/schemas/0.0.31-schema.sql"
27+
}

examples/simple/services.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ module "project-services" {
3232
activate_apis = [
3333
"compute.googleapis.com",
3434
"dns.googleapis.com",
35-
"monitoring.googleapis.com"
35+
"monitoring.googleapis.com",
36+
"spanner.googleapis.com",
3637
]
3738

3839
depends_on = [

examples/simple/variables.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ variable "zone" {
2929

3030
variable "abfs_docker_image_uri" {
3131
type = string
32-
description = "Docker image URI for main ABFS server"
32+
description = "Docker image URI for ABFS"
3333
}
3434

3535
variable "abfs_gerrit_uploader_git_branch" {
@@ -70,3 +70,13 @@ variable "abfs_service_account_id" {
7070
type = string
7171
description = "ABFS service account ID (e.g. abfs@<project-id>.iam.gserviceaccount.com)"
7272
}
73+
74+
variable "abfs_bucket_location" {
75+
type = string
76+
description = "The location of the ABFS bucket (https://cloud.google.com/storage/docs/locations)."
77+
}
78+
79+
variable "abfs_spanner_instance_config" {
80+
type = string
81+
description = "The name of the instance's configuration (similar but not quite the same as a region) which defines the geographic placement and replication of your ABFS database in this instance (https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/spanner_instance.html#config-1)."
82+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)