diff --git a/modules/compute/security_group/README.md b/modules/compute/security_group/README.md index 1889141..d8e0d8a 100644 --- a/modules/compute/security_group/README.md +++ b/modules/compute/security_group/README.md @@ -1,54 +1,43 @@ -# security-groups-gen2 -This module create security groups from a map +# security-group +This module create security group. ## Inputs -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:-----:| -| tags | tags | List | n/a | yes | -| vpc-id | VPC id | string | n/a | yes | -| security-groups | See example below | map | n/a | yes | - -### security-groups input -Below is a sample security-groups map this module ingests - -``` -module "bea-bast-sg" { - source = "../../modules/compute/security_groups" - - security-groups = [ - { - name = "RackspaceAdmin2" - description = "Allow rdp/ssh access from Rackspace" - ingress = { - r1 = "icmp,-1,-1,0.0.0.0/0,ICMP ping" - r2 = "-1,-1,-1,1.2.3.4/32,Foo access" - } - egress = { - r1 = "-1,-1,-1,0.0.0.0/0,Default egress rule" - } - }, - { - name = "RackspaceAdmin" - description = "Allow rdp/ssh access from Rackspace" - ingress = { - r1 = "tcp,443,443,${aws_ec2_managed_prefix_list.rsip_range.id},Bar ip ranges" - r2 = "tcp,22,22,2.3.4.5/32,Joe Blow" - } - egress = { - r1 = "-1,-1,-1,0.0.0.0/0,Default egress rule" - } - } - ] - - tags = local.default-tags - vpc-id = "vpc-xxx" -} -``` +| Name | Description | Type | Default | Required | +|---------|-------------------|----------|---------|:--------:| +| vpc-id | VPC id | string | n/a | yes | +| ingress | See example below | map | n/a | yes | +| egress | See example below | map | n/a | yes | ## Outputs -| Name | Description | -|------|-------------| +| Name | Description | +|------------|--------------------------------| | sg-id-name | A map of SG id and their names | +### Example +Below is a sample root module calling this shared module + +```hcl +module "admin-sg" { + + source = "../../modules/compute/security_group" + + description = "Security group for admins" + egress = { + r1 = "tcp,4750,4750,1.2.3.4/32,Patch Management Tool" + r2 = "tcp,22,22,1.2.3.4/32,Patch Management Tool" + r3 = "tcp,52311,52311,${aws_ec2_managed_prefix_list.bigfix.id},Client to BigFix server" + } + ingress = { + r1 = "tcp,4750,4750,1.2.3.4/32,Patch Management Tool" + r2 = "tcp,22,22,1.2.3.4/32,Patch Management Tool" + r3 = "tcp,52311,52311,${aws_ec2_managed_prefix_list.bigfix.id},BigFix server to client" + } + name = "admin-sg" + vpc-id = "vpc-01a10b033169f89a8" +} +``` + + + diff --git a/modules/compute/security_group/main.tf b/modules/compute/security_group/main.tf index 590eb9b..6fb358e 100644 --- a/modules/compute/security_group/main.tf +++ b/modules/compute/security_group/main.tf @@ -11,7 +11,7 @@ resource "aws_security_group" "sg" { name = var.name description = var.description vpc_id = var.vpc-id - tags = { Name = var.name } + tags = { Name = var.name } } resource "aws_vpc_security_group_ingress_rule" "ingress-rules" {