Deploy simple web server provided by nginx in debian 10 to google cloud platform using terraform.
-
prerequisites installation
- Google Cloud Platform
- create a project
- install Google Cloud SDK
- authenticate yourself
- install Terraform
- Google Cloud Platform
-
environment configuration
cat <<EOS > ~/.gcp export GCP_PROJECT_ID=<your GCP project name> export GCP_ACCOUNT_FILE=~/.config/gcloud/legacy_credentials/<your@email.com>/adc.json export GCP_ZONE=europe-west3-b export GCP_REGION=europe-west3 export TF_VAR_gcp_zone="\$GCP_ZONE" export TF_VAR_gcp_credentials="\$GCP_ACCOUNT_FILE" export TF_VAR_gcp_project_id="\$GCP_PROJECT_ID" export TF_VAR_gcp_region="\$GCP_REGION" EOS # secure the file chmod 0600 ~/.gcp # load the file source ~/.gcp
-
clone this repository and
cd
into it -
create SSH key pair
ssh-keygen -t rsa -b 4096 -C "terraform" -f ./ssh/key
-
configure terraform variables (set your custom values)
# create variable file cp .terraform.tfvars.example terraform.tfvars # set custom variable values vi terraform.tfvars
-
deployment
# download module(s) terraform init # deploy terraform apply