-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from CloudVLab/tlf_firebase
Firebase Project: Initial Version
- Loading branch information
Showing
14 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Terraform: Firebase Project | ||
|
||
| Channel | Status | | ||
|---------|--------| | ||
| Stable | ![CloudBuild]() | | ||
| Beta | ![CloudBuild]() | | ||
|
||
Create a Firebase Project based on a Terraform configuration | ||
|
||
## Using Input Values | ||
|
||
__NOTE:__ Qwiklabs requires some values to be defined as part of the provisioning process. | ||
|
||
#### Qwiklabs Properties | ||
``` | ||
gcp_project_id = "my-gcp-project" | ||
gcp_region = "us-central1" | ||
gcp_zone = "us-central1-a" | ||
``` | ||
|
||
#### Custom Properties | ||
N/A | ||
|
||
## Example | ||
|
||
View the [example configuration](https://github.com/CloudVLab/terraform-lab-foundation/tree/main/basics/firebase_project/example) to get started. | ||
|
||
## Accessing Output Values | ||
|
||
| Field | Description | | ||
|-------|-------------| | ||
| firebase_project_id | Firebase project identifier | | ||
| firebase_project_number | Firebase project number | | ||
|
||
## Adding a Commit | ||
|
||
Commits to the repository will initiate the automated QA process | ||
|
||
It is highly recommended that modules are tested locally before making a commit. | ||
|
||
## Request a Pull Request | ||
|
||
__DO NOT__ raise a PR on code that does not pass integration tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
steps: | ||
- name: 'hashicorp/terraform:${_PROVIDER_VER}' | ||
args: ['init'] | ||
id: init-terraform | ||
dir: '${_TERRAFORM_DIR}' | ||
- name: 'hashicorp/terraform:${_PROVIDER_VER}' | ||
args: ['validate'] | ||
id: validate-terraform | ||
dir: '${_TERRAFORM_DIR}' | ||
- name: 'hashicorp/terraform:${_PROVIDER_VER}' | ||
args: ['apply', '-var-file=test.tfvars', '-auto-approve'] | ||
id: apply-terraform | ||
dir: '${_TERRAFORM_DIR}' | ||
- name: 'hashicorp/terraform:${_PROVIDER_VER}' | ||
args: ['destroy', '-var-file=test.tfvars', '-auto-approve'] | ||
id: destroy-terraform | ||
dir: '${_TERRAFORM_DIR}' | ||
substitutions: | ||
_PROVIDER_VER: 1.0.1 | ||
_TERRAFORM_DIR: basics/firebase_project/stable | ||
tags: ['terraform-lab-foundation','firebase', 'project'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Terraform: Firebase Project | ||
|
||
## Example | ||
|
||
The example is based on the following hierarchy: | ||
``` | ||
. | ||
├── instructions | ||
│ ├── en.md | ||
│ └── img | ||
├── QL_OWNER | ||
└── qwiklabs.yaml | ||
``` | ||
|
||
## Add the module to the directory | ||
|
||
Add the example Terraform code module to your project | ||
|
||
``` | ||
curl -L https://github.com/CloudVLab/terraform-lab-foundation/raw/main/basics/firebase_project/example/install.sh | bash | ||
``` | ||
|
||
## View the updated directory | ||
|
||
The example is based on the following hierarchy: | ||
|
||
``` | ||
. | ||
├── instructions | ||
│ ├── en.md | ||
│ └── img | ||
├── QL_OWNER | ||
├── qwiklabs.yaml | ||
└── tf | ||
├── main.tf | ||
├── outputs.tf | ||
├── runtime.yaml | ||
└── variables.tf | ||
``` | ||
|
||
__NOTE:__ The Terraform examples assume a configuration sub-directory | ||
named `tf` is present. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
BRANCH="main" | ||
MODULE="firebase_project" | ||
TYPE="basics" | ||
CHANNEL="STABLE" | ||
|
||
# Set the endpoint for the module | ||
if [ "$CHANNEL" = "STABLE" ]; then | ||
## STABLE Channel | ||
URL="https://github.com/CloudVLab/terraform-lab-foundation/raw/${BRANCH}" | ||
else | ||
## DEV/BETA Channel | ||
URL="https://github.com/CloudVLab/terraform-lab-foundation/raw/${BRANCH}" | ||
fi | ||
|
||
DIRECTORY="tf" | ||
FILE1="main.tf" | ||
FILE1_URL="${URL}/${TYPE}/${MODULE}/example/main.tf" | ||
FILE2="outputs.tf" | ||
FILE2_URL="${URL}/${TYPE}/${MODULE}/example/outputs.tf" | ||
FILE3="runtime.yaml" | ||
FILE3_URL="${URL}/${TYPE}/${MODULE}/example/runtime.yaml" | ||
FILE4="variables.tf" | ||
FILE4_URL="${URL}/${TYPE}/${MODULE}/example/variables.tf" | ||
|
||
# Create TF directory if not present | ||
if [ ! -d $DIRECTORY ]; then | ||
mkdir $DIRECTORY | ||
fi | ||
|
||
# Download if the file does not exist | ||
if [ ! -f $DIRECTORY/$FILE1 ]; then | ||
curl -L $FILE1_URL -o "$DIRECTORY/$FILE1" | ||
fi | ||
|
||
# Download if the file does not exist | ||
if [ ! -f $DIRECTORY/$FILE2 ]; then | ||
curl -L $FILE2_URL -o "$DIRECTORY/$FILE2" | ||
fi | ||
|
||
# Download if the file does not exist | ||
if [ ! -f $DIRECTORY/$FILE3 ]; then | ||
curl -L $FILE3_URL -o "$DIRECTORY/$FILE3" | ||
fi | ||
|
||
# Download if the file does not exist | ||
if [ ! -f $DIRECTORY/$FILE4 ]; then | ||
curl -L $FILE4_URL -o "$DIRECTORY/$FILE4" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Firebase: Project | ||
# Local: modules/[channel] | ||
# Remote: github.com://CloudVLab/terraform-lab-foundation//[module]/[channel] | ||
|
||
# Module: Google Compute Engine | ||
module "la_firebase_project" { | ||
source = "github.com/CloudVLab/terraform-lab-foundation//basics/firebase_project/stable" | ||
|
||
# Pass values to the module | ||
gcp_project_id = var.gcp_project_id | ||
gcp_region = var.gcp_region | ||
gcp_zone = var.gcp_zone | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Expose Firebase Project properties | ||
|
||
# Terraform Output values | ||
output "firebase_project_id" { | ||
value = module.la_firebase_project.firebase_project_id | ||
} | ||
|
||
output "firebase_project_number" { | ||
value = module.la_firebase_project.firebase_project_number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
runtime: terraform | ||
version: 1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
# Mandatory Prefix | ||
echo "STARTUP-SCRIPT START" | ||
echo "DO_SOMETHING_HERE" | ||
# Mandatory Postfix | ||
echo "STARTUP-SCRIPT END" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Qwiklabs Mandatory Values | ||
variable "gcp_project_id" { | ||
type = string | ||
} | ||
|
||
variable "gcp_region" { | ||
type = string | ||
} | ||
|
||
variable "gcp_zone" { | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Module: GoogleAPIs | ||
module "la_api_batch" { | ||
source = "github.com/CloudVLab/terraform-lab-foundation//basics/api_service/dev" | ||
|
||
# Pass values to the module | ||
gcp_project_id = var.gcp_project_id | ||
gcp_region = var.gcp_region | ||
gcp_zone = var.gcp_zone | ||
|
||
# Enable Google API(s) | ||
api_services = [ "firebase.googleapis.com" ] | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/firebase_project.html | ||
resource "google_firebase_project" "default" { | ||
provider = google-beta | ||
project = var.gcp_project_id | ||
depends_on = [ module.la_api_batch ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## -------------------------------------------------------------- | ||
## Custom variable definitions | ||
## -------------------------------------------------------------- | ||
|
||
## Firebase Project Configuration | ||
|
||
output "firebase_project_id" { | ||
value = "${google_firebase_project.default.project}" | ||
description = "Firebase Project identifier." | ||
} | ||
|
||
output "firebase_project_number" { | ||
value = "${google_firebase_project.default.project_number}" | ||
description = "Firebase Project number." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
runtime: terraform | ||
version: 1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gcp_project_id = "qwiklabs-resources" | ||
gcp_region = "us-central1" | ||
gcp_zone = "us-central1-a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## -------------------------------------------------------------- | ||
## Mandatory variable definitions | ||
## -------------------------------------------------------------- | ||
|
||
variable "gcp_project_id" { | ||
type = string | ||
description = "The GCP project ID to create resources in." | ||
} | ||
|
||
# Default value passed in | ||
variable "gcp_region" { | ||
type = string | ||
description = "Region to create resources in." | ||
} | ||
|
||
# Default value passed in | ||
variable "gcp_zone" { | ||
type = string | ||
description = "Zone to create resources in." | ||
} |