mirror of
https://github.com/farcasclaudiu/terraform-course.git
synced 2026-06-29 01:02:16 +03:00
demo-2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
resource "aws_key_pair" "mykey" {
|
||||
key_name = "mykey"
|
||||
public_key = "${file("${var.PATH_TO_PUBLIC_KEY}")}"
|
||||
}
|
||||
|
||||
resource "aws_instance" "example" {
|
||||
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
|
||||
instance_type = "t2.micro"
|
||||
key_name = "${aws_key_pair.mykey.key_name}"
|
||||
|
||||
provisioner "file" {
|
||||
source = "script.sh"
|
||||
destination = "/tmp/script.sh"
|
||||
}
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"chmod +x /tmp/script.sh",
|
||||
"sudo /tmp/script.sh"
|
||||
]
|
||||
}
|
||||
connection {
|
||||
user = "${var.INSTANCE_USERNAME}"
|
||||
private_key = "${file("${var.PATH_TO_PRIVATE_KEY}")}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user