-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.tf
48 lines (42 loc) · 1.04 KB
/
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
variable "key_path" {
default = "~/.ssh/keyAWS.pub"
}
provider "aws" {
profile = "default"
region = "eu-west-3"
}
resource "aws_key_pair" "madu" {
key_name = "madu"
public_key = file(var.key_path)
}
resource "aws_instance" "madu" {
key_name = aws_key_pair.madu.key_name
ami = "ami-096b8af6e7e8fb927"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.web_group_security.name}"]
provisioner "local-exec" {
command = "echo \"[myserver]\n${aws_instance.madu.public_ip} ansible_user=ubuntu\" > ./ansible/inventory/hosts"
}
}
resource "aws_security_group" "web_group_security" {
name = "madu_security_group"
description = "security group for the project Madu"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}