-
Notifications
You must be signed in to change notification settings - Fork 101
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 #57 from imp14a/fix/automation-docs
terraform deployment docs
- Loading branch information
Showing
7 changed files
with
93 additions
and
13 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
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
REGION=$1 | ||
RUN_SA=$2 | ||
|
||
cp templates/config.toml ../backend_apis/app | ||
cp templates/Dockerfile ../backend_apis/ | ||
cd ../backend_apis | ||
gcloud run deploy genai-for-marketing --source . --allow-unauthenticated --region="${REGION}" --service-account="${RUN_SA}" |
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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
# Terraform deployment | ||
Terraform deployment simpliefies the deployment of this solution and can be used as blueprint of the solution, it includes all requirements in order to deploy in a single terraform scripts the. | ||
|
||
*Note*: Current version of the Terraform Google Cloud provider has not been updated to generate some of the GenAI resources, this soultion uses null_resource to create some resources using Google Cloud SDK. | ||
|
||
## Prerequisites: | ||
|
||
Previous to execute terraform you need to enable some services using the following steps: | ||
|
||
### Enable Firebase | ||
Will be used for the frontend deployment | ||
|
||
1. Go to https://console.firebase.google.com/ | ||
2. Select add project and load your Google Cloud Platform project | ||
|
@@ -11,23 +17,60 @@ | |
5. Continue and complete | ||
|
||
### Enable Vertex AI Agent Builder | ||
Required before start using App Builder services | ||
1. Go to https://console.cloud.google.com/gen-app-builder/start | ||
2. Accept TOS | ||
|
||
|
||
## Terraform deployment | ||
``` | ||
export USER_PROJECT_OVERRIDE=true | ||
export GOOGLE_BILLING_PROJECT=<your_project_id> | ||
|
||
From [Cloud Shell](https://cloud.google.com/shell/docs/using-cloud-shell) run the following commands: | ||
|
||
*Note*: This deployment requires Terraform 1.7 or higher | ||
|
||
```sh | ||
# move to the tf folder | ||
cd tf/ | ||
|
||
export USER_PROJECT_OVERRIDE=true | ||
export GOOGLE_BILLING_PROJECT=<your_project_id> | ||
|
||
terraform init | ||
terraform apply -var=project_id=<your_project_id> | ||
``` | ||
|
||
## After Terraform deployment | ||
1. Go to https://firebase.corp.google.com/project/genai-marketing-tf-test/authentication/providers | ||
### Terraform variables | ||
You can change any of the default variables values in [variables.tf](variables.tf). | ||
|
||
This terraform will generate all configurations files required in the frontend and backend_apis you need to change [variables.tf](variables.tf) values in order to change configuration if needed. | ||
|
||
### After Terraform deployment | ||
You need to enable at least one authentication provider in Firebase, you can enable it using the following steps: | ||
1. Go to https://firebase.corp.google.com/project/your_project_id/authentication/providers (change the your_project_id value) | ||
2. Select Google and enable it | ||
3. Set the name for the project and support email for project | ||
4. Save | ||
4. Save | ||
|
||
## Check your deployment | ||
Once deployment is completed terraform will output relevants resoruces values. | ||
|
||
Resulting example outputs: | ||
```sh | ||
backend_deployment = "https://genai-for-marketing-xxxxxxxx.a.run.app" | ||
backend_service_account = "[email protected]" | ||
frontend_deployment = "https://your-project-id.web.app" | ||
``` | ||
You can use the app by accessing to the frontend_deployment URL. | ||
|
||
### Deployed resources | ||
This deployment creates all the resources described in the main [README.md](../README.md) file, the following is a list of the created resources: | ||
- Required Google Cloud services | ||
- [BiqQuery](https://console.cloud.google.com/bigquery) Dataset and tables (populating tables with sample data) | ||
- Google Drive folder and templates files | ||
- [Service Account](https://console.cloud.google.com/iam-admin) with the required permissions | ||
- [Search engine and Chat engine](https://console.cloud.google.com/gen-app-builder) with datastores | ||
- [Cloud Run](https://console.cloud.google.com/run) for backend APIs | ||
- Firebase for frontend deployment | ||
|
||
### Configuration files | ||
This deployment uses the tempaltes in the [templates/](templates/) diractory to replace all necessary configuration values for the application. After the deployment is complete, you can review the resulting values in the config.tomal and enviroments.ts files. |
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
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
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
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,28 @@ | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
|
||
FROM python:3.11-slim | ||
|
||
# Allow statements and log messages to immediately appear in the Knative logs | ||
ENV PYTHONUNBUFFERED True | ||
ENV GOOGLE_CLOUD_PROJECT ${project_id} | ||
|
||
WORKDIR / | ||
COPY ./requirements.txt /requirements.txt | ||
RUN pip install --no-cache-dir --upgrade -r /requirements.txt | ||
|
||
COPY ./app /app | ||
|
||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"] |