I create 30 instance to run crawl script, but I have no idea how to stop instances created by terraform command. Please see my main.tf
code below:
resource "aws_instance""crawl_worker" {
ami = "${var.ami_id}"
instance_type = "t3a.nano"
security_groups = ["${var.aws_security_group}"]
key_name = "secret"
count = 10
tags = {
Name = "crawl_worker_${count.index}"
}
connection {
type = "ssh"
host = "${self.public_ip}"
user = "ubuntu"
private_key = "${file("~/secret.pem")}"
timeout = "50m"
}
provisioner "remote-exec" {
inline = [
"python3 aws_crawl.py"
]
}
}
I want to stop aws instances after complete running this command python3 aws_crawl.py
, but I cannot find stop current aws instance by command line.