Resource: aws_vpc_security_group_ingress_rule

Manages an inbound (ingress) rule for a security group.

When specifying an inbound rule for your security group in a VPC, the configuration must include a source for the traffic.

Example Usage

resource "aws_security_group" "example" {
  name        = "example"
  description = "example"
  vpc_id      = aws_vpc.main.id
  tags = {
    Name = "example"
  }
}

resource "aws_vpc_security_group_ingress_rule" "example" {
  security_group_id = aws_security_group.example.id

  cidr_ipv4   = "10.0.0.0/8"
  from_port   = 80
  ip_protocol = "tcp"
  to_port     = 80
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import security group ingress rules using the security_group_rule_id. For example:

import {
  to = aws_vpc_security_group_ingress_rule.example
  id = "sgr-02108b27edd666983"
}

Using terraform import, import security group ingress rules using the security_group_rule_id. For example:

% terraform import aws_vpc_security_group_ingress_rule.example sgr-02108b27edd666983