forked from jbrotsos/astlab2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
negative2.tf
114 lines (95 loc) · 2.5 KB
/
negative2.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
provider "aws2" {
profile = "default"
region = "us-west-2"
}
data "aws_availability_zones" "available2" {
state = "available"
}
data "aws_ami" "ubuntu2" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_vpc" "vpc1" {
cidr_block = "10.10.0.0/16"
}
resource "aws_subnet" "subnet12" {
vpc_id = aws_vpc.vpc1.id
cidr_block = "10.10.10.0/24"
availability_zone_id = data.aws_availability_zones.available2.zone_ids[0]
tags = {
Name = "subnet1"
}
}
resource "aws_subnet" "subnet22" {
vpc_id = aws_vpc.vpc1.id
cidr_block = "10.10.11.0/24"
availability_zone_id = data.aws_availability_zones.available2.zone_ids[1]
tags = {
Name = "subnet2"
}
}
resource "aws_lb" "test2" {
name = "test123"
load_balancer_type = "application"
subnets = [aws_subnet.subnet12.id, aws_subnet.subnet22.id]
internal = true
}
resource "aws_lb_target_group" "test2" {
port = 80
protocol = "HTTP"
target_type = "instance"
vpc_id = aws_vpc.vpc1.id
}
resource "aws_default_security_group" "dsg2" {
vpc_id = aws_vpc.vpc1.id
}
resource "aws_lb_listener" "listener2" {
load_balancer_arn = aws_lb.test2.arn
protocol = "HTTPS"
port = 80
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.test2.arn
}
}
resource "aws_lb_target_group_attachment" "attach12" {
target_group_arn = aws_lb_target_group.test2.arn
target_id = aws_instance.inst12.id
port = 80
}
resource "aws_instance" "inst12" {
vpc_security_group_ids = [aws_default_security_group.dsg2.id]
subnet_id = aws_subnet.subnet12.id
ami = data.aws_ami.ubuntu2.id
instance_type = "t3.micro"
}
resource "aws_lb_target_group_attachment" "attach22" {
target_group_arn = aws_lb_target_group.test2.arn
target_id = aws_instance.inst22.id
port = 80
}
resource "aws_instance" "inst22" {
vpc_security_group_ids = [aws_default_security_group.dsg2.id]
subnet_id = aws_subnet.subnet12.id
ami = data.aws_ami.ubuntu2.id
instance_type = "t3.micro"
}
resource "aws_lb_target_group_attachment" "attach32" {
target_group_arn = aws_lb_target_group.test2.arn
target_id = aws_instance.inst32.id
port = 80
}
resource "aws_instance" "inst32" {
vpc_security_group_ids = [aws_default_security_group.dsg2.id]
subnet_id = aws_subnet.subnet12.id
ami = data.aws_ami.ubuntu2.id
instance_type = "t3.micro"
}