Skip to content

Commit c35bf6d

Browse files
Android Build Filesystem (ABFS) Teamsce-taid
authored andcommitted
No public description
PiperOrigin-RevId: 773613379
1 parent d281628 commit c35bf6d

File tree

7 files changed

+160
-24
lines changed

7 files changed

+160
-24
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
crash.*.log
11+
12+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
13+
# password, private keys, and other secrets. These should not be part of version
14+
# control as they are data points which are potentially sensitive and subject
15+
# to change depending on the environment.
16+
*.tfvars
17+
*.tfvars.json
18+
19+
# Ignore override files as they are usually used to override resources locally and so
20+
# are not checked in
21+
override.tf
22+
override.tf.json
23+
*_override.tf
24+
*_override.tf.json
25+
26+
# Ignore transient lock info files created by terraform apply
27+
.terraform.tfstate.lock.info
28+
29+
# Include override files you do wish to add to version control using negated pattern
30+
# !example_override.tf
31+
32+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
33+
# example: *tfplan*
34+
35+
# Ignore CLI configuration files
36+
.terraformrc
37+
terraform.rc

examples/simple/.terraform.lock.hcl

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/simple/iam.tf

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

15-
resource "google_service_account" "abfs_server" {
16-
project = data.google_project.project.project_id
17-
account_id = "abfs-server"
18-
display_name = "SA for ABFS server VMs"
15+
data "google_service_account" "abfs" {
16+
project = data.google_project.project.project_id
17+
account_id = var.abfs_service_account_id
1918
}
2019

2120
module "project-iam-bindings" {
22-
source = "terraform-google-modules/iam/google//modules/projects_iam"
23-
version = "8.1.0"
21+
source = "terraform-google-modules/iam/google//modules/projects_iam"
22+
version = "8.1.0"
23+
2424
projects = [data.google_project.project.project_id]
2525
mode = "authoritative"
26-
2726
bindings = {
28-
"roles/logging.logWriter" = ["serviceAccount:${google_service_account.abfs_server.email}"],
29-
"roles/monitoring.metricWriter" = ["serviceAccount:${google_service_account.abfs_server.email}"],
30-
"roles/monitoring.viewer" = ["serviceAccount:${google_service_account.abfs_server.email}"],
31-
"roles/stackdriver.resourceMetadata.writer" = ["serviceAccount:${google_service_account.abfs_server.email}"],
32-
"roles/artifactregistry.reader" = ["serviceAccount:${google_service_account.abfs_server.email}"]
27+
"roles/artifactregistry.reader" = [data.google_service_account.abfs.member],
28+
"roles/logging.logWriter" = [data.google_service_account.abfs.member],
29+
"roles/monitoring.metricWriter" = [data.google_service_account.abfs.member],
30+
"roles/monitoring.viewer" = [data.google_service_account.abfs.member],
31+
"roles/stackdriver.resourceMetadata.writer" = [data.google_service_account.abfs.member],
3332
}
3433

3534
depends_on = [

examples/simple/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module "abfs-deployment" {
1717

1818
project_id = var.project_id
1919
zone = var.zone
20-
service_account_email = google_service_account.abfs_server.email
20+
service_account_email = data.google_service_account.abfs.email
2121
subnetwork = module.abfs-vpc.subnets["${var.region}/abfs-subnet"].name
2222
abfs_docker_image_uri = var.abfs_docker_image_uri
2323
abfs_license = var.abfs_license
@@ -28,7 +28,7 @@ module "abfs-uploaders" {
2828

2929
project_id = var.project_id
3030
zone = var.zone
31-
service_account_email = google_service_account.abfs_server.email
31+
service_account_email = data.google_service_account.abfs.email
3232
subnetwork = module.abfs-vpc.subnets["${var.region}/abfs-subnet"].name
3333
abfs_docker_image_uri = var.abfs_docker_image_uri
3434
abfs_gerrit_uploader_manifest_server = var.abfs_gerrit_uploader_manifest_server
@@ -40,7 +40,8 @@ module "abfs-uploaders" {
4040
}
4141

4242
module "monitoring" {
43-
source = "./monitoring"
43+
source = "./monitoring"
44+
4445
project_id = data.google_project.project.project_id
4546
notification_email = var.alert_notification_email
4647
}

examples/simple/network.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ module "abfs-vpc" {
1919
project_id = data.google_project.project.project_id
2020
network_name = "abfs-network"
2121
routing_mode = "GLOBAL"
22-
2322
firewall_rules = [
2423
{
2524
description = "Allow egress to Google APIs via Private Google Access"
2625
direction = "EGRESS"
2726
name = "allow-egress-google-apis"
2827
priority = 1000
2928
ranges = ["199.36.153.8/30", "34.126.0.0/18"]
30-
target_service_accounts = [google_service_account.abfs_server.email]
29+
target_service_accounts = [data.google_service_account.abfs.email]
3130

3231
allow = [
3332
{
@@ -59,8 +58,8 @@ module "abfs-vpc" {
5958
priority = 1000
6059

6160
ranges = ["0.0.0.0/0"]
62-
source_service_accounts = [google_service_account.abfs_server.email]
63-
target_service_accounts = [google_service_account.abfs_server.email]
61+
source_service_accounts = [data.google_service_account.abfs.email]
62+
target_service_accounts = [data.google_service_account.abfs.email]
6463
allow = [
6564
{
6665
protocol = "icmp"
@@ -77,7 +76,6 @@ module "abfs-vpc" {
7776
]
7877
}
7978
]
80-
8179
subnets = [
8280
{
8381
subnet_name = "abfs-subnet"
@@ -100,8 +98,9 @@ resource "google_compute_router" "nat_router" {
10098
}
10199

102100
module "cloud-nat" {
103-
source = "terraform-google-modules/cloud-nat/google"
104-
version = "~> 5.3"
101+
source = "terraform-google-modules/cloud-nat/google"
102+
version = "~> 5.3"
103+
105104
project_id = var.project_id
106105
region = var.region
107106
router = google_compute_router.nat_router.name

examples/simple/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ output "license_information" {
1616
value = {
1717
project_id = data.google_project.project.project_id,
1818
project_number = data.google_project.project.number,
19-
service_account_email = google_service_account.abfs_server.email
20-
service_account_unique_id = google_service_account.abfs_server.unique_id
19+
service_account_email = data.google_service_account.abfs.email
20+
service_account_unique_id = data.google_service_account.abfs.unique_id
2121
}
2222
}

examples/simple/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ variable "alert_notification_email" {
6565
type = string
6666
description = "Email address to send alert notifications to"
6767
}
68+
69+
variable "abfs_service_account_id" {
70+
type = string
71+
description = "ABFS service account ID (e.g. abfs@<project-id>.iam.gserviceaccount.com)"
72+
}

0 commit comments

Comments
 (0)