forked from AvasDream/terraform_hacking_lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
25 lines (23 loc) · 843 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Define the AWS Instance
*/
data "template_file" "install_script" {
/* File template for the install script */
template = "${file("install_lab.sh")}"
}
resource "aws_instance" "hacking-lab-server" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "${var.instance_type}"
vpc_security_group_ids = ["${aws_security_group.allow_connections_hacking_lab.id}"]
/* Specify SSH Key Name for login */
key_name = "${var.ssh_key_name}"
/* Include Bash file and execute */
user_data = "${data.template_file.install_script.rendered}"
tags = {
Name = "hacking-lab-server"
}
/* This local exec is just for convenience and opens the ssh sessio. */
provisioner "local-exec" {
command = "echo putty -ssh ubuntu@${aws_instance.hacking-lab-server.public_ip} 22 -i '${var.ssh_key_path}'"
}
}