-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
34 lines (33 loc) · 921 Bytes
/
main.tf
File metadata and controls
34 lines (33 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
resource "aws_instance" "web" {
#ami = "ami-00068cd7555f543d5"
ami = "ami-06640050dc3f556bb"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.web-node.name}"]
key_name = "june"
# Copy in the bash script we want to execute.
# The source is the location of the bash script
# on the local linux box you are executing terraform
# from. The destination is on the new AWS instance.
provisioner "file" {
source = "package.sh"
destination = "/tmp/package.sh"
}
# Change permissions on bash script and execute from ec2-user.
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/package.sh",
"sudo /tmp/package.sh",
]
}
# Login to the ec2-user with the aws key.
connection {
type = "ssh"
user = "ec2-user"
password = ""
private_key = file("june.pem")
host = self.public_ip
}
tags = {
Name = "HelloWorld"
}
}