|
| 1 | +--- |
| 2 | +title: GCP Google Cloud Platform - Install CLI Tools |
| 3 | +description: Learn to install cli tools required for using Terraform on GCP |
| 4 | +--- |
| 5 | + |
| 6 | +## Step-01: Introduction |
| 7 | +1. Install gcloud CLI |
| 8 | +2. Install Terraform CLI |
| 9 | +3. Install VSCode Editor |
| 10 | +4. Install Terraform Pluging for VSCode |
| 11 | +5. Implement above 4 steps in both MacOS and WindowsOS |
| 12 | + |
| 13 | +## Step-02: MacOS: Install gcloud cli and verify |
| 14 | +### Step-02-01: Install gcloud cli |
| 15 | +- [Install gcloud cli](https://cloud.google.com/sdk/docs/install-sdk#mac) |
| 16 | +```t |
| 17 | +# Verify Python Version (Supported versions are Python 3 (3.5 to 3.11, 3.11 recommended) |
| 18 | +python3 -V |
| 19 | + |
| 20 | +# Determine your machine hardware |
| 21 | +uname -m |
| 22 | + |
| 23 | +# Create Folder |
| 24 | +mkdir gcloud-cli-software |
| 25 | +cd gcloud-cli-software |
| 26 | + |
| 27 | +# Download gcloud cli based on machine hardware |
| 28 | +## Important Note: Download the latest version available on that respective day |
| 29 | +Dowload Link: https://cloud.google.com/sdk/docs/install-sdk#mac |
| 30 | + |
| 31 | +## As on today the below is the latest version (x86_64 bit) |
| 32 | +curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-479.0.0-darwin-x86_64.tar.gz |
| 33 | + |
| 34 | +# Unzip binary |
| 35 | +ls -lrta |
| 36 | +tar -zxf google-cloud-cli-479.0.0-darwin-x86_64.tar.gz |
| 37 | +cd |
| 38 | + |
| 39 | +# Run the install script with screen reader mode on: |
| 40 | +./google-cloud-sdk/install.sh --screen-reader=true |
| 41 | +``` |
| 42 | + |
| 43 | +### Step-02-02: Verify gcloud cli version |
| 44 | +```t |
| 45 | +# Open new terminal |
| 46 | +AS PATH is updated, open new terminal |
| 47 | + |
| 48 | +# gcloud cli version |
| 49 | +gcloud version |
| 50 | +``` |
| 51 | + |
| 52 | +### Step-02-03: Intialize gcloud CLI in local Terminal |
| 53 | +```t |
| 54 | +# Initialize gcloud CLI |
| 55 | +./google-cloud-sdk/bin/gcloud init |
| 56 | + |
| 57 | +# List accounts whose credentials are stored on the local system: |
| 58 | +gcloud auth list |
| 59 | + |
| 60 | +# List the properties in your active gcloud CLI configuration |
| 61 | +gcloud config list |
| 62 | + |
| 63 | +# View information about your gcloud CLI installation and the active configuration |
| 64 | +gcloud info |
| 65 | + |
| 66 | +# gcloud config Configurations Commands (For Reference) |
| 67 | +gcloud config list |
| 68 | +gcloud config configurations list |
| 69 | +gcloud config configurations activate |
| 70 | +gcloud config configurations create |
| 71 | +gcloud config configurations delete |
| 72 | +gcloud config configurations describe |
| 73 | +gcloud config configurations rename |
| 74 | + |
| 75 | +# Configure GCP Credentials (ADC: Application Default Credentials) |
| 76 | +# IMPORTANT: MANDATORY FOR TERRAFORM COMMANDS TO WORK WITH GCP FROM OUR LOCAL TERMINAL |
| 77 | +gcloud auth application-default login |
| 78 | +``` |
| 79 | + |
| 80 | +### Step-02-04: Install Terraform CLI using Homebrew |
| 81 | +- [Download Packages](https://developer.hashicorp.com/terraform/install#darwin) |
| 82 | +- [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/install-cli) |
| 83 | +```t |
| 84 | +# Install the Hashicorp tap |
| 85 | +brew tap hashicorp/tap |
| 86 | + |
| 87 | +# Install terraform |
| 88 | +brew install hashicorp/tap/terraform |
| 89 | + |
| 90 | +# Update to the latest version of Terraform |
| 91 | +brew update |
| 92 | +brew upgrade hashicorp/tap/terraform |
| 93 | +``` |
| 94 | + |
| 95 | +### Step-02-05: Install Terraform CLI - Manually |
| 96 | +- [Download Packages](https://developer.hashicorp.com/terraform/install#darwin) |
| 97 | +- [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/install-cli) |
| 98 | +```t |
| 99 | +# Copy binary zip file to a folder |
| 100 | +mkdir /Users/<YOUR-USER>/Documents/terraform-install |
| 101 | +COPY Package to "terraform-install" folder |
| 102 | + |
| 103 | +# Unzip |
| 104 | +unzip <PACKAGE-NAME> |
| 105 | +unzip terraform_1.8.5_darwin_amd64.zip |
| 106 | + |
| 107 | +# Copy terraform binary to /usr/local/bin |
| 108 | +echo $PATH |
| 109 | +mv terraform /usr/local/bin |
| 110 | + |
| 111 | +# Verify Version |
| 112 | +terraform version |
| 113 | + |
| 114 | +# To Uninstall Terraform (NOT REQUIRED) |
| 115 | +rm -rf /usr/local/bin/terraform |
| 116 | +``` |
| 117 | + |
| 118 | +### Step-02-06: MACOS: IDE for Terraform - VS Code Editor |
| 119 | +- [Microsoft Visual Studio Code Editor](https://code.visualstudio.com/download) |
| 120 | +- [Hashicorp Terraform Plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform) |
| 121 | + |
| 122 | + |
| 123 | +## Step-03: WindowsOS: Install gcloud cli and verify |
| 124 | +### Step-03-01: Install gcloud cli on WindowsOS |
| 125 | +- [Install gcloud cli on WindowsOS](https://cloud.google.com/sdk/docs/install-sdk#windows) |
| 126 | +```t |
| 127 | +## Important Note: Download the latest version available on that respective day |
| 128 | +Dowload Link: https://cloud.google.com/sdk/docs/install-sdk#windows |
| 129 | + |
| 130 | +## Run the Installer |
| 131 | +GoogleCloudSDKInstaller.exe |
| 132 | +``` |
| 133 | + |
| 134 | +### Step-03-02: Verify gcloud cli version |
| 135 | +```t |
| 136 | +# gcloud cli version |
| 137 | +gcloud version |
| 138 | +``` |
| 139 | + |
| 140 | +### Step-03-03: Intialize gcloud CLI in local Terminal |
| 141 | +```t |
| 142 | +# Initialize gcloud CLI |
| 143 | +gcloud init |
| 144 | + |
| 145 | +# List accounts whose credentials are stored on the local system: |
| 146 | +gcloud auth list |
| 147 | + |
| 148 | +# List the properties in your active gcloud CLI configuration |
| 149 | +gcloud config list |
| 150 | + |
| 151 | +# View information about your gcloud CLI installation and the active configuration |
| 152 | +gcloud info |
| 153 | + |
| 154 | +# gcloud config Configurations Commands (For Reference) |
| 155 | +gcloud config list |
| 156 | +gcloud config configurations list |
| 157 | +gcloud config configurations activate |
| 158 | +gcloud config configurations create |
| 159 | +gcloud config configurations delete |
| 160 | +gcloud config configurations describe |
| 161 | +gcloud config configurations rename |
| 162 | + |
| 163 | +# Configure GCP Credentials (ADC: Application Default Credentials) |
| 164 | +gcloud auth application-default login |
| 165 | +``` |
| 166 | + |
| 167 | +### Step-03-04: Install Terraform CLI |
| 168 | +- [Download Terraform](https://developer.hashicorp.com/terraform/install#windows) |
| 169 | +- [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/install-cli) |
| 170 | +```t |
| 171 | +# Install the Hashicorp tap |
| 172 | +choco install terraform |
| 173 | +``` |
| 174 | +- Unzip the package |
| 175 | +- Create new folder `terraform-bins` |
| 176 | +- Copy the `terraform.exe` to a `terraform-bins` |
| 177 | +- Set PATH in windows |
| 178 | + |
| 179 | +### Step-03-05: Windows: IDE for Terraform - VS Code Editor |
| 180 | +- [Microsoft Visual Studio Code Editor](https://code.visualstudio.com/download) |
| 181 | +- [Hashicorp Terraform Plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform) |
| 182 | + |
| 183 | + |
| 184 | + |
0 commit comments