-
Notifications
You must be signed in to change notification settings - Fork 71
feat: support multiple firebase sites #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bb77787
8ccc7a2
b260df6
20d9ad9
c9cacd6
53e1771
a85b685
71f7e10
7a85338
cd58077
85c617c
3c7bf00
8ee5e7d
e7cc4c7
0c99f61
bfc5941
0c5fc0b
ef39b75
0327d88
6885933
9bcf68e
0430c1f
870797c
40f9d52
ae80693
1b386cf
285ec74
16576f1
b9074a6
2ab0855
74481ed
b7a857e
cd16d5b
fb6ea65
0ab98cf
9ec351b
168394f
ae2350f
3971a70
64e275b
85c019b
49536e2
111ab4b
05dddb0
7ba0c29
caa192e
262e318
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,4 +18,5 @@ ARG PROJECT_ID=YOURPROJECTID | |
| FROM gcr.io/$PROJECT_ID/firebase | ||
|
|
||
| COPY . ./ | ||
|
|
||
| ENTRYPOINT ./placeholder-deploy.sh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "projects": {}, | ||
| "targets": { | ||
| "$PROJECT_ID": { | ||
| "hosting": { | ||
| "$SUFFIX": [ | ||
| "${PROJECT_ID}-${SUFFIX}" | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "etags": {} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,22 +22,55 @@ steps: | |
| - 'TF_VAR_org_id=$_ORG_ID' | ||
| - 'TF_VAR_folder_id=$_FOLDER_ID' | ||
| - 'TF_VAR_billing_account=$_BILLING_ACCOUNT' | ||
|
|
||
| # Initialize all tests, then run two parallel sets of tests. | ||
| - id: init-all | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose'] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Since both sections below have an
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, this was copied from https://github.com/GoogleCloudPlatform/terraform-google-secure-cicd/blob/main/build/int.cloudbuild.yaml#L31 as a presumed 'best practice' (note: only example I could find)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm chatting with tf blueprint maintainers around best practices here, tbd |
||
|
|
||
| # Simple example - one deployment per project | ||
| - id: simple-example-init | ||
| waitFor: ['init-all'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSimpleExample --stage init --verbose'] | ||
| - id: simple-example-apply | ||
| waitFor: ['simple-example-init'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSimpleExample --stage apply --verbose'] | ||
| - id: simple-example-verify | ||
| waitFor: ['simple-example-apply'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSimpleExample --stage verify --verbose'] | ||
| - id: simple-example-teardown | ||
| waitFor: ['simple-example-verify'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSimpleExample --stage teardown --verbose'] | ||
|
|
||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Suffix example - supports multiple deployments per project | ||
| - id: suffix-example-init | ||
| waitFor: ['init-all'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSuffixExample --stage init --verbose'] | ||
| - id: suffix-example-apply | ||
| waitFor: ['suffix-example-init'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSuffixExample --stage apply --verbose'] | ||
| - id: suffix-example-verify | ||
| waitFor: ['suffix-example-apply'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSuffixExample --stage verify --verbose'] | ||
| - id: suffix-example-teardown | ||
| waitFor: ['suffix-example-verify'] | ||
| dir: infra | ||
| name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' | ||
| args: ['/bin/bash', '-c', 'cft test run TestSuffixExample --stage teardown --verbose'] | ||
| tags: | ||
| - 'ci' | ||
| - 'integration' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Simple Example | ||
|
|
||
| This example illustrates how to use the `dynamic-python-webapp` module. | ||
|
|
||
| This example uses a randomly generated suffix when naming resources to support multiple deployments per project. | ||
|
|
||
| <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | client\_job\_name | Client Cloud Run job name | | ||
| | firebase\_url | Firebase URL | | ||
| | server\_service\_name | Server Cloud Run service name | | ||
| | usage | Connection details for the project | | ||
|
|
||
| <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
|
||
| To provision this example, run the following from within this directory: | ||
| - `terraform init` to get the plugins | ||
| - `terraform plan` to see the infrastructure plan | ||
| - `terraform apply` to apply the infrastructure build | ||
| - `terraform destroy` to destroy the built infrastructure |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * Copyright 2023 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| module "dynamic-python-webapp" { | ||
| source = "../.." | ||
|
|
||
| project_id = var.project_id | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * Copyright 2023 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| output "usage" { | ||
| sensitive = true | ||
| description = "Connection details for the project" | ||
| value = module.dynamic-python-webapp.usage | ||
| } | ||
|
|
||
| output "firebase_url" { | ||
| description = "Firebase URL" | ||
| value = module.dynamic-python-webapp.firebase_url | ||
| } | ||
|
|
||
| output "server_service_name" { | ||
| description = "Server Cloud Run service name" | ||
| value = module.dynamic-python-webapp.server_service_name | ||
| } | ||
|
|
||
| output "client_job_name" { | ||
| description = "Client Cloud Run job name" | ||
| value = module.dynamic-python-webapp.client_job_name | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Copyright 2023 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| variable "project_id" { | ||
| description = "The ID of the project in which to provision resources." | ||
| type = string | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * Copyright 2023 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| terraform { | ||
| required_providers { | ||
| google = { | ||
| source = "hashicorp/google" | ||
| version = "~> 4.0" | ||
| } | ||
| } | ||
| required_version = ">= 0.13" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,13 @@ resource "google_cloud_run_v2_job" "client" { | |
| service_account = google_service_account.client.email | ||
| containers { | ||
| image = local.client_image | ||
|
|
||
| # Variables used to customise Firebase configuration on deployment | ||
| # https://github.com/GoogleCloudPlatform/avocano/blob/main/client/docker-deploy.sh | ||
| env { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. discussion: At first I found this variable's presence on the Cloud Run Jobs mysterious, and wondered if we should have inline comments linking to usage. But I'm not sure we want to try maintaining a list like that to be comprehensive. This is one of those pieces that hand-off to future maintainers might lose track how to handle changes.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added links to the script usage, which might help, but happy to do more |
||
| name = "SUFFIX" | ||
| value = var.random_suffix ? random_id.suffix.hex : "" | ||
| } | ||
| env { | ||
| name = "SERVICE_NAME" | ||
| value = google_cloud_run_v2_service.server.name | ||
|
|
@@ -154,6 +161,10 @@ resource "google_cloud_run_v2_job" "placeholder" { | |
| value = var.project_id | ||
| } | ||
|
|
||
| env { | ||
| name = "SUFFIX" | ||
| value = var.random_suffix ? random_id.suffix.hex : "" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.