Skip to content

Commit fda8e55

Browse files
authored
Merge pull request #11 from Datatamer/DEV-14278
DEV-14278, DEV-14279 Address tfsec warnings and make example more complete.
2 parents 19b2407 + 5b06fb4 commit fda8e55

File tree

8 files changed

+47
-42
lines changed

8 files changed

+47
-42
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Datatamer/devops @Datatamer/ci-team

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Smallest complete fully working example. This example might require extra resour
2929
This terraform module will create:
3030
* an AWS RDS Postgres instance
3131
* a database parameter group
32+
* a database subnet group
3233
* a security group for the rds instance
3334

3435
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -49,11 +50,11 @@ This terraform module will create:
4950

5051
| Name | Description | Type | Default | Required |
5152
|------|-------------|------|---------|:--------:|
52-
| password | The postgres password | `string` | n/a | yes |
53+
| password | The password for the master DB user. | `string` | n/a | yes |
5354
| rds\_subnet\_ids | VPC subnet IDs in subnet group | `list(string)` | n/a | yes |
54-
| spark\_cluster\_sg\_ids | Security group is attached to the ec2 instances of EMR Spark | `list(string)` | n/a | yes |
55+
| spark\_cluster\_sg\_ids | List of Spark service access security group IDs to allow ingress from | `list(string)` | n/a | yes |
5556
| subnet\_group\_name | The name of the subnet group to add the RDS instance to | `string` | n/a | yes |
56-
| tamr\_vm\_sg\_id | Security group id attached to the tamr vm | `string` | n/a | yes |
57+
| tamr\_vm\_sg\_id | Tamr VM security group ID to allow ingress from | `string` | n/a | yes |
5758
| vpc\_id | VPC ID for the rds security group | `string` | n/a | yes |
5859
| additional\_cidrs | Additional CIDR to connect to RDS Postgres instance | `list(string)` | `[]` | no |
5960
| additional\_tags | Additional tags to set on the RDS instance | `map` | `{}` | no |
@@ -69,11 +70,11 @@ This terraform module will create:
6970
| max\_allocated\_storage | Max allocate storage | `number` | `1000` | no |
7071
| parameter\_group\_family | The family of the DB parameter group | `string` | `"postgres12"` | no |
7172
| parameter\_group\_name | The name of the rds parameter group | `string` | `"rds-postgres-pg"` | no |
72-
| postgres\_name | The name of the postgres instance | `string` | `"tamr_rds_db"` | no |
73+
| postgres\_name | The name of the postgres database to create on the DB instance | `string` | `"tamr_rds_db"` | no |
7374
| security\_group\_name | Name for the security group for the rds instance | `string` | `"tamr_rds_sg"` | no |
7475
| skip\_final\_snapshot | Skip final snapshot | `bool` | `true` | no |
7576
| storage\_type | Storage type (e.g. gp2, io1) | `string` | `"gp2"` | no |
76-
| username | The postgres username | `string` | `"tamr"` | no |
77+
| username | The username for the master DB user. | `string` | `"tamr"` | no |
7778

7879
## Outputs
7980

examples/minimal/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ No provider.
1111

1212
| Name | Description | Type | Default | Required |
1313
|------|-------------|------|---------|:--------:|
14-
| identifier\_prefix | Identifier prefix for the resources | `string` | n/a | yes |
15-
| parameter\_group\_name | Name of the parameter group | `string` | n/a | yes |
16-
| pg\_password | Password for postgres | `string` | n/a | yes |
17-
| pg\_username | Username for postgres | `string` | n/a | yes |
18-
| postgres\_db\_name | Name of the postgres db | `string` | n/a | yes |
14+
| spark\_service\_access\_sg\_ids | List of Spark service access security group IDs to allow ingress from | `list(string)` | n/a | yes |
15+
| subnet\_ids | List of at least 2 subnets in different AZs for DB subnet group | `list(string)` | n/a | yes |
16+
| tamr\_vm\_sg\_id | Security group ID of Tamr VM to allow ingress from | `string` | n/a | yes |
17+
| vpc\_id | VPC ID of network. | `string` | n/a | yes |
1918

2019
## Outputs
2120

examples/minimal/local.tfvars

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
postgres_db_name = "example_postgres_db"
1+
vpc_id = "vpc-example"
2+
subnet_ids = ["subnet-az1", "subnet-az2"]
3+
spark_service_access_sg_ids = ["example-spark-service-access-sg"]
4+
tamr_vm_sg_id = "example-tamr-vm-sg"

examples/minimal/main.tf

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
module "rds_postgres" {
2-
source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=0.3.0"
3-
postgres_name = "example_rds_postgres"
2+
# source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=0.3.0"
3+
source = "../.."
4+
5+
identifier_prefix = "example-rds-pg-"
6+
postgres_name = "example0"
47
parameter_group_name = "example-rds-postgres-pg"
5-
identifier_prefix = "example-rds-"
8+
username = "example-tamr-master"
9+
password = "foo" #tfsec:ignore:GEN003
610

7-
username = "exampleUsername"
8-
password = "examplePassword"
11+
vpc_id = var.vpc_id
12+
subnet_group_name = "example_subnet_group"
13+
# Network requirement: DB subnet group needs a subnet in at least two Availability Zones
14+
rds_subnet_ids = var.subnet_ids
915

10-
subnet_group_name = "example_subnet"
11-
rds_subnet_ids = ["example-subnet-1", "example-subnet-2"]
12-
spark_cluster_sg_ids = ["sg-examplesecuritygroup1", "sg-examplesecuritygroup2"]
13-
tamr_vm_sg_id = "sg-exampletamrsecuritygroup"
14-
vpc_id = "vpc-examplevpcnetworkid"
16+
spark_cluster_sg_ids = var.spark_service_access_sg_ids
17+
tamr_vm_sg_id = var.tamr_vm_sg_id
1518
}

examples/minimal/variables.tf

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
variable "postgres_db_name" {
1+
variable "vpc_id" {
22
type = string
3-
description = "Name of the postgres db"
3+
description = "VPC ID of network."
44
}
55

6-
variable "parameter_group_name" {
7-
type = string
8-
description = "Name of the parameter group"
6+
variable "subnet_ids" {
7+
type = list(string)
8+
description = "List of at least 2 subnets in different AZs for DB subnet group"
99
}
1010

11-
variable "identifier_prefix" {
12-
type = string
13-
description = "Identifier prefix for the resources"
14-
}
15-
16-
variable "pg_username" {
17-
type = string
18-
description = "Username for postgres"
11+
variable "spark_service_access_sg_ids" {
12+
type = list(string)
13+
description = "List of Spark service access security group IDs to allow ingress from"
1914
}
2015

21-
variable "pg_password" {
16+
variable "tamr_vm_sg_id" {
2217
type = string
23-
description = "Password for postgres"
18+
description = "Security group ID of Tamr VM to allow ingress from"
2419
}

modules/rds-postgres-sg/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "aws_security_group" "rds_postgres_sg" {
66
}
77

88
resource "aws_security_group_rule" "tamr_vm" {
9+
description = "Rule for ingress from Tamr VM to Postgres"
910
from_port = 5432
1011
protocol = "tcp"
1112
security_group_id = aws_security_group.rds_postgres_sg.id
@@ -15,6 +16,7 @@ resource "aws_security_group_rule" "tamr_vm" {
1516
}
1617

1718
resource "aws_security_group_rule" "spark_cluster" {
19+
description = "Rule for ingress from Spark cluster to Postgres"
1820
count = length(var.spark_cluster_sg_ids)
1921
from_port = 5432
2022
protocol = "tcp"
@@ -25,6 +27,7 @@ resource "aws_security_group_rule" "spark_cluster" {
2527
}
2628

2729
resource "aws_security_group_rule" "additional_cidrs" {
30+
description = "Rule for ingress from additional CIDRs to Postgres"
2831
count = length(var.additional_cidrs) == 0 ? 0 : 1
2932
from_port = 5432
3033
protocol = "tcp"

variables.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
variable "password" {
2-
description = "The postgres password"
2+
description = "The password for the master DB user."
33
type = string
44
}
55

66
variable "username" {
7-
description = "The postgres username"
7+
description = "The username for the master DB user."
88
type = string
99
default = "tamr"
1010
}
1111

1212
variable "postgres_name" {
13-
description = "The name of the postgres instance"
13+
description = "The name of the postgres database to create on the DB instance"
1414
type = string
1515
default = "tamr_rds_db"
1616
}
@@ -23,7 +23,7 @@ variable "parameter_group_name" {
2323

2424
variable "identifier_prefix" {
2525
description = "Identifier prefix for the RDS instance"
26-
type = "string"
26+
type = string
2727
default = "tamr-rds-"
2828
}
2929

@@ -110,12 +110,12 @@ variable "security_group_name" {
110110
}
111111

112112
variable "tamr_vm_sg_id" {
113-
description = "Security group id attached to the tamr vm"
113+
description = "Tamr VM security group ID to allow ingress from"
114114
type = string
115115
}
116116

117117
variable "spark_cluster_sg_ids" {
118-
description = "Security group is attached to the ec2 instances of EMR Spark"
118+
description = "List of Spark service access security group IDs to allow ingress from"
119119
type = list(string)
120120
}
121121

0 commit comments

Comments
 (0)