July 2017
Intermediate to advanced
374 pages
8h
English
Firstly, we need to create a security group resource for our ELB by adding this code to main.tf:
# A security group for the ELB so it is accessible via the web
resource "aws_security_group" "elb" {
name = "cna_sg_elb"
description = "Security_group_elb"
vpc_id = "${aws_vpc.default.id}"
# HTTP access from anywhere
ingress {
from_port = 5000
to_port = 5000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
Now, we need to add the following configuration for creating the ELB resources, and to add the app server into it as well:
resource "aws_elb" "web" { name = "cna-elb" subnets = ["${aws_subnet.default.id}"] ...