Skip to content

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 = protocol = "-1" to_port = cidr_blocks = ["10.0.0.0/8"] ipv6_cidr_blocks = ["::/8"] } egress { from_port = protocol = "-1" to_port = 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.

See also  How to get an EKS Cluster name from an AWS Region
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x