Ensure you are logged into both GCP & Azure systems from your CLI before executing below terraform commands.
gcloud auth login
gcloud auth application-default login
List projects and choose one.
gcloud projects list
gcloud config set project <PROJECT_NAME>
gcloud config list
az account show
Connect to Azure systems from GCP Cloud. In this example, we will use GCP VM to connect with Azure resources.
export GCP_PROJECT_NAME=$(gcloud config list --format="value(core.project)")
terraform init
terraform plan -var gcp_project_name=$GCP_PROJECT_NAME
terraform apply -var gcp_project_name=$GCP_PROJECT_NAME
Post terraform apply
, copy the ssh command from the output and login to the GCP VM.
- Some pre-requisities will be installed
- Connectivity to the Azure systems will be established
- Test it by running the command shown.
It's observed sometimes, GCP VMs aren't executing the scripts in /etc/profile.d/
on first ssh login. If that happens with you, there are two ways to fix it.
- Exit the shell and run the
gcloud ssh
command again. - Manually, run the script that will configure the shell to connect with Azure services -
bash /etc/profile.d/set_env_vars.sh
terraform destroy -var gcp_project_name=$GCP_PROJECT_NAME