+resource "null_resource" "cluster" {
+ provisioner "remote-exec" {
+ inline = ["sudo microk8s kubectl get no >> kubectl.info"]
+ }
+
+ connection {
+ host = aws_instance.master.public_ip
+ type = "ssh"
+ user = "ubuntu"
+ password = ""
+ private_key = "${file("terraform.pem")}"
+ }
+
+ provisioner "local-exec" {
+ command = <<EOT
+ echo ${aws_instance.master.private_ip}
+ export privateIP=${aws_instance.master.private_ip}
+ export publicIP=${aws_instance.master.public_ip}
+ ssh-keyscan -H ${aws_instance.worker.public_dns} >> ~/.ssh/known_hosts
+ scp -i terraform.pem ubuntu@${aws_instance.worker.public_dns}:/configFile-worker .
+ EOT
+ }
+
+ lifecycle {
+ create_before_destroy = true
+ }