Security Group Example
Terraform
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
# Configure the AWS Provider
provider "aws" {
profile = "default"
region = "eu-west-1"
}
# Create Security Group for the Application Load Balancer
# terraform aws create security group
resource "aws_security_group" "http-https-global-security-group" {
name = "HTTP HTTPS Global"
description = "HTTP HTTPS Global (80,443 - All)"
vpc_id = "vpc-4fe52XXX"
ingress {
description = "HTTP Access Global"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "HTTPS Access Global"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "HTTP-HTTPS-Global"
}
}