hashicorp / terraform-getting-started-gcp-cloud-shell

Getting Started Guide for Terraform and Google Cloud Platform using a Google Cloud Shell tutorial
Mozilla Public License 2.0
22 stars 33 forks source link

Error during the tutorial setup #12

Open glodov opened 2 years ago

glodov commented 2 years ago

Right from the very start it does not work. :(

-bash: [[: /etc/profile.d/customize_environment.sh: syntax error: operand expected (error token is "/etc/profile.d/customize_environment.sh")
Welcome to Cloud Shell! Type "help" to get started.
To set your Cloud Platform project in this session use “gcloud config set project [PROJECT_ID]”
i@cloudshell:~$ cloudshell_open --repo_url "https://github.com/hashicorp/terraform-getting-started-gcp-cloud-shell" --dir "tutorial/" --page "editor" --tutorial "./cloudshell_tutorial.md" --open_in_editor "./main.tf" --git_branch "main" --force_new_clone
2022/08/25 17:47:13 Cloning https://github.com/hashicorp/terraform-getting-started-gcp-cloud-shell into /home/i/cloudshell_open/terraform-getting-started-gcp-cloud-shell
Cloning into '/home/i/cloudshell_open/terraform-getting-started-gcp-cloud-shell'...
fatal: Remote branch main not found in upstream origin
2022/08/25 17:47:14 failed to resolve path '/home/i/cloudshell_open/terraform-getting-started-gcp-cloud-shell': No such file or directory
Error occured

File /etc/profile.d/customize_environment.sh:

#!/bin/bash
if [[ ! "$USER" -eq "root" ]]; then
  return
fi

if [[ -f "/google/devshell/customize_environment_start" ]]; then
  return
fi

function reportEvent {
  if [[ -z "$USER_EMAIL" ]]; then
    return
  fi
  curl -s -o /dev/null "https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/log?key=AIzaSyBTrp02tPmZTE55uVehXtbFKUGnoUcmsbM" --header "Content-Type: application/json" --request POST --data "{
  client_info: {
    client_type: 'DESKTOP'
  },
  log_source: 'CONCORD',
  log_event: {
    event_time_ms: `date +%s%N | cut -b1-13`,
    source_extension_json_proto3: \"{
      'client_email': \\"$USER_EMAIL\\",
      'console_type': 'HEKATE_DEVSHELL',
      'event_name': \\"$1\\",
    }\"
  },
  }"
}

if [[ -f "$HOME/.customize_environment" ]]; then
  sudo touch /var/log/customize_environment
  reportEvent "customizeEnvironment" &
  sudo chmod a+rw /var/log/customize_environment
  sudo touch /google/devshell/customize_environment_start
  sudo chmod a+r /google/devshell/customize_environment_start
  (((sudo bash $HOME/.customize_environment &> /var/log/customize_environment) && (sudo touch /google/devshell/customize_environment_done && sudo chmod a+r /google/devshell/customize_environment_done && reportEvent "customizeEnvironmentDone")) || true) &
fi
jlenuffgsoi commented 2 years ago

In the URL https://console.cloud.google.com/cloudshell/open?cloudshell_image=gcr.io/graphite-cloud-shell-images/terraform:latest&cloudshell_git_repo=https://github.com/hashicorp/terraform-getting-started-gcp-cloud-shell&cloudshell_git_branch=main&cloudshell_working_dir=tutorial/&open_in_editor=./main.tf&cloudshell_tutorial=./cloudshell_tutorial.md, just change cloudshell_git_branch=main into cloudshell_git_branch=master.

So the link becomes https://console.cloud.google.com/cloudshell/open?cloudshell_image=gcr.io/graphite-cloud-shell-images/terraform:latest&cloudshell_git_repo=https://github.com/hashicorp/terraform-getting-started-gcp-cloud-shell&cloudshell_git_branch=master&cloudshell_working_dir=tutorial/&open_in_editor=./main.tf&cloudshell_tutorial=./cloudshell_tutorial.md.