-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
98 lines (79 loc) · 2.7 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# resource "aws_instance" "ec2privateawseducateiacdemo" {
# # availability_zone = var.az
# ami = "ami-09e67e426f25ce0d7" # ubuntu 20 image
# instance_type = "t2.micro"
# tags = { Name = var.private_instance_name }
# key_name = "awseducateiacdemo"
# vpc_security_group_ids = [aws_security_group.sg_private_awseducateicademo.id]
# subnet_id = aws_subnet.privatesubnetawseducateiacdemo.id
# # root_block_device {
# # volume_size = 10
# # delete_on_termination = true
# # volume_type = "gp2"
# # tags = {
# # Name = "iacdemorootebs"
# # }
# # }
# }
resource "aws_instance" "ec2publicawseducateiacdemo" {
# availability_zone = var.az
ami = "ami-09e67e426f25ce0d7" # ubuntu 20 image
instance_type = "t2.micro"
tags = { Name = var.public_instance_name }
key_name = "awseducateiacdemo"
vpc_security_group_ids = [aws_security_group.sg_public_awseducateicademo.id]
subnet_id = aws_subnet.publicsubnetawseducateiacdemo.id
# root_block_device {
# volume_size = 10
# delete_on_termination = true
# volume_type = "gp2"
# tags = {
# Name = "iacdemorootebs"
# }
# }
}
resource "aws_instance" "jenkinsawseducateiacdemo" {
# availability_zone = var.az
ami = "ami-09e67e426f25ce0d7" # ubuntu 20 image
instance_type = "t2.micro"
tags = { Name = var.jenkins_instance_name }
key_name = "awseducateiacdemo"
vpc_security_group_ids = [aws_security_group.sg_public_awseducateicademo.id]
subnet_id = aws_subnet.publicsubnetawseducateiacdemo.id
# root_block_device {
# volume_size = 10
# delete_on_termination = true
# volume_type = "gp2"
# tags = {
# Name = "iacdemorootebs"
# }
# }
}
output "public_instance_ip_addr" {
value = aws_instance.ec2publicawseducateiacdemo.public_ip
}
output "jenkins_public_instance_ip_addr" {
value = aws_instance.jenkinsawseducateiacdemo.public_ip
}
# output "private_instance_ip_addr" {
# value = aws_instance.ec2privateawseducateiacdemo.private_ip
# }
# resource "aws_ebs_volume" "iacdemoebs" {
# availability_zone = var.az
# size = 8
# depends_on = [
# aws_instance.iacdemo
# ]
# type = "gp2"
# tags = {
# Name = "iacdemoebs"
# }
# }
# resource "aws_volume_attachment" "attachebsec2" {
# device_name = "/dev/sdh"
# volume_id = aws_ebs_volume.iacdemoebs.id
# instance_id = aws_instance.iacdemo.id
# depends_on = [
# aws_instance.iacdemo, aws_ebs_volume.iacdemoebs
# ]
# }