Skip to content

Commit d143ee5

Browse files
authored
Create provisioner_file_and_remote.tf
1 parent d317284 commit d143ee5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

provisioner_file_and_remote.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
provider "aws" {
2+
region = "us-east-1"
3+
}
4+
5+
6+
resource "aws_instance" "stage_instance" {
7+
instance_type = var.instance_type
8+
ami = var.ami_id
9+
key_name = "myec2keypair"
10+
vpc_security_group_ids = ["sg-02d85b5dd5f74c7a7"]
11+
12+
provisioner "file" {
13+
connection {
14+
type = "ssh"
15+
user = "ubuntu"
16+
private_key = file("myec2keypair.pem")
17+
host = aws_instance.stage_instance.public_ip
18+
}
19+
source = "abc.sh"
20+
destination = "/tmp/abc.sh"
21+
}
22+
connection {
23+
type = "ssh"
24+
user = "ubuntu"
25+
private_key = file("myec2keypair.pem")
26+
host = aws_instance.stage_instance.public_ip
27+
}
28+
provisioner "remote-exec" {
29+
30+
31+
inline = [
32+
"chmod +x /tmp/abc.sh",
33+
"/tmp/abc.sh",
34+
]
35+
}
36+
37+
tags = {
38+
Name = "stage-instance"
39+
}
40+
}

0 commit comments

Comments
 (0)