🚀 NOTE TO READER: If you feel something could be better, written more clearly and in more understandable way, please feel free to fork and do a PR. All the approriate changes are accepted and welcomed.🚀
This documentation aims to help use get start with terraform on different cloud providers.
Please install following on your computer before we get started:
- Python 3.5 or 3.7
- Install google cloud sdk
- Install terraform
-
Make sure your python is installed and running Use:
python -v
-
Make sure gcloud is installed and running Use:
gcloud -v
-
Make sure terraform is installed and running Use :
terraform --help
-
(Optional) Install terraform autocomplete Use :
terraform -install-autocomplete
Before you start make sure you already have signed up for google cloud service.
- Login into GCP using command
gcloud auth application-default login
. This will open browser asking which account you want to use. - Provide google auth library to access google account.
- Check projects associated with given account using
gcloud projects list
- There might be default project created automatically.
- Create gcloud service account using command
gcloud iam service-accounts create terraform-admin --display-name "Terraform Gcloud"
- verify the service account using command
gcloud iam service-accounts list
- Download service account key using command
gcloud iam service-accounts keys create ~/terraform-admin.json --iam-account SERVICE_ACCOUNT_EMAIL
- Go to gcp console > IAM > service accounts to verify id your service account has been created or not.
- You can list projects using
gcloud projects list
- Select which project to use using command
gcloud config set project project ID
- In order for service account to make changes to google cloud console, we need to add role. Let's try to give editor role to service account.Use this command to provide editor role to service account created above.
gcloud projects add-iam-policy-binding PROJECT ID --member "serviceAccount:SERVICE ACCOUNT EMAIL" --role "roles/editor"
- Now, go and verify in google cloud console to see if service account as been associated with IAM role.
- Active service account created above using command
gcloud auth activate-service-account SERVICE_ACCOUNT_EMAIL --key-file=PATH_TO_SERVICE_ACCOUNT_KEY DOWNLOADED
- We will be using this service account to interact with GCP console