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

chore: Init clickops #124

Merged
merged 5 commits into from
May 28, 2024
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
59 changes: 59 additions & 0 deletions .github/workflows/handler-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Pull Request Test Handler

on:
repository_dispatch:
types:
- test-command

env:
GOOGLE_SERVICE_ACCOUNT: "[email protected]"

jobs:
public-dns-with-cloud-dns:
name: Public DNS with Cloud DNS
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: "~1"

- name: Install k6 for load testing
env:
K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz
run: |
sudo apt-get install jq
curl -L $K6_URL | tar -xz --strip-components=1

- name: Authenticate with Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GOOGLE_TESTING_SA_CREDENTIALS }}"

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"

- name: Terraform Init
id: init
run: terraform init -input=false -no-color

- name: Terraform Validate
id: validate
run: terraform validate -no-color

- name: Retrieve Health Check URL
id: retrieve-health-check-url
run: |
terraform output -no-color -raw health_check_url

- name: Terraform Destroy
id: destroy
if: ${{ always() }}
run: terraform destroy -auto-approve -input=false -no-color
24 changes: 24 additions & 0 deletions .github/workflows/tf-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Terraform Lint Check

on: [push]

jobs:
tflint:
name: Run tflint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: "~1"

- name: Install tflint
run: |
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

- name: Run tflint
run: tflint
35 changes: 17 additions & 18 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ module "project_factory_project_services" {
}

locals {
fqdn = var.subdomain == null ? var.domain_name : "${var.subdomain}.${var.domain_name}"
url_prefix = var.ssl ? "https" : "http"
url = "${local.url_prefix}://${local.fqdn}"
internal_app_port = 32543
create_bucket = var.bucket_name == ""
create_network = var.network == null
fqdn = var.subdomain == null ? var.domain_name : "${var.subdomain}.${var.domain_name}"
url_prefix = var.ssl ? "https" : "http"
url = "${local.url_prefix}://${local.fqdn}"
create_bucket = var.bucket_name == ""
create_network = var.network == null
}

module "service_accounts" {
Expand All @@ -45,7 +44,7 @@ module "kms" {
}

locals {
crypto_key = var.use_internal_queue ? null : module.kms.0.crypto_key
crypto_key = var.use_internal_queue ? null : module.kms[0].crypto_key
}

module "storage" {
Expand All @@ -72,9 +71,9 @@ module "networking" {
}

locals {
network_connection = try(module.networking.0.connection, { network = var.network })
network = try(module.networking.0.network, { self_link = var.network })
subnetwork = try(module.networking.0.subnetwork, { self_link = var.subnetwork })
network_connection = try(module.networking[0].connection, { network = var.network })
network = try(module.networking[0].network, { self_link = var.network })
subnetwork = try(module.networking[0].subnetwork, { self_link = var.subnetwork })
}

module "app_gke" {
Expand Down Expand Up @@ -128,10 +127,10 @@ module "redis" {
}

locals {
redis_certificate = var.create_redis ? module.redis.0.ca_cert : null
redis_connection_string = var.create_redis ? "redis://:${module.redis.0.auth_string}@${module.redis.0.connection_string}?tls=true&ttlInSeconds=604800&caCertPath=/etc/ssl/certs/server_ca.pem" : null
bucket = local.create_bucket ? module.storage.0.bucket_name : var.bucket_name
bucket_queue = var.use_internal_queue ? "internal://" : "pubsub:/${module.storage.0.bucket_queue_name}"
redis_certificate = var.create_redis ? module.redis[0].ca_cert : null
redis_connection_string = var.create_redis ? "redis://:${module.redis[0].auth_string}@${module.redis[0].connection_string}?tls=true&ttlInSeconds=604800&caCertPath=/etc/ssl/certs/server_ca.pem" : null
bucket = local.create_bucket ? module.storage[0].bucket_name : var.bucket_name
bucket_queue = var.use_internal_queue ? "internal://" : "pubsub:/${module.storage[0].bucket_queue_name}"
project_id = module.project_factory_project_services.project_id
secret_store_source = "gcp-secretmanager://${local.project_id}?namespace=${var.namespace}"
}
Expand Down Expand Up @@ -218,10 +217,10 @@ module "wandb" {
}

redis = var.create_redis ? {
password = module.redis.0.auth_string
host = module.redis.0.host
port = module.redis.0.port
caCert = module.redis.0.ca_cert
password = module.redis[0].auth_string
host = module.redis[0].host
port = module.redis[0].port
caCert = module.redis[0].ca_cert
params = {
tls = true
ttlInSeconds = 604800
Expand Down
Loading