Skip to content
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

Add: Initial version - custom repo path #331

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions solutions/la_generative_ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Terraform: Generative AI

Terraform configuration to create:

- [x] Enable Googleapis
- [x] Random generator
- [x] Service Account
- [x] Google Cloud Storage
- [x] IAM Google Cloud Storage
- [x] Local file configuration
- [x] Vertex AI Notebook instance


## Using Input Values

__NOTE:__ Qwiklabs requires some values to be defined as part of the provisioning process.

```
gcp_project_id = "my-gcp-project"
gcp_region = "us-central1"
gcp_zone = "us-central1-a"
```

## Accessing Output Values

| Field | Description |
|-------|-------------|
| N/A | N/A |

## 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.
21 changes: 21 additions & 0 deletions solutions/la_generative_ai/cloudbuild.yaml
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: solutions/generative-ai/stable
tags: ['terraform-lab-foundation', 'vertex', 'generative-ai', 'solutions']
83 changes: 83 additions & 0 deletions solutions/la_generative_ai/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Terraform: Generative AI

## Example

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
```

## 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/solutions/generative-ai/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.

## Update Qwiklabs Yaml

#### Custom Properties

The `qwiklabs.yaml` configuration file is used to set the optional definition of
custom properties e.g. `gcp_user_id`:

```
1 - type: gcp_project
2 id: project_0
3 variant: gcpd
4 ssh_key_user: user_0
5 startup_script:
6 type: qwiklabs
7 path: tf
8 custom_properties:
9 - key: gcp_user_id
10 reference: user_0.username
```

#### Visible Outputs

The `qwiklabs.yaml` configuration file is used to set the definition of
student visible outputs e.g. `GCP Username`

```
1 student_visible_outputs:
2 - label: "Open Google Console"
3 reference: project_0.console_url
4 - label: "GCP Username"
5 reference: user_0.username
6 - label: "GCP Password"
7 reference: user_0.password
```
50 changes: 50 additions & 0 deletions solutions/la_generative_ai/example/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
BRANCH="main"
CHANNEL="STABLE"
TYPE="solutions"
MODULE="generative-ai"

# Set the endpoint for the module
if [ "$CHANNEL" = "STABLE" ]; then
## STABLE Channel
URL="https://storage.googleapis.com/terraform-lab-foundation/"
# 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
25 changes: 25 additions & 0 deletions solutions/la_generative_ai/example/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# ------------------ Module Definition
#

# Solution: Generative AI environment
# Local: solutions/generative-ai/stable
# Remote: github//solutions/generative-ai/stable

module "sme_generative_ai" {
## NOTE: When changing the `source` parameter
## `terraform init` is required

## REMOTE: GitHub (Public) access - working
source = "github.com/CloudVLab/terraform-lab-foundation//solutions/generative-ai/stable"

## Exchange values between Qwiklabs and Module
gcp_project_id = var.gcp_project_id
gcp_region = var.gcp_region
gcp_zone = var.gcp_zone
gcp_user_id = var.gcp_user_id

# Set the source repository
sme_git_repo = "https://github.com/CloudVLab/generative-ai.git"
}

4 changes: 4 additions & 0 deletions solutions/la_generative_ai/example/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## --------------------------------------------------------------
## Custom variable defintions
## --------------------------------------------------------------

2 changes: 2 additions & 0 deletions solutions/la_generative_ai/example/runtime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runtime: terraform
version: 1.0.1
23 changes: 23 additions & 0 deletions solutions/la_generative_ai/example/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# ------------------ Qwiklabs Values
#
variable "gcp_project_id" {
type = string
}

variable "gcp_region" {
type = string
}

variable "gcp_zone" {
type = string
}

variable "gcp_user_id" {
type = string
}

#
#
# ------------------ Custom Properties
#
Loading