So I'm familiar with Terraform and have built environments on AWS with it. I have a new project on google cloud and I'm having an issue (or misunderstanding) on how to get my provisioning scripts/steps into an autoscaling group.
Terraform v0.7.13
resource "google_compute_instance_template" "events_service_template" {
name = "${var.environment}-events-service-template"
machine_type = "${var.machine_type}"
can_ip_forward = false
tags = []
disk {
source_image = "ubuntu-os-cloud/ubuntu-1404-lts"
disk_type = "pd-ssd"
disk_size_gb = "30"
auto_delete = true
boot = true
}
network_interface {
network = "default"
}
metadata {
ssh-keys = "root:${file("${var.public_key_path}")}"
}
service_account {
scopes = ["https://www.googleapis.com/auth/compute.readonly"]
}
provisioner "file" {
source = "scripts/startup.sh"
destination = "/root/startup.sh"
connection {
type = "ssh"
user = "root"
private_key = "${file("${var.private_key_path}")}"
agent = false
}
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "root"
private_key = "${file("${var.private_key_path}")}"
agent = false
}
inline = [
"chmod +x /root/startup.sh",
"/root/startup.sh"
]
}
}
Error applying plan:
1 error(s) occurred:
* ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
I used a modified version of the google two-tier example.
google_compute_instance_template is a resource to define a template, not an VM. google_compute_instance is a resource to create a VM.
You're referring to google two-tier example, it uses google_compute_instance resource - https://github.com/hashicorp/terraform/blob/master/examples/google-two-tier/main.tf#L30
I think what people were trying to do is:
google_compute_instance_template.provisioners defined in google_compute_instance_template to provision a VM image as the image for instance group.google_compute_instance_group_manager to deploy VMs in an instance group. This will allow you to take advantage of the autoscaling feature.This is simply not possible right now. But, it makes sense to have feature like this.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
I think what people were trying to do is:
google_compute_instance_template.provisionersdefined ingoogle_compute_instance_templateto provision a VM image as the image for instance group.google_compute_instance_group_managerto deploy VMs in an instance group. This will allow you to take advantage of the autoscaling feature.This is simply not possible right now. But, it makes sense to have feature like this.