Skip to content

Latest commit

 

History

History
67 lines (55 loc) · 3.17 KB

File metadata and controls

67 lines (55 loc) · 3.17 KB

AWS Security Group Rules Module

This module creates EC2 Security Group Rules.

Example

# main.tf
module "instance_sg_rules" {
  source = "git::https://github.com/lpavliuk/Terraform-Modules.git//aws_security_group_rules"

  security_group_id = local.instance_sg_id
  inbound_rules     = [
    {
      description = "(MySQL) from Specific IP Address"
      protocol    = "tcp"
      port_range  = 3306
      source_type = "cidr_ipv4"
      source      = "172.31.11.16/32"
    },
    {
      description = "(MSs Ports) from VPC"
      protocol    = "tcp"
      port_range  = "52000-52999"
      source_type = "cidr_ipv4"
      source      = "172.31.0.0/16"
    },
    {
      description = "from EC2 VPN"
      port_range  = "all"
      source_type = "security_group_id"
      source      = local.vpn_instance_sg_id
    },
  ]
}

Requirements

Name Version
terraform < 2.0.0, >= 1.6.6
aws < 6.0, >= 5.22

Inputs

Name Description Type Default Required
security_group_id Security Group ID string n/a yes
inbound_rules Inbound Rules.

Use port_range = "all" to define all traffic rule.
port_range definition examples:
- 80
- "80"
- "80-443"
- "all"

Available source_type values:
- cidr_ipv4
- cidr_ipv6
- security_group_id
- prefix_list_id
list(object({
description = optional(string, "")
protocol = optional(string, "tcp")
port_range = string
source_type = string
source = string
}))
[] no
outbound_rules Outbound Rules.

Use port_range = "all" to define all traffic rule.
port_range definition examples:
- 80
- "80"
- "80-443"
- "all"

Available source_type values:
- cidr_ipv4
- cidr_ipv6
- security_group_id
- prefix_list_id
list(object({
description = optional(string, "")
protocol = optional(string, "tcp")
port_range = string
source_type = string
source = string
}))
[] no

Outputs

Name Description
security_group_id Security Group ID

Resources

Name Type
aws_vpc_security_group_egress_rule.this resource
aws_vpc_security_group_ingress_rule.this resource