GoogleCloudPlatform / terraform-example-foundation-app

https://registry.terraform.io/modules/GoogleCloudPlatform/terraform-example-foundation-app/google
Apache License 2.0
33 stars 36 forks source link

Advise and explain how to create a script to set all environment variables to step 6-anthos-install. #93

Closed vfigueiredo-cit closed 1 year ago

vfigueiredo-cit commented 3 years ago

Expected Behavior

Create a script to set all required environment variables to step 6-anthos-install. As there are many variables and you may have to restart bastion a few times during the deploy, setting all of them manually every time is a lot of work.

Actual Behavior

All environment variables are set manually.

Steps to Reproduce the Problem

1. 1. 1.

Suggestion

  1. Made a scrip named variables.sh:

    nano variables.sh
  2. Update the file with the variables and save:

    export GKE_PROJECT_ID=$(gcloud config get-value project)
    export PROJECT_NUM=$(gcloud projects describe ${GKE_PROJECT_ID} --format='value(projectNumber)')
    export CLUSTER_1=gke-1-boa-d-us-east1
    export CLUSTER_1_REGION=us-east1
    export CLUSTER_2=gke-2-boa-d-us-west1
    export CLUSTER_2_REGION=us-west1
    export CLUSTER_INGRESS=mci-boa-d-us-east1
    export CLUSTER_INGRESS_REGION=us-east1
    export WORKLOAD_POOL=${GKE_PROJECT_ID}.svc.id.goog
    export MESH_ID="proj-${PROJECT_NUM}"
    export ASM_VERSION=1.8
    export ISTIO_VERSION=1.8.6-asm.3
    export ASM_LABEL=asm-186-3
    export CTX_1=gke_${GKE_PROJECT_ID}_${CLUSTER_1_REGION}_${CLUSTER_1}
    export CTX_2=gke_${GKE_PROJECT_ID}_${CLUSTER_2_REGION}_${CLUSTER_2}
    export CTX_INGRESS=gke_${GKE_PROJECT_ID}_${CLUSTER_INGRESS_REGION}_${CLUSTER_INGRESS}
    export CICD_PROJECT_ID=YOUR_CICD_PROJECT_ID
    export SQL_PROJECT_ID=YOUR_SQL_PROJECT_ID
    export SQL_INSTANCE_NAME_EAST=YOUR_SQL_INSTANCE_NAME_EAST
    export SQL_INSTANCE_NAME_WEST=YOUR_SQL_INSTANCE_NAME_WEST
    #Those below will only be needed later in the deploy
    export INGRESS_CONFIG_URI=$(gcloud container clusters list --uri | grep ${CLUSTER_INGRESS})
    export CLUSTER_1_URI=$(gcloud container clusters list --uri | grep ${CLUSTER_1})
    export CLUSTER_2_URI=$(gcloud container clusters list --uri | grep ${CLUSTER_2})
    export CICD_PROJECT_ID=YOUR_CICD_PROJECT_ID
  3. Make executable:

    chmod 777 variables.sh
  4. To run the script:

    source ./variables.sh

Specifications

rutalreja-deloitte commented 1 year ago

These variables are highly dependent on the terraform outputs of the previous steps, the gcloud commands also assumes you are in the correct project. This will never consistently work for everyone hence there is no advantage hiding this behind a shell script.

The intention is to have it in the Readme to bring attention to it so every user running these statements, does a sanity check and executes them.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days