-
Notifications
You must be signed in to change notification settings - Fork 8
DEV-13447 sg module rds #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jaynathani-tamr
merged 2 commits into
Datatamer:master
from
jaynathani-tamr:DEV-13447-sg-module-rds
Apr 7, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| postgres_db_name = "example_postgres_db" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| module "rds_postgres" { | ||
jaynathani-tamr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| source = "git::https://github.com/Datatamer/terraform-rds-postgres.git?ref=0.1.0" | ||
| postgres_name = "example_rds_postgres" | ||
| parameter_group_name = "example-rds-postgres-pg" | ||
| identifier_prefix = "example-rds-" | ||
|
|
||
| username = "exampleUsername" | ||
| password = "examplePassword" | ||
|
|
||
| subnet_name = "example_subnet" | ||
| spark_cluster_sg_ids = ["sg-examplesecuritygroup1", "sg-examplesecuritygroup2"] | ||
| tamr_vm_sg_id = "sg-exampletamrsecuritygroup" | ||
| vpc_id = "vpc-examplevpcnetworkid" | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| variable "postgres_db_name" { | ||
| type = string | ||
| description = "Name of the postgres db" | ||
| } | ||
|
|
||
| variable "parameter_group_name" { | ||
| type = string | ||
| description = "Name of the parameter group" | ||
| } | ||
|
|
||
| variable "identifier_prefix" { | ||
| type = string | ||
| description = "Identifier prefix for the resources" | ||
| } | ||
|
|
||
| variable "pg_username" { | ||
| type = string | ||
| description = "Username for postgres" | ||
| } | ||
|
|
||
| variable "pg_password" { | ||
| type = string | ||
| description = "Password for postgres" | ||
| } | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Tamr AWS RDS Security Groups Terraform Module | ||
| This terraform module creates the security group and the security group rules for the AWS RDS instance | ||
|
|
||
| # Example | ||
| ``` | ||
| module "rds_sg" { | ||
| source = "./modules/rds-postgres-sg" | ||
| spark_cluster_sg_ids = ["sg-examplesparksecuritygroup1", "sg-examplesparksecuritygroup2"] | ||
| tamr_vm_sg_id = "sg-exampletamrvmsecuritygroup" | ||
| vpc_id = "vpc-examplevpcid" | ||
| security_group_name = "examplerdssecuritygroup" | ||
| additional_cidrs = ["1.2.3.4/32"] | ||
| } | ||
| ``` | ||
|
|
||
| # Variables | ||
| ## Inputs: | ||
| * `tamr_vm_sg_id` (required): Security group id attached to the tamr vm | ||
| * `spark_cluster_sg_ids` (required): List of Security groups attached to the ec2 instances of EMR Spark | ||
| * `vpc_id` (required): VPC ID for the rds security group | ||
| * `security_group_name` (optional): Name for the security group for the rds instance | ||
| * `additional_cidrs` (optional): List of additional CIDR to connect to RDS Postgres instance | ||
| * `additional_tags` (optional): Tags to set on the RDS instance security group | ||
|
|
||
| ## Outputs: | ||
| * `rds_sg_id`: ID of the security group attached to the RDS instance | ||
|
|
||
| # AWS Resources created | ||
| This terraform module creates 1 Security Group: | ||
| * A security group for the RDS instance | ||
|
|
||
| This terraform module also creates Security Group Rules. The number of Security Group rules vary depending on the additional CIDRs provided. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| resource "aws_security_group" "rds_postgres_sg" { | ||
| name = var.security_group_name | ||
| description = "VPC Security group that will be attached to the RDS Postgres instance" | ||
| vpc_id = var.vpc_id | ||
| tags = var.additional_tags | ||
| } | ||
|
|
||
| resource "aws_security_group_rule" "tamr_vm" { | ||
| from_port = 5432 | ||
| protocol = "tcp" | ||
| security_group_id = aws_security_group.rds_postgres_sg.id | ||
| to_port = 5432 | ||
| type = "ingress" | ||
| source_security_group_id = var.tamr_vm_sg_id | ||
| } | ||
|
|
||
| resource "aws_security_group_rule" "spark_cluster" { | ||
| count = length(var.spark_cluster_sg_ids) | ||
| from_port = 5432 | ||
| protocol = "tcp" | ||
| security_group_id = aws_security_group.rds_postgres_sg.id | ||
| to_port = 5432 | ||
| type = "ingress" | ||
| source_security_group_id = var.spark_cluster_sg_ids[count.index] | ||
| } | ||
|
|
||
| resource "aws_security_group_rule" "additional_cidrs" { | ||
| count = length(var.additional_cidrs) == 0 ? 0 : 1 | ||
| from_port = 5432 | ||
| protocol = "tcp" | ||
| security_group_id = aws_security_group.rds_postgres_sg.id | ||
| to_port = 5432 | ||
| type = "ingress" | ||
| cidr_blocks = var.additional_cidrs | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| output "rds_sg_id" { | ||
| value = aws_security_group.rds_postgres_sg.id | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| variable "security_group_name" { | ||
| description = "Name for the security group for the rds instance" | ||
| type = string | ||
| default = "tamr_rds_sg" | ||
| } | ||
|
|
||
| variable "tamr_vm_sg_id" { | ||
| description = "Security group id attached to the tamr vm" | ||
| type = string | ||
| } | ||
|
|
||
| variable "spark_cluster_sg_ids" { | ||
| description = "List of Security groups attached to the ec2 instances of EMR Spark" | ||
| type = list(string) | ||
| } | ||
|
|
||
| variable "vpc_id" { | ||
| description = "VPC ID for the rds security group" | ||
| type = string | ||
| } | ||
|
|
||
| variable "additional_cidrs" { | ||
| description = "Additional CIDR to connect to RDS Postgres instance" | ||
| type = list(string) | ||
| default = [] | ||
| } | ||
|
|
||
| variable "additional_tags" { | ||
| description = "Additional tags to set on the RDS instance" | ||
| type = map | ||
| default = {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.