diff --git a/README.md b/README.md index d7f8c43..fab5b87 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,12 @@ ssh-keygen -t rsa -b 4096 ## UTILISATION -- Lançer Terraform: +- Initialiser Terraform: ```bash terraform init ``` -- Lançer Terraform: +- Dry run: ```bash terraform plan ``` diff --git a/main.tf b/main.tf index 5eb1203..5a2e406 100644 --- a/main.tf +++ b/main.tf @@ -79,35 +79,35 @@ resource "google_compute_instance" "default" { ### COPY DES FICHIERS provisioner "file" { - source = "app/" - destination = "./" - connection { - host = google_compute_instance.default.network_interface.0.access_config.0.nat_ip - type = "ssh" - user = var.gcp_ssh_user - timeout = "500s" - private_key = "${file(var.gcp_ssh_priv_key_file)}" - } + source = "app/" + destination = "./" + connection { + host = google_compute_instance.default.network_interface.0.access_config.0.nat_ip + type = "ssh" + user = var.gcp_ssh_user + timeout = "500s" + private_key = file(var.gcp_ssh_priv_key_file) + } } ### START DEPLOY.SH provisioner "remote-exec" { - inline = [ - "chmod +x ~/deploy.sh", - "cd ~", - "./deploy.sh" - ] - connection { - host = google_compute_instance.default.network_interface.0.access_config.0.nat_ip - type = "ssh" - user = var.gcp_ssh_user - timeout = "500s" - private_key = "${file(var.gcp_ssh_priv_key_file)}" - } + inline = [ + "chmod +x ~/deploy.sh", + "cd ~", + "./deploy.sh" + ] + connection { + host = google_compute_instance.default.network_interface.0.access_config.0.nat_ip + type = "ssh" + user = var.gcp_ssh_user + timeout = "500s" + private_key = file(var.gcp_ssh_priv_key_file) + } } } ## GET VM PUBLIC IP output "Web-server-URL" { - value = join("",["http://",google_compute_instance.default.network_interface.0.access_config.0.nat_ip,":5000"]) + value = join("", ["http://", google_compute_instance.default.network_interface.0.access_config.0.nat_ip, ":5000"]) } \ No newline at end of file diff --git a/terraform.tfvars b/terraform.tfvars index 43dbfe5..0c9cfeb 100644 --- a/terraform.tfvars +++ b/terraform.tfvars @@ -1,8 +1,8 @@ # GCP Settings -gcp_project_id = "terraform-demo-381114" # A MODIFIER -gcp_region = "europe-west9" -gcp_zone = "europe-west9-a" -gcp_auth_file = "./auth/terraform-demo-381114-158cfce10778.json" # A MODIFIER -gcp_ssh_user = "devops" # A MODIFIER OU PAS -gcp_ssh_pub_key_file = "~/.ssh/terraform.pub" +gcp_project_id = "terraform-demo-381114" # A MODIFIER +gcp_region = "europe-west9" +gcp_zone = "europe-west9-a" +gcp_auth_file = "./auth/terraform-demo-381114-158cfce10778.json" # A MODIFIER +gcp_ssh_user = "devops" # A MODIFIER OU PAS +gcp_ssh_pub_key_file = "~/.ssh/terraform.pub" gcp_ssh_priv_key_file = "~/.ssh/terraform" \ No newline at end of file diff --git a/variables.tf b/variables.tf index fe7f9ac..f88274e 100644 --- a/variables.tf +++ b/variables.tf @@ -24,15 +24,15 @@ variable "gcp_zone" { variable "gcp_ssh_user" { type = string - description = "SSH user" + description = "SSH user" } variable "gcp_ssh_pub_key_file" { type = string - description = "SSH public key file path" + description = "SSH public key file path" } variable "gcp_ssh_priv_key_file" { type = string - description = "SSH private key file path" + description = "SSH private key file path" } \ No newline at end of file