Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.0"
version = "~> 6.0"
}
}
}
Expand All @@ -27,11 +27,7 @@ resource "google_project" "default" {
# TODO: REPLACE WITH YOUR OWN VALUES
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"

# Required for the project to display in any list of Firebase projects.
labels = {
"firebase" = "enabled"
}
billing_account = "<BILLING_ACCOUNT_ID>"
}

# Enable the required underlying Service Usage API.
Expand Down
9 changes: 2 additions & 7 deletions web/terraform-checkpoints/register-app-checkpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.0"
version = "~> 6.0"
}
}
}
Expand All @@ -27,11 +27,7 @@ resource "google_project" "default" {
# TODO: REPLACE WITH YOUR OWN VALUES
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"

# Required for the project to display in any list of Firebase projects.
labels = {
"firebase" = "enabled"
}
billing_account = "<BILLING_ACCOUNT_ID>"
}

# Enable the required underlying Service Usage API.
Expand Down Expand Up @@ -76,5 +72,4 @@ resource "google_firebase_web_app" "default" {
project = google_firebase_project.default.project
# TODO: REPLACE WITH YOUR OWN VALUE
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
deletion_policy = "DELETE"
}
43 changes: 17 additions & 26 deletions web/terraform-checkpoints/replicate-config/main-foreach.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.0"
version = "~> 6.0"
}
}
}
Expand All @@ -30,11 +30,6 @@ resource "google_project" "default" {
# Required if you want to set up Authentication via Terraform
billing_account = "<YOUR_BILLING_ACCOUNT_ID>"

# Required for the projects to display in any list of Firebase projects.
labels = {
"firebase" = "enabled"
}

# TODO: REPLACE WITH YOUR OWN VALUES
for_each = {
prod = "<PROJECT_NAME_OF_PROD_PROJECT>"
Expand Down Expand Up @@ -88,7 +83,6 @@ resource "google_firebase_web_app" "default" {
project = each.value.project
# TODO: REPLACE WITH YOUR OWN VALUE
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
deletion_policy = "DELETE"
}

# UNCOMMENT BELOW IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
Expand Down Expand Up @@ -256,30 +250,27 @@ resource "google_project_service" "firebasestorage" {
disable_on_destroy = false
}

# Provision the default Cloud Storage bucket for the project via Google App Engine.
resource "google_app_engine_application" "default" {
# Provision a Cloud Storage bucket for the project
resource "google_storage_bucket" "my_buckets" {
provider = google-beta
for_each = google_firebase_project.default

project = each.value.project
# See available locations: https://firebase.google.com/docs/projects/locations#default-cloud-location
# This will set the location for the default Storage bucket and the App Engine App.
# TODO: REPLACE WITH YOUR OWN VALUE
location_id = "<NAME_OF_DESIRED_REGION_FOR_DEFAULT_BUCKET>" # Must be in the same location as Firestore (above)

# Wait until Firestore is provisioned first.
depends_on = [
google_firestore_database.default
]
# TODO: name your bucket
name = "${each.value.project}-<EXTRA_NAME_OF_BUCKET>"
# TODO: See available locations https://cloud.google.com/storage/docs/locations
location = "<LOCATION_OF_BUCKET>"
force_destroy = true
}

# Make the default Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
resource "google_firebase_storage_bucket" "default_bucket" {
# Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
resource "google_firebase_storage_bucket" "my_buckets" {
provider = google-beta
for_each = google_firebase_project.default

project = each.value.project
bucket_id = google_app_engine_application.default[each.key].default_bucket
bucket_id = google_storage_bucket.my_buckets[each.key].name

depends_on = [
google_project_service.firebasestorage,
Expand All @@ -302,19 +293,19 @@ resource "google_firebaserules_ruleset" "storage" {
}
}

# Wait for the default Storage bucket to be provisioned before creating this ruleset.
# Wait for the Storage bucket to be provisioned before creating this ruleset.
depends_on = [
google_firebase_storage_bucket.default_bucket,
google_firebase_storage_bucket.my_buckets,
]
}

# Release the ruleset to the default Storage bucket.
resource "google_firebaserules_release" "default_bucket" {
# Release the ruleset to the Storage bucket.
resource "google_firebaserules_release" "my_buckets" {
provider = google-beta
for_each = google_firebase_project.default

name = "firebase.storage/${google_app_engine_application.default[each.key].default_bucket}"
ruleset_name = "projects/${google_firebase_project.default[each.key].project}/rulesets/${google_firebaserules_ruleset.storage[each.key].name}"
name = "firebase.storage/${google_storage_bucket.my_buckets[each.key].name}"
ruleset_name = google_firebaserules_ruleset.storage[each.key].name
project = each.value.project

lifecycle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ resource "google_project" "staging" {
provider = google-beta.no_user_project_override

# TODO: REPLACE WITH YOUR OWN VALUES
name = "<PROJECT_NAME_OF_YOUR_STAGING_PROJECT>"
project_id = "<PROJECT_ID_OF_YOUR_STAGING_PROJECT>"
# UNCOMMENT BELOW IF YOU IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
# billing_account = "<BILLING_ACCOUNT_ID>"

# Required for the project to display in any list of Firebase projects.
labels = {
"firebase" = "enabled"
}
name = "<PROJECT_NAME_OF_YOUR_STAGING_PROJECT>"
project_id = "<PROJECT_ID_OF_YOUR_STAGING_PROJECT>"
billing_account = "<BILLING_ACCOUNT_ID>"
}

# Enable the required underlying Service Usage API.
Expand Down Expand Up @@ -53,10 +47,9 @@ resource "google_firebase_project" "staging" {
resource "google_firebase_web_app" "staging" {
provider = google-beta

project = google_firebase_project.staging.project
project = google_firebase_project.staging.project
# TODO: REPLACE WITH YOUR OWN VALUE
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
deletion_policy = "DELETE"
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
}

# UNCOMMENT BELOW IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
Expand Down Expand Up @@ -200,29 +193,24 @@ resource "google_project_service" "storage_staging" {
disable_on_destroy = false
}

# Provision the default Cloud Storage bucket for the project via Google App Engine.
resource "google_app_engine_application" "staging" {
# Provision a Cloud Storage bucket for the project
resource "google_storage_bucket" "my_bucket_staging" {
provider = google-beta
project = google_firebase_project.staging.project

project = google_firebase_project.staging.project
# See available locations: https://firebase.google.com/docs/projects/locations#default-cloud-location
# This will set the location for the default Storage bucket and the App Engine App.
# TODO: REPLACE WITH YOUR OWN VALUE
location_id = "<NAME_OF_DESIRED_REGION_FOR_DEFAULT_BUCKET>" # Must be in the same location as Firestore (above)

# Wait until Firestore is provisioned first.
depends_on = [
google_firestore_database.staging
]
# TODO: name your bucket
name = "<NAME_OF_BUCKET>"
# TODO: See available locations https://cloud.google.com/storage/docs/locations
location = "<LOCATION_OF_BUCKET>"
force_destroy = true
}

# Make the default Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
resource "google_firebase_storage_bucket" "default_bucket_staging" {
# Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
resource "google_firebase_storage_bucket" "my_bucket_staging" {
provider = google-beta

project = google_firebase_project.staging.project
bucket_id = google_app_engine_application.staging.default_bucket

bucket_id = google_storage_bucket.my_bucket_staging.name

depends_on = [
google_project_service.storage_staging
Expand All @@ -243,18 +231,18 @@ resource "google_firebaserules_ruleset" "storage_staging" {
}
}

# Wait for the default Storage bucket to be provisioned before creating this ruleset.
# Wait for the Storage bucket to be provisioned before creating this ruleset.
depends_on = [
google_firebase_storage_bucket.default_bucket_staging,
google_firebase_storage_bucket.my_bucket_staging,
]
}

# Release the ruleset to the default Storage bucket.
resource "google_firebaserules_release" "default_bucket_staging" {
# Release the ruleset to the Storage bucket.
resource "google_firebaserules_release" "my_bucket_staging" {
provider = google-beta

name = "firebase.storage/${google_app_engine_application.staging.default_bucket}"
ruleset_name = "projects/${google_firebase_project.staging.project}/rulesets/${google_firebaserules_ruleset.storage_staging.name}"
name = "firebase.storage/${google_storage_bucket.my_bucket_staging.name}"
ruleset_name = google_firebaserules_ruleset.storage_staging.name
project = google_firebase_project.staging.project

lifecycle {
Expand Down
8 changes: 1 addition & 7 deletions web/terraform-checkpoints/set-up-auth-checkpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.0"
version = "~> 6.0"
}
}
}
Expand All @@ -28,11 +28,6 @@ resource "google_project" "default" {
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"
billing_account = "<BILLING_ACCOUNT_ID>"

# Required for the project to display in any list of Firebase projects.
labels = {
"firebase" = "enabled"
}
}

# Enable the required underlying Service Usage API.
Expand Down Expand Up @@ -77,7 +72,6 @@ resource "google_firebase_web_app" "default" {
project = google_firebase_project.default.project
# TODO: REPLACE WITH YOUR OWN VALUE
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
deletion_policy = "DELETE"
}

# Enable the Identity Toolkit API.
Expand Down
11 changes: 2 additions & 9 deletions web/terraform-checkpoints/set-up-firestore-checkpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.0"
version = "~> 6.0"
}
}
}
Expand All @@ -27,13 +27,7 @@ resource "google_project" "default" {
# TODO: REPLACE WITH YOUR OWN VALUES
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"
# UNCOMMENT BELOW IF YOU IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
# billing_account = "<BILLING_ACCOUNT_ID>"

# Required for the project to display in any list of Firebase projects.
labels = {
"firebase" = "enabled"
}
billing_account = "<BILLING_ACCOUNT_ID>"
}

# Enable the required underlying Service Usage API.
Expand Down Expand Up @@ -78,7 +72,6 @@ resource "google_firebase_web_app" "default" {
project = google_firebase_project.default.project
# TODO: REPLACE WITH YOUR OWN VALUE
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
deletion_policy = "DELETE"
}

# UNCOMMENT BELOW IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
Expand Down
Loading