Terraform module for AWS Security Group
This module may be used to create Security Group resources in AWS Cloud provider.......
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.
Below we are able to check the resources that are being created as part of this module call:
- Security Group
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
}
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 - {}) |
This module has the following outputs:
- id
- arn
- name
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>
Module maintained by Module maintained by the - Nitin Das