-
Notifications
You must be signed in to change notification settings - Fork 23
/
ec2.tf
87 lines (66 loc) · 2.05 KB
/
ec2.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
########################
### Data source ###
########################
data "aws_ami" "amazon_linux_2" {
most_recent = true
owners = ["amazon"]
filter {
name = "owner-alias"
values = ["amazon"]
}
filter {
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
########################
### Ec2 Instance ###
########################
resource "aws_instance" "PublicWebTemplate" {
ami = data.aws_ami.amazon_linux_2.id
instance_type = "t2.micro"
subnet_id = aws_subnet.public-web-subnet-1.id
vpc_security_group_ids = [aws_security_group.webserver-security-group.id]
key_name = "source_key"
user_data = file("ec2-init-script.sh")
tags = {
Name = "web-asg"
}
}
##############################
#### EC2 instance Web Tier ###
##############################
/*resource "aws_instance" "PublicWebTemplate" {
ami = "ami-052efd3df9dad4825"
instance_type = "t2.micro"
subnet_id = aws_subnet.public-web-subnet-1.id
vpc_security_group_ids = [aws_security_group.webserver-security-group.id]
key_name = "source_key"
user_data = file("ec2-init-script.sh")
tags = {
Name = "web-asg"
}
}*/
resource "aws_instance" "private-app-template" {
ami = data.aws_ami.amazon_linux_2.id
instance_type = "t2.micro"
subnet_id = aws_subnet.private-app-subnet-1.id
vpc_security_group_ids = [aws_security_group.ssh-security-group.id]
key_name = "source_key"
tags = {
Name = "app-asg"
}
}
##############################
#### EC2 instance App Tier ###
##############################
/*resource "aws_instance" "private-app-template" {
ami = "ami-052efd3df9dad4825"
instance_type = "t2.micro"
subnet_id = aws_subnet.private-app-subnet-1.id
vpc_security_group_ids = [aws_security_group.ssh-security-group.id]
key_name = "source_key"
tags = {
Name = "app-asg"
}
}*/