Skip to content

vvalusa/sg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Requirements

Name Version
aws 3.35.0

Providers

Name Version
aws 3.35.0

Modules

No modules.

Resources

Name Type
aws_security_group.security_group resource

Inputs

Name Description Type Default Required
description Description of Security group string n/a yes
egress List of egress rules
map(object({
from_port = number
to_port = number
protocol = string
cidr_blocks = list(string)
description = string
security_groups = list(string)

}))
n/a yes
ingress List of ingress rules
map(object({
from_port = number
to_port = number
protocol = string
cidr_blocks = list(string)
description = string
security_groups = list(string)

}))
n/a yes
name Name of Security group string n/a yes
tags Mention the tags any n/a yes
vpc_cidr CIDR block for the VPC string n/a yes
vpc_id ID of the VPC where to create security group string n/a yes

Outputs

Name Description
arn The ARN of the security group
id The ID of the security group

Usage

Here is examples of how you can use this module, we created 2 different type of groups i.e. open to public access, and DB security groups.

Security group with custom rules

module "sg_public" {
  source   = "../sg/"
  vpc_cidr = var.vpc_cidr
  vpc_id   = var.vpc_id
  ingress = {
    "http_rules_ingress" = {
      description     = "For HTTP"
      from_port       = 80
      to_port         = 80
      protocol        = "tcp"
      cidr_blocks     = ["0.0.0.0/0"]
      security_groups = []
    },
    "ssh_rules_ingress" = {
      description     = "For SSH"
      from_port       = 22
      to_port         = 22
      protocol        = "tcp"
      cidr_blocks     = ["0.0.0.0/0"]
      security_groups = []
    }
  }
  egress = {
    "Internet_open_egress" = {
      description     = "Internet open egress"
      from_port       = 0
      to_port         = 0
      protocol        = "-1"
      cidr_blocks     = ["0.0.0.0/0"]
      security_groups = []
    }
  }
  name        = "Public security group"
  description = "Public secuirty group"
  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}


module "sg_rds" {
  source   = "../sg/"
  vpc_cidr = var.vpc_cidr
  vpc_id   = var.vpc_id
  ingress = {
    "http_rules_ingress" = {
      description     = "For HTTP"
      from_port       = 3306
      to_port         = 3306
      protocol        = "tcp"
      cidr_blocks     = []
      security_groups = ["sg-035962aecd67def34"]
    }
  }
  egress = {
    "Internet_open_egress" = {
      description     = "Internet RDS egress"
      from_port       = 0
      to_port         = 0
      protocol        = "-1"
      cidr_blocks     = ["0.0.0.0/0"]
      security_groups = []
    }
  }
  name        = "RDS security group"
  description = "RDS secuirty group"
  tags = {
    Terraform   = "true"
    Environment = "rds_dev"
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages