From 2198ae24e58ea2def3b61f3bf78a12f273132b76 Mon Sep 17 00:00:00 2001 From: Don Badrak Date: Thu, 10 Oct 2019 12:07:03 -0400 Subject: [PATCH] add rds-mssql --- rds-mssql/main.tf | 57 ++++++++++++++++++++++++++++++++++++++++++ rds-mssql/output.tf | 9 +++++++ rds-mssql/variables.tf | 19 ++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 rds-mssql/main.tf create mode 100644 rds-mssql/output.tf create mode 100644 rds-mssql/variables.tf diff --git a/rds-mssql/main.tf b/rds-mssql/main.tf new file mode 100644 index 0000000..c5c1257 --- /dev/null +++ b/rds-mssql/main.tf @@ -0,0 +1,57 @@ +/** +* # About +* +* This describes how to use the aws-common-security-groups submodule for rds-mssql +* +* # Usage +* +* ```code +* module "rds-mssql" { +* source = "git::https://vc1.csvd.census.gov/terraform-modules/aws-common-security-groups.git//rds-mssql" +* +* # name = "m-rds-mssql" +* vpc_id = var.vpc_id +* # Name, CostAllocation, and Environment are pre-set +* # tags = { } +* } +* ``` +*/ + +locals { + description = "module: MS SQL Server Common Ports" + name = var.name + ports = [ + [ 1433, 1433, "tcp" ] + ] +} + +resource "aws_security_group" "this_security_group" { + name = local.name + description = local.description + vpc_id = var.vpc_id + + dynamic "ingress" { + for_each = local.ports + iterator = p + content { + description = "${local.description}" + from_port = p.value[0] + to_port = p.value[1] + protocol = p.value[2] + cidr_blocks = [ "0.0.0.0/0" ] + } + } + + egress { + description = "ALL: ${local.description}" + from_port = 0 + to_port = 0 + protocol = -1 + cidr_blocks = [ "0.0.0.0/0" ] + } + + tags = merge( + map("Name", local.name), + var.tags, + ) +} diff --git a/rds-mssql/output.tf b/rds-mssql/output.tf new file mode 100644 index 0000000..f9c3840 --- /dev/null +++ b/rds-mssql/output.tf @@ -0,0 +1,9 @@ +output "this_security_group_id" { + description = "Created security group ID" + value = aws_security_group.this_security_group.id +} + +output "this_security_group_arn" { + description = "Created security group ARN" + value = aws_security_group.this_security_group.arn +} diff --git a/rds-mssql/variables.tf b/rds-mssql/variables.tf new file mode 100644 index 0000000..f0d6a0e --- /dev/null +++ b/rds-mssql/variables.tf @@ -0,0 +1,19 @@ +variable "vpc_id" { + description = "VPC ID Number" + type = string +} + +variable "name" { + description = "Security group Name" + type = string + default = "m-rds-mssql" +} + +variable "tags" { + description = "Extra security group tags" + type = map + default = { + "CostAllocation" = "csvd:infrastructure" + "Environment" = "csvd-infrastructure" + } +}