Skip to content

Commit c072299

Browse files
committed
Add service account setup
1 parent 591328d commit c072299

File tree

4 files changed

+81
-22
lines changed

4 files changed

+81
-22
lines changed

mmv1/products/firebaseapphosting/Backend.yaml

+21-18
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,38 @@ import_format:
2626
- "projects/{{project}}/locations/{{location}}/backends/{{backend_id}}"
2727
- "{{project}}/{{location}}/{{backend_id}}"
2828
- "{{location}}/{{backend_id}}"
29+
min_version: beta
2930
examples:
3031
- name: firebase_app_hosting_backend_basic
3132
primary_resource_id: example
33+
min_version: beta
3234
vars:
33-
location: 'us-central1'
34-
backend_id: 'my-backend'
35-
app_id: '1:0000000000:web:674cde32020e16fbce9dbd'
36-
display_name: 'My Backend'
37-
serving_locality: 'GLOBAL_ACCESS'
35+
location: "us-central1"
36+
backend_id: "my-backend"
37+
app_id: "1:0000000000:web:674cde32020e16fbce9dbd"
38+
display_name: "My Backend"
39+
serving_locality: "GLOBAL_ACCESS"
3840
test_env_vars:
39-
project_id: 'PROJECT_NAME'
41+
project_id: "PROJECT_NAME"
4042
test_vars_overrides:
41-
'location': '"us-central1"'
42-
'serving_locality': '"GLOBAL_ACCESS"'
43-
'app_id': '"1:0000000000:web:674cde32020e16fbce9dbd"'
43+
"location": '"us-central1"'
44+
"serving_locality": '"GLOBAL_ACCESS"'
45+
"app_id": '"1:0000000000:web:674cde32020e16fbce9dbd"'
4446
- name: firebase_app_hosting_backend_github
4547
primary_resource_id: example
48+
min_version: beta
4649
vars:
47-
location: 'us-central1'
48-
backend_id: 'my-backend-gh'
49-
app_id: 'firebase:app:id'
50-
display_name: 'My Backend'
51-
serving_locality: 'GLOBAL_ACCESS'
50+
location: "us-central1"
51+
backend_id: "my-backend-gh"
52+
app_id: "firebase:app:id"
53+
display_name: "My Backend"
54+
serving_locality: "GLOBAL_ACCESS"
5255
test_env_vars:
53-
project_id: 'PROJECT_NAME'
56+
project_id: "PROJECT_NAME"
5457
test_vars_overrides:
55-
'location': '"us-central1"'
56-
'serving_locality': '"GLOBAL_ACCESS"'
57-
skip_test: true # Can't establish a Github connection in automated tests.
58+
"location": '"us-central1"'
59+
"serving_locality": '"GLOBAL_ACCESS"'
60+
skip_test: true # Can't establish a Github connection in automated tests.
5861
autogen_async: true
5962
async:
6063
operation:

mmv1/products/firebaseapphosting/product.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ scopes:
1919
versions:
2020
- base_url: https://firebaseapphosting.googleapis.com/v1beta/
2121
name: beta
22-
# GA not available yet
23-
# - base_url: https://firebaseapphosting.googleapis.com/v1main/
24-
# name: ga
22+
# GA not available yet
23+
# - base_url: https://firebaseapphosting.googleapis.com/v1main/
24+
# name: ga

mmv1/templates/terraform/examples/firebase_app_hosting_backend_basic.tf.tmpl

+47-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
1+
# Service account setup only required once per project.
2+
resource "google_service_account" "service_account" {
3+
provider = google-beta
4+
5+
project = "{{index $.TestEnvVars "project_id"}}"
6+
7+
# Must be firebase-app-hosting-compute
8+
account_id = "firebase-app-hosting-compute"
9+
display_name = "Firebase App Hosting compute service account"
10+
11+
# Do not throw if already exists
12+
create_ignore_already_exists = true
13+
}
14+
15+
resource "google_project_iam_member" "app_hosting_sa_developerconnect" {
16+
provider = google-beta
17+
18+
project = "{{index $.TestEnvVars "project_id"}}"
19+
20+
# For reading connected Github repos
21+
role = "roles/developerconnect.readTokenAccessor"
22+
member = google_service_account.service_account.member
23+
}
24+
25+
resource "google_project_iam_member" "app_hosting_sa_adminsdk" {
26+
provider = google-beta
27+
28+
project = "{{index $.TestEnvVars "project_id"}}"
29+
30+
# For Firebase Admin SDK
31+
role = "roles/firebase.sdkAdminServiceAgent"
32+
member = google_service_account.service_account.member
33+
}
34+
35+
resource "google_project_iam_member" "app_hosting_sa_runner" {
36+
provider = google-beta
37+
38+
project = "{{index $.TestEnvVars "project_id"}}"
39+
40+
# For App Hosting
41+
role = "roles/firebaseapphosting.computeRunner"
42+
member = google_service_account.service_account.member
43+
}
44+
145
resource "google_firebase_app_hosting_backend" "example" {
46+
provider = google-beta
47+
248
project = "{{index $.TestEnvVars "project_id"}}"
349
location = "{{index $.Vars "location"}}"
450
backend_id = "{{index $.Vars "backend_id"}}"
551
app_id = "{{index $.Vars "app_id"}}"
652
display_name = "{{index $.Vars "display_name"}}"
753
serving_locality = "{{index $.Vars "serving_locality"}}"
8-
service_account = "firebase-app-hosting-compute@{{index $.TestEnvVars "project_id"}}.iam.gserviceaccount.com"
54+
service_account = google_service_account.service_account.email
955
environment = "prod"
1056

1157
annotations = {

mmv1/templates/terraform/examples/firebase_app_hosting_backend_github.tf.tmpl

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
resource "google_firebase_app_hosting_backend" "example" {
2+
provider = google-beta
3+
24
project = "{{index $.TestEnvVars "project_id"}}"
35
location = "{{index $.Vars "location"}}"
46
backend_id = "{{index $.Vars "backend_id"}}"
@@ -23,6 +25,8 @@ resource "google_firebase_app_hosting_backend" "example" {
2325
}
2426

2527
resource "google_developer_connect_connection" "my-connection" {
28+
provider = google-beta
29+
2630
project = "{{index $.TestEnvVars "project_id"}}"
2731
location = "{{index $.Vars "location"}}"
2832
connection_id = "tf-test-connection-new"
@@ -33,6 +37,8 @@ resource "google_developer_connect_connection" "my-connection" {
3337
}
3438

3539
resource "google_developer_connect_git_repository_link" "my-repository" {
40+
provider = google-beta
41+
3642
project = "{{index $.TestEnvVars "project_id"}}"
3743
location = "{{index $.Vars "location"}}"
3844

@@ -48,12 +54,16 @@ output "next_steps" {
4854

4955
# Setup permissions. Only needed once per project
5056
resource "google_project_service_identity" "devconnect-p4sa" {
57+
provider = google-beta
58+
5159
provider = google-beta
5260
project = "{{index $.TestEnvVars "project_id"}}"
5361
service = "developerconnect.googleapis.com"
5462
}
5563

5664
resource "google_project_iam_member" "devconnect-secret" {
65+
provider = google-beta
66+
5767
project = "{{index $.TestEnvVars "project_id"}}"
5868
role = "roles/secretmanager.admin"
5969
member = google_project_service_identity.devconnect-p4sa.member

0 commit comments

Comments
 (0)