Skip to content

Commit 4d49ce4

Browse files
authored
Merge pull request #16 from pkuber-tamr/DEV-14916
DEV-14916
2 parents 79fcd16 + 7f98db5 commit 4d49ce4

File tree

19 files changed

+138
-144
lines changed

19 files changed

+138
-144
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Tamr Terraform Template Repo
22

3+
## v2.0.0 - June 30th 2021
4+
* Accepts a list of security groups
5+
* Returns a list of ports used by RDS
6+
* Removes ability for the creation of security groups
7+
38
## v1.0.0 - April 12th 2021
49
* Updates minimum Terraform version to 13
510
* Updates minimum AWS provider version to 3.36.0

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This repo follows the [terraform standard module structure](https://www.terrafor
77
Inline example implementation of the module. This is the most basic example of what it would look like to use this module.
88
```
99
module "rds_postgres" {
10-
source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=0.4.0"
10+
source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=2.0.0"
1111
postgres_name = "example_rds_postgres"
1212
parameter_group_name = "example-rds-postgres-pg"
1313
identifier_prefix = "example-rds-"
@@ -29,7 +29,6 @@ This terraform module will create:
2929
* an AWS RDS Postgres instance
3030
* a database parameter group
3131
* a database subnet group
32-
* a security group for the rds instance
3332

3433
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3534
## Requirements
@@ -49,9 +48,9 @@ This terraform module will create:
4948

5049
| Name | Description | Type | Default | Required |
5150
|------|-------------|------|---------|:--------:|
52-
| ingress\_sg\_ids | List of security group IDs to allow ingress from (i.e. Spark cluster SG IDs, Tamr VM SG ID) | `list(string)` | n/a | yes |
5351
| password | The password for the master DB user. | `string` | n/a | yes |
5452
| rds\_subnet\_ids | VPC subnet IDs in subnet group | `list(string)` | n/a | yes |
53+
| security\_group\_ids | List of security group IDs to allow ingress from (i.e. Spark cluster SG IDs, Tamr VM SG ID) | `list(string)` | n/a | yes |
5554
| subnet\_group\_name | The name of the subnet group to add the RDS instance to | `string` | n/a | yes |
5655
| vpc\_id | VPC ID for the rds security group | `string` | n/a | yes |
5756
| additional\_cidrs | Additional CIDR to connect to RDS Postgres instance | `list(string)` | `[]` | no |
@@ -84,7 +83,7 @@ This terraform module will create:
8483
| rds\_hostname | n/a |
8584
| rds\_postgres\_id | ID of the of the RDS instance |
8685
| rds\_postgres\_pg\_id | ID of the RDS postgres parameter group |
87-
| rds\_sg\_id | ID of the security group attached to the rds instance |
86+
| rds\_security\_group\_ids | List of security group ids attached to the rds instance |
8887
| rds\_username | n/a |
8988

9089
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
2.0.0

examples/minimal/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ No provider.
1111

1212
| Name | Description | Type | Default | Required |
1313
|------|-------------|------|---------|:--------:|
14-
| ingress\_sg\_ids | List of security group IDs to allow ingress from (i.e. Spark cluster SG IDs, Tamr VM SG ID) | `list(string)` | n/a | yes |
14+
| ingress\_cidr\_blocks | CIDR blocks to attach to security groups for ingress | `list(string)` | n/a | yes |
15+
| name\_prefix | A string to prepend to names of resources created by this example | `any` | n/a | yes |
16+
| security\_group\_ids | List of security group IDs to allow ingress from (i.e. Spark cluster SG IDs, Tamr VM SG ID) | `list(string)` | n/a | yes |
1517
| subnet\_ids | List of at least 2 subnets in different AZs for DB subnet group | `list(string)` | n/a | yes |
1618
| vpc\_id | VPC ID of network. | `string` | n/a | yes |
19+
| egress\_cidr\_blocks | CIDR blocks to attach to security groups for egress | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
1720

1821
## Outputs
1922

20-
No output.
23+
| Name | Description |
24+
|------|-------------|
25+
| ingress\_ports | List of ingress ports |
26+
| rds | n/a |
2127

2228
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/minimal/local.tfvars

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
vpc_id = "vpc-example"
2-
subnet_ids = ["subnet-az1", "subnet-az2"]
3-
ingress_sg_ids = ["example-spark-service-access-sg", "example-tamr-vm-sg"]
1+
vpc_id = "vpc-example"
2+
subnet_ids = ["subnet-az1", "subnet-az2"]
3+
security_group_ids = ["example-spark-service-access-sg", "example-tamr-vm-sg"]
4+
name_prefix = "test" # Replace me for a more specific prefix
5+
ingress_cidr_blocks = ["1.2.3.0/24"]

examples/minimal/main.tf

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
module "rds_postgres" {
2-
# source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=0.4.0"
2+
# source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=2.0.0"
33
source = "../.."
44

55
identifier_prefix = "example-rds-pg-"
66
postgres_name = "example0"
77
parameter_group_name = "example-rds-postgres-pg"
8-
username = "example-tamr-master"
9-
password = "foo" #tfsec:ignore:GEN003
8+
username = "exampleUsername"
9+
password = "examplePassword" #tfsec:ignore:GEN003
1010

1111
vpc_id = var.vpc_id
1212
subnet_group_name = "example_subnet_group"
1313
# Network requirement: DB subnet group needs a subnet in at least two Availability Zones
1414
rds_subnet_ids = var.subnet_ids
15-
ingress_sg_ids = var.ingress_sg_ids
15+
security_group_ids = module.rds-postgres-sg.security_group_ids
16+
}
17+
18+
module "sg-ports" {
19+
# source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git//modules/rds-postgres-ports?ref=2.0.0"
20+
source = "../../modules/rds-postgres-ports"
21+
}
22+
23+
module "rds-postgres-sg" {
24+
source = "git::[email protected]:Datatamer/terraform-aws-security-groups.git?ref=1.0.0"
25+
vpc_id = var.vpc_id
26+
ingress_cidr_blocks = var.ingress_cidr_blocks
27+
egress_cidr_blocks = var.egress_cidr_blocks
28+
ingress_ports = module.sg-ports.ingress_ports
29+
sg_name_prefix = var.name_prefix
30+
egress_protocol = "all"
31+
ingress_protocol = "tcp"
1632
}

examples/minimal/outputs.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
output "ingress_ports" {
2+
value = module.sg-ports
3+
description = "List of ingress ports"
4+
}
5+
6+
output "rds" {
7+
value = module.rds_postgres
8+
}

examples/minimal/variables.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@ variable "subnet_ids" {
88
description = "List of at least 2 subnets in different AZs for DB subnet group"
99
}
1010

11-
variable "ingress_sg_ids" {
11+
variable "security_group_ids" {
1212
description = "List of security group IDs to allow ingress from (i.e. Spark cluster SG IDs, Tamr VM SG ID)"
1313
type = list(string)
1414
}
15+
16+
variable "name_prefix" {
17+
description = "A string to prepend to names of resources created by this example"
18+
}
19+
20+
variable "ingress_cidr_blocks" {
21+
description = "CIDR blocks to attach to security groups for ingress"
22+
type = list(string)
23+
}
24+
25+
variable "egress_cidr_blocks" {
26+
description = "CIDR blocks to attach to security groups for egress"
27+
type = list(string)
28+
default = ["0.0.0.0/0"]
29+
}

main.tf

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ resource "aws_db_subnet_group" "rds_postgres_subnet_group" {
1010
subnet_ids = var.rds_subnet_ids
1111
}
1212

13-
module "rds_sg" {
14-
source = "./modules/rds-postgres-sg"
15-
ingress_sg_ids = var.ingress_sg_ids
16-
vpc_id = var.vpc_id
17-
security_group_name = var.security_group_name
18-
additional_cidrs = var.additional_cidrs
19-
additional_tags = var.additional_tags
20-
}
21-
2213
resource "aws_db_instance" "rds_postgres" {
2314
name = var.postgres_name
2415

@@ -39,7 +30,7 @@ resource "aws_db_instance" "rds_postgres" {
3930
db_subnet_group_name = aws_db_subnet_group.rds_postgres_subnet_group.name
4031
multi_az = true
4132
publicly_accessible = false
42-
vpc_security_group_ids = [module.rds_sg.rds_sg_id]
33+
vpc_security_group_ids = var.security_group_ids
4334
parameter_group_name = aws_db_parameter_group.rds_postgres_pg.name
4435

4536
maintenance_window = var.maintenance_window
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Tamr AWS RDS Postgres Ports Module
2+
This module returns a list of ports used by the RDS Postgres Service.
3+
4+
# Examples
5+
## Basic
6+
Inline example implementation of the module. This is the most basic example of what it would look like to use this module.
7+
```
8+
module "rds_postgres" {
9+
source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres//modules/rds-postgres-ports?ref=2.0.0"
10+
}
11+
```
12+
13+
# Resources Created
14+
This module creates no resources.
15+
16+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
17+
## Requirements
18+
19+
No requirements.
20+
21+
## Providers
22+
23+
No provider.
24+
25+
## Inputs
26+
27+
| Name | Description | Type | Default | Required |
28+
|------|-------------|------|---------|:--------:|
29+
| additional\_ports | Additional ports to add to the output of this module | `list(number)` | `[]` | no |
30+
| ports | Ports used by RDS Postgres | `list(number)` | <pre>[<br> 5432<br>]</pre> | no |
31+
32+
## Outputs
33+
34+
| Name | Description |
35+
|------|-------------|
36+
| ingress\_ports | List of ingress ports |
37+
38+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
39+
40+
# References
41+
This repo is based on:
42+
* [terraform standard module structure](https://www.terraform.io/docs/modules/index.html#standard-module-structure)
43+
* [templated terraform module](https://github.com/tmknom/template-terraform-module)
44+
45+
# License
46+
Apache 2 Licensed. See LICENSE for full details.

0 commit comments

Comments
 (0)