Skip to content

nitinda/terraform-module-aws-security-group

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Module: terraform-module-aws-security-group

Terraform module for AWS Security Group


Code : Stable


General

This module may be used to create Security Group resources in AWS Cloud provider.......


Prerequisites

This module needs Terraform 0.12.23 or newer.

You can download the latest Terraform version from here.

This module deploys aws services details are in respective feature branches.


Features

Below we are able to check the resources that are being created as part of this module call:

  • Security Group

Usage

Using this repo

To use this module, add the following call to your code:

module "security_group" {
  source = "git::https://github.com/nitinda/terraform-module-aws-security-group.git?ref=master"

  name_prefix            = "ec2-sg-"
  description            = "EC2 Security Group that allows traffic from whitelisted ips"
  vpc_id                 = var.vpc_id
  revoke_rules_on_delete = true
  ingress = [
    {
        from_port   = 0
        to_port     = 0
        protocol    = -1
        description = "Ingress rule that allows traffic from whitelisted ips"
        cidr_blocks = [ module.network.vpc_cidr ]
    }
  ]
  egress = [
    {
      from_port   = 0
      to_port     = 0
      protocol    = "-1"
      cidr_blocks = ["0.0.0.0/0"]
      description = "The egress rule allows all ports"
    }
  ]
}
module "security_group" {
  source = "git::https://github.com/nitinda/terraform-module-aws-security-group.git?ref=master"

  name                   = "ec2-sg-"
  description            = "EC2 Security Group that allows traffic from whitelisted ips"
  vpc_id                 = var.vpc_id
  revoke_rules_on_delete = true
  ingress = [
    {
        from_port   = 0
        to_port     = 0
        protocol    = -1
        description = "Ingress rule that allows traffic from whitelisted ips"
        cidr_blocks = [ module.network.vpc_cidr ]
    }
  ]
  egress = [
    {
      from_port   = 0
      to_port     = 0
      protocol    = "-1"
      cidr_blocks = ["0.0.0.0/0"]
      description = "The egress rule allows all ports"
    }
  ]
}
module "security_group" {
  source = "git::https://github.com/nitinda/terraform-module-aws-security-group.git?ref=master"

  name                   = "ec2-sg-"
  description            = "EC2 Security Group that allows traffic from whitelisted ips"
  vpc_id                 = var.vpc_id
  revoke_rules_on_delete = true
}

Inputs

The variables required in order for the module to be successfully called from the deployment repository are the following:

Variable Description Type Argument Status
name_prefix Creates a unique name beginning with the specified prefix string Optional
(Default - null)
name The name of the security group string Optional
(Default - null)
description The security group description string Optional
(Default - null)
ingress Ingress rules for security group any Optional
(Default - [])
egress Egress rules for security group any Optional
(Default - [])
revoke_rules_on_delete Instruct Terraform to revoke all of
the Security Groups attached ingress and
egress rules before deleting the rule itself
bool Optional
(Default - false)
vpc_id The VPC ID any Optional
(Default - null)
tags A mapping of tags to assign to the resource map(string) Optional
(Default - {})

Outputs

General

This module has the following outputs:

  • id
  • arn
  • name

Usage

In order for the variables to be accessed at module level please use the syntax below:

module.<module_name>.<output_variable_name>

The output variable is able to be accessed through terraform state file using the syntax below:

data.terraform_remote_state.<layer_name>.<output_variable_name>

Authors

Module maintained by Module maintained by the - Nitin Das