Skip to content

Commit c5dc39a

Browse files
committed
Rennovate Terraform examples
1 parent 967c2c0 commit c5dc39a

7 files changed

Lines changed: 70 additions & 124 deletions

web/terraform-checkpoints/create-firebase-project-checkpoint.tf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
google-beta = {
55
source = "hashicorp/google-beta"
6-
version = "~> 4.0"
6+
version = "~> 6.0"
77
}
88
}
99
}
@@ -27,11 +27,7 @@ resource "google_project" "default" {
2727
# TODO: REPLACE WITH YOUR OWN VALUES
2828
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
2929
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"
30-
31-
# Required for the project to display in any list of Firebase projects.
32-
labels = {
33-
"firebase" = "enabled"
34-
}
30+
billing_account = "<BILLING_ACCOUNT_ID>"
3531
}
3632

3733
# Enable the required underlying Service Usage API.

web/terraform-checkpoints/register-app-checkpoint.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
google-beta = {
55
source = "hashicorp/google-beta"
6-
version = "~> 4.0"
6+
version = "~> 6.0"
77
}
88
}
99
}
@@ -27,11 +27,7 @@ resource "google_project" "default" {
2727
# TODO: REPLACE WITH YOUR OWN VALUES
2828
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
2929
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"
30-
31-
# Required for the project to display in any list of Firebase projects.
32-
labels = {
33-
"firebase" = "enabled"
34-
}
30+
billing_account = "<BILLING_ACCOUNT_ID>"
3531
}
3632

3733
# Enable the required underlying Service Usage API.
@@ -76,5 +72,4 @@ resource "google_firebase_web_app" "default" {
7672
project = google_firebase_project.default.project
7773
# TODO: REPLACE WITH YOUR OWN VALUE
7874
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
79-
deletion_policy = "DELETE"
8075
}

web/terraform-checkpoints/replicate-config/main-foreach.tf

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
google-beta = {
55
source = "hashicorp/google-beta"
6-
version = "~> 4.0"
6+
version = "~> 6.0"
77
}
88
}
99
}
@@ -30,11 +30,6 @@ resource "google_project" "default" {
3030
# Required if you want to set up Authentication via Terraform
3131
billing_account = "<YOUR_BILLING_ACCOUNT_ID>"
3232

33-
# Required for the projects to display in any list of Firebase projects.
34-
labels = {
35-
"firebase" = "enabled"
36-
}
37-
3833
# TODO: REPLACE WITH YOUR OWN VALUES
3934
for_each = {
4035
prod = "<PROJECT_NAME_OF_PROD_PROJECT>"
@@ -88,7 +83,6 @@ resource "google_firebase_web_app" "default" {
8883
project = each.value.project
8984
# TODO: REPLACE WITH YOUR OWN VALUE
9085
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
91-
deletion_policy = "DELETE"
9286
}
9387

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

259-
# Provision the default Cloud Storage bucket for the project via Google App Engine.
260-
resource "google_app_engine_application" "default" {
253+
# Provision a Cloud Storage bucket for the project
254+
resource "google_storage_bucket" "my_buckets" {
261255
provider = google-beta
262256
for_each = google_firebase_project.default
263257

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

270-
# Wait until Firestore is provisioned first.
271-
depends_on = [
272-
google_firestore_database.default
273-
]
260+
# TODO: name your bucket
261+
name = "${each.value.project}-<EXTRA_NAME_OF_BUCKET>"
262+
# TODO: See available locations https://cloud.google.com/storage/docs/locations
263+
location = "<LOCATION_OF_BUCKET>"
264+
force_destroy = true
274265
}
275266

276-
# Make the default Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
277-
resource "google_firebase_storage_bucket" "default_bucket" {
267+
# Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
268+
resource "google_firebase_storage_bucket" "my_buckets" {
278269
provider = google-beta
279270
for_each = google_firebase_project.default
280271

281272
project = each.value.project
282-
bucket_id = google_app_engine_application.default[each.key].default_bucket
273+
bucket_id = google_storage_bucket.my_buckets[each.key].name
283274

284275
depends_on = [
285276
google_project_service.firebasestorage,
@@ -302,19 +293,19 @@ resource "google_firebaserules_ruleset" "storage" {
302293
}
303294
}
304295

305-
# Wait for the default Storage bucket to be provisioned before creating this ruleset.
296+
# Wait for the Storage bucket to be provisioned before creating this ruleset.
306297
depends_on = [
307-
google_firebase_storage_bucket.default_bucket,
298+
google_firebase_storage_bucket.my_buckets,
308299
]
309300
}
310301

311-
# Release the ruleset to the default Storage bucket.
312-
resource "google_firebaserules_release" "default_bucket" {
302+
# Release the ruleset to the Storage bucket.
303+
resource "google_firebaserules_release" "my_buckets" {
313304
provider = google-beta
314305
for_each = google_firebase_project.default
315306

316-
name = "firebase.storage/${google_app_engine_application.default[each.key].default_bucket}"
317-
ruleset_name = "projects/${google_firebase_project.default[each.key].project}/rulesets/${google_firebaserules_ruleset.storage[each.key].name}"
307+
name = "firebase.storage/${google_storage_bucket.my_buckets[each.key].name}"
308+
ruleset_name = google_firebaserules_ruleset.storage[each.key].name
318309
project = each.value.project
319310

320311
lifecycle {

web/terraform-checkpoints/replicate-config/main_staging-copypaste.tf

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@ resource "google_project" "staging" {
33
provider = google-beta.no_user_project_override
44

55
# TODO: REPLACE WITH YOUR OWN VALUES
6-
name = "<PROJECT_NAME_OF_YOUR_STAGING_PROJECT>"
7-
project_id = "<PROJECT_ID_OF_YOUR_STAGING_PROJECT>"
8-
# UNCOMMENT BELOW IF YOU IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
9-
# billing_account = "<BILLING_ACCOUNT_ID>"
10-
11-
# Required for the project to display in any list of Firebase projects.
12-
labels = {
13-
"firebase" = "enabled"
14-
}
6+
name = "<PROJECT_NAME_OF_YOUR_STAGING_PROJECT>"
7+
project_id = "<PROJECT_ID_OF_YOUR_STAGING_PROJECT>"
8+
billing_account = "<BILLING_ACCOUNT_ID>"
159
}
1610

1711
# Enable the required underlying Service Usage API.
@@ -53,10 +47,9 @@ resource "google_firebase_project" "staging" {
5347
resource "google_firebase_web_app" "staging" {
5448
provider = google-beta
5549

56-
project = google_firebase_project.staging.project
50+
project = google_firebase_project.staging.project
5751
# TODO: REPLACE WITH YOUR OWN VALUE
58-
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
59-
deletion_policy = "DELETE"
52+
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
6053
}
6154

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

203-
# Provision the default Cloud Storage bucket for the project via Google App Engine.
204-
resource "google_app_engine_application" "staging" {
196+
# Provision a Cloud Storage bucket for the project
197+
resource "google_storage_bucket" "my_bucket_staging" {
205198
provider = google-beta
199+
project = google_firebase_project.staging.project
206200

207-
project = google_firebase_project.staging.project
208-
# See available locations: https://firebase.google.com/docs/projects/locations#default-cloud-location
209-
# This will set the location for the default Storage bucket and the App Engine App.
210-
# TODO: REPLACE WITH YOUR OWN VALUE
211-
location_id = "<NAME_OF_DESIRED_REGION_FOR_DEFAULT_BUCKET>" # Must be in the same location as Firestore (above)
212-
213-
# Wait until Firestore is provisioned first.
214-
depends_on = [
215-
google_firestore_database.staging
216-
]
201+
# TODO: name your bucket
202+
name = "<NAME_OF_BUCKET>"
203+
# TODO: See available locations https://cloud.google.com/storage/docs/locations
204+
location = "<LOCATION_OF_BUCKET>"
205+
force_destroy = true
217206
}
218207

219-
# Make the default Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
220-
resource "google_firebase_storage_bucket" "default_bucket_staging" {
208+
# Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
209+
resource "google_firebase_storage_bucket" "my_bucket_staging" {
221210
provider = google-beta
222211

223212
project = google_firebase_project.staging.project
224-
bucket_id = google_app_engine_application.staging.default_bucket
225-
213+
bucket_id = google_storage_bucket.my_bucket_staging.name
226214

227215
depends_on = [
228216
google_project_service.storage_staging
@@ -243,18 +231,18 @@ resource "google_firebaserules_ruleset" "storage_staging" {
243231
}
244232
}
245233

246-
# Wait for the default Storage bucket to be provisioned before creating this ruleset.
234+
# Wait for the Storage bucket to be provisioned before creating this ruleset.
247235
depends_on = [
248-
google_firebase_storage_bucket.default_bucket_staging,
236+
google_firebase_storage_bucket.my_bucket_staging,
249237
]
250238
}
251239

252-
# Release the ruleset to the default Storage bucket.
253-
resource "google_firebaserules_release" "default_bucket_staging" {
240+
# Release the ruleset to the Storage bucket.
241+
resource "google_firebaserules_release" "my_bucket_staging" {
254242
provider = google-beta
255243

256-
name = "firebase.storage/${google_app_engine_application.staging.default_bucket}"
257-
ruleset_name = "projects/${google_firebase_project.staging.project}/rulesets/${google_firebaserules_ruleset.storage_staging.name}"
244+
name = "firebase.storage/${google_storage_bucket.my_bucket_staging.name}"
245+
ruleset_name = google_firebaserules_ruleset.storage_staging.name
258246
project = google_firebase_project.staging.project
259247

260248
lifecycle {

web/terraform-checkpoints/set-up-auth-checkpoint.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
google-beta = {
55
source = "hashicorp/google-beta"
6-
version = "~> 4.0"
6+
version = "~> 6.0"
77
}
88
}
99
}
@@ -28,11 +28,6 @@ resource "google_project" "default" {
2828
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
2929
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"
3030
billing_account = "<BILLING_ACCOUNT_ID>"
31-
32-
# Required for the project to display in any list of Firebase projects.
33-
labels = {
34-
"firebase" = "enabled"
35-
}
3631
}
3732

3833
# Enable the required underlying Service Usage API.
@@ -77,7 +72,6 @@ resource "google_firebase_web_app" "default" {
7772
project = google_firebase_project.default.project
7873
# TODO: REPLACE WITH YOUR OWN VALUE
7974
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
80-
deletion_policy = "DELETE"
8175
}
8276

8377
# Enable the Identity Toolkit API.

web/terraform-checkpoints/set-up-firestore-checkpoint.tf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
google-beta = {
55
source = "hashicorp/google-beta"
6-
version = "~> 4.0"
6+
version = "~> 6.0"
77
}
88
}
99
}
@@ -27,13 +27,7 @@ resource "google_project" "default" {
2727
# TODO: REPLACE WITH YOUR OWN VALUES
2828
name = "<PROJECT_NAME_OF_YOUR_PROJECT>"
2929
project_id = "<PROJECT_ID_OF_YOUR_PROJECT>"
30-
# UNCOMMENT BELOW IF YOU IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP
31-
# billing_account = "<BILLING_ACCOUNT_ID>"
32-
33-
# Required for the project to display in any list of Firebase projects.
34-
labels = {
35-
"firebase" = "enabled"
36-
}
30+
billing_account = "<BILLING_ACCOUNT_ID>"
3731
}
3832

3933
# Enable the required underlying Service Usage API.
@@ -78,7 +72,6 @@ resource "google_firebase_web_app" "default" {
7872
project = google_firebase_project.default.project
7973
# TODO: REPLACE WITH YOUR OWN VALUE
8074
display_name = "<DISPLAY_NAME_OF_YOUR_WEB_APP>"
81-
deletion_policy = "DELETE"
8275
}
8376

8477
# UNCOMMENT BELOW IF YOU SET UP FIREBASE AUTHENTICATION USING TERRAFORM IN THE PREVIOUS STEP

0 commit comments

Comments
 (0)