Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29450

terraform) how to stop instance after running script(inline)?

$
0
0

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.


Viewing all articles
Browse latest Browse all 29450

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>