Skip to content

Commit

Permalink
Add 'resources' reading and 'location_id' setting on Firebase P… (Goo…
Browse files Browse the repository at this point in the history
…gleCloudPlatform#3319)

* Add FirebaseLocation fine grained resource

* Updates for firebase finalize location

Removed the custom decoder and replaced with the "fine grain" resource operator
"nested_query".
Updated the import_id so that importing wouldn't crash terraform

Co-authored-by: Chris Stephens <[email protected]>
  • Loading branch information
2 people authored and Nathan Klish committed May 18, 2020
1 parent 4bced80 commit 2ce57c4
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
33 changes: 33 additions & 0 deletions products/firebase/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ objects:
name: 'Project'
min_version: beta
base_url: projects/{{project}}
self_link: projects/{{project}}
create_url: projects/{{project}}:addFirebase
input: true
description: |
Expand All @@ -66,4 +67,36 @@ objects:
output: true
description: |
The GCP project display name
- !ruby/object:Api::Resource
name: 'ProjectLocation'
min_version: beta
base_url: projects/{{project}}
self_link: projects/{{project}}
create_url: projects/{{project}}/defaultLocation:finalize
nested_query: !ruby/object:Api::Resource::NestedQuery
keys:
- resources
input: true
description: |
Sets the default Google Cloud Platform (GCP) resource location for the specified FirebaseProject.
This method creates an App Engine application with a default Cloud Storage bucket, located in the specified
locationId. This location must be one of the available GCP resource locations.
After the default GCP resource location is finalized, or if it was already set, it cannot be changed.
The default GCP resource location for the specified FirebaseProject might already be set because either the
GCP Project already has an App Engine application or defaultLocation.finalize was previously called with a
specified locationId. Any new calls to defaultLocation.finalize with a different specified locationId will
return a 409 error.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
'https://firebase.google.com/'
api: 'https://firebase.google.com/docs/projects/api/reference/rest/v1beta1/projects.defaultLocation/finalize'
properties:
- !ruby/object:Api::Type::String
name: locationId
required: true
description: |
The ID of the default GCP resource location for the Project. The location must be one of the available GCP
resource locations.
14 changes: 14 additions & 0 deletions products/firebase/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ overrides: !ruby/object:Overrides::ResourceOverrides
instance_name: "memory-cache"
test_env_vars:
org_id: :ORG_ID
ProjectLocation: !ruby/object:Overrides::Terraform::ResourceOverride
import_format: ['projects/{{project}}', '{{project}}']
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 10
skip_delete: true
skip_sweeper: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "firebase_project_location_basic"
min_version: 'beta'
primary_resource_id: "basic"
test_env_vars:
org_id: :ORG_ID
properties:

# This is for copying files over
files: !ruby/object:Provider::Config::Files
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "google_project" "default" {
provider = google-beta

project_id = "tf-test%{random_suffix}"
name = "tf-test%{random_suffix}"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
}

resource "google_firebase_project" "default" {
provider = google-beta
project = google_project.default.project_id
}

resource "google_firebase_project_location" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
project = google_firebase_project.default.project

location_id = "us-central"
}

0 comments on commit 2ce57c4

Please sign in to comment.