Difference between revisions of "Terraform resource: aws security group"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
 
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
 
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
  
<pre>
 
resource "aws_security_group" "allow_tls" {
 
  name        = "allow_tls"
 
  description = "Allow TLS inbound traffic"
 
  vpc_id      = aws_vpc.main.id
 
  
  ingress {
+
resource "aws_security_group" "allow_tls" {
    description      = "TLS from VPC"
+
  name        = "allow_tls"
    from_port        = 443
+
  description = "Allow TLS inbound traffic"
    to_port          = 443
+
  vpc_id      = aws_vpc.main.id
    protocol        = "tcp"
+
    cidr_blocks      = [aws_vpc.main.cidr_block]
+
  ingress {
    ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block]
+
    description      = "TLS from VPC"
  }
+
    from_port        = 443
 
+
    to_port          = 443
  egress {
+
    protocol        = "tcp"
    from_port        = 0
+
    cidr_blocks      = [aws_vpc.main.cidr_block]
    to_port          = 0
+
    ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block]
    protocol        = "-1"
+
  }  
    cidr_blocks      = ["0.0.0.0/0"]
+
    ipv6_cidr_blocks = ["::/0"]
+
  egress {
  }
+
    from_port        = 0
 
+
    to_port          = 0
  tags = {
+
    protocol        = "-1"
    Name = "allow_tls"
+
    cidr_blocks      = ["0.0.0.0/0"]
  }
+
    ipv6_cidr_blocks = ["::/0"]
}
+
  }
</pre>
+
 +
  tags = {
 +
    Name = "allow_tls"
 +
  }
 +
}
  
  

Revision as of 21:18, 1 June 2022


resource "aws_security_group" "allow_tls" {
  name        = "allow_tls"
  description = "Allow TLS inbound traffic"
  vpc_id      = aws_vpc.main.id

  ingress {
    description      = "TLS from VPC"
    from_port        = 443
    to_port          = 443
    protocol         = "tcp"
    cidr_blocks      = [aws_vpc.main.cidr_block]
    ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block]
  } 

  egress {
    from_port        = 0
    to_port          = 0
    protocol         = "-1"
    cidr_blocks      = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }

  tags = {
    Name = "allow_tls"
  }
}


Related terms

See also

Advertising: