How to Create an AWS Security Group in Terraform

Below is a simple Terraform script block to create a Security Group in AWS.

resource "aws_security_group" "Sample-App-Security-Group" { name = "sampleappsg-123" description = "Inbound and outbound traffic for sampleapp service" vpc_id = aws_vpc.id ingress { from_port = 0 protocol = "-1" to_port = 0 cidr_blocks = ["10.0.0.0/8"] ipv6_cidr_blocks = ["::/8"] } egress { from_port = 0 protocol = "-1" to_port = 0 cidr_blocks = ["10.0.0.0/8"] ipv6_cidr_blocks = ["::/8"] } tags { Name = "Sample App Security Group" } }
Code language: JavaScript (javascript)

You can read up more about all the possible arguments in the AWS Security Group Terraform Reference.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments