-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amanpruthi
committed
Jun 18, 2024
1 parent
9f8c0b0
commit 3165d29
Showing
1 changed file
with
15 additions
and
39 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 |
---|---|---|
@@ -1,53 +1,29 @@ | ||
data "google_client_config" "current" {} | ||
|
||
# Module to manage gcloud | ||
# module "gcloud" { | ||
# source = "terraform-google-modules/gcloud/google" | ||
# version = "~> 3.4" | ||
# platform = "linux" | ||
# create_cmd_entrypoint = "gcloud" | ||
# create_cmd_body = "compute forwarding-rules list --format=json > lb_details.json" | ||
# } | ||
|
||
# Fetch Load Balancer Details using gcloud module | ||
resource "null_resource" "fetch_lb_details" { | ||
resource "null_resource" "install_dependencies" { | ||
provisioner "local-exec" { | ||
command = <<EOT | ||
ls -lrt | ||
gcloud version | ||
# Download and install jq | ||
curl -o jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 | ||
chmod 0755 jq | ||
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-387.0.0-linux-x86_64.tar.gz | ||
tar -xf google-cloud-cli-387.0.0-linux-x86_64.tar.gz | ||
./google-cloud-sdk/install.sh -q | ||
/bin/bash /home/tfc-agent/.tfc-agent/component/terraform/runs/run-KruyrUQKD98yfjEf/config/services/deployer/terraform/deploy/google/single-tenant/google-cloud-sdk/path.bash.inc | ||
echo $GOOGLE_CREDENTIALS | ||
echo $GOOGLE_CREDENTIALS > creds.json | ||
echo "printing creds" | ||
cat creds.json | ||
google-cloud-sdk/bin/gcloud auth activate-service-account [email protected] --key-file=creds.json --project=wandb-qa | ||
google-cloud-sdk/bin/gcloud compute forwarding-rules list --format=json > lb_details.json | ||
cat lb_details.json | jq -r '.[] | select(.name | test("${var.namespace}-internal")) | .name' > filtered_lb_names.txt | ||
EOT | ||
} | ||
} | ||
|
||
# resource "null_resource" "install_dependencies" { | ||
# provisioner "local-exec" { | ||
# command = <<EOT | ||
# # Download and install jq | ||
# curl -o jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 | ||
# chmod 0755 jq | ||
# # # Download and install gcloud SDK | ||
# # curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-387.0.0-linux-x86_64.tar.gz | ||
# # tar -xf google-cloud-cli-387.0.0-linux-x86_64.tar.gz | ||
# # ./google-cloud-sdk/install.sh -q | ||
# # which gcloud | ||
# EOT | ||
# } | ||
# } | ||
|
||
|
||
# resource "null_resource" "fetch_lb_details" { | ||
# provisioner "local-exec" { | ||
# command = <<EOT | ||
# cat lb_details.json | jq -r '.[] | select(.name | test("${var.namespace}-internal")) | .name' > filtered_lb_names.txt | ||
# EOT | ||
# } | ||
# depends_on = [null_resource.install_dependencies] | ||
# } | ||
|
||
data "external" "filtered_lb_names" { | ||
program = ["sh", "-c", "cat filtered_lb_names.txt | jq -R -s '{\"load_balancer_name\": .}'"] | ||
depends_on = [null_resource.fetch_lb_details] | ||
depends_on = [null_resource.install_dependencies] | ||
} | ||
|
||
locals { | ||
|