Skip to content

Commit

Permalink
Fix access for Teleport DB support
Browse files Browse the repository at this point in the history
Signed-off-by: Stavros Foteinopoulos <[email protected]>
  • Loading branch information
stafot committed Nov 11, 2024
1 parent c9559a7 commit eb3fb45
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 1 deletion.
1 change: 1 addition & 0 deletions aws/awat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
| <a name="input_open_oidc_provider_url"></a> [open\_oidc\_provider\_url](#input\_open\_oidc\_provider\_url) | The Open OIDC Provider URL for a specific cluster | `string` | n/a | yes |
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | n/a | `list(string)` | n/a | yes |
| <a name="input_serviceaccount"></a> [serviceaccount](#input\_serviceaccount) | Service Account, with which we want to associate IAM permission | `string` | n/a | yes |
| <a name="input_teleport_cidr"></a> [teleport\_cidr](#input\_teleport\_cidr) | The Teleport CIDR block to allow access | `string` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | n/a | `string` | n/a | yes |

## Outputs
Expand Down
8 changes: 8 additions & 0 deletions aws/awat/awat_db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ resource "aws_security_group" "cnc_to_awat_db" {
security_groups = [data.terraform_remote_state.cnc_cluster.outputs.workers_security_group]
}

ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
}

ingress {
from_port = 5432
to_port = 5432
Expand Down
5 changes: 5 additions & 0 deletions aws/awat/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,8 @@ variable "iam_database_authentication_enabled" {
description = "Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled."
default = false
}

variable "teleport_cidr" {
type = string
description = "The Teleport CIDR block to allow access"
}
1 change: 1 addition & 0 deletions aws/customer-web-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
| <a name="input_environment"></a> [environment](#input\_environment) | n/a | `string` | n/a | yes |
| <a name="input_iam_database_authentication_enabled"></a> [iam\_database\_authentication\_enabled](#input\_iam\_database\_authentication\_enabled) | Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | `bool` | `false` | no |
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | n/a | `list(string)` | n/a | yes |
| <a name="input_teleport_cidr"></a> [teleport\_cidr](#input\_teleport\_cidr) | The Teleport CIDR block to allow access | `string` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | n/a | `string` | n/a | yes |

## Outputs
Expand Down
5 changes: 5 additions & 0 deletions aws/customer-web-server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ variable "iam_database_authentication_enabled" {
description = "Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled."
default = false
}

variable "teleport_cidr" {
type = string
description = "The Teleport CIDR block to allow access"
}
8 changes: 8 additions & 0 deletions aws/customer-web-server/web-server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ resource "aws_security_group" "cws_postgres_sg" {
description = "CLOUD VPN"
}

ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
}

egress {
from_port = 0
to_port = 0
Expand Down
1 change: 1 addition & 0 deletions aws/elrond/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
| <a name="input_environment"></a> [environment](#input\_environment) | The environment to deploy the Elrond resources, dev, test, etc. | `string` | n/a | yes |
| <a name="input_iam_database_authentication_enabled"></a> [iam\_database\_authentication\_enabled](#input\_iam\_database\_authentication\_enabled) | Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | `bool` | `false` | no |
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | The Elrond DB private subnets | `list(string)` | n/a | yes |
| <a name="input_teleport_cidr"></a> [teleport\_cidr](#input\_teleport\_cidr) | The Teleport CIDR block to allow access | `string` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC to deploy the Elrond resources | `string` | n/a | yes |

## Outputs
Expand Down
8 changes: 8 additions & 0 deletions aws/elrond/elrond-db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ resource "aws_security_group" "cnc_to_elrond_postgress" {
security_groups = [data.terraform_remote_state.cluster.outputs.workers_security_group]
}

ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
}

ingress {
from_port = 5432
to_port = 5432
Expand Down
5 changes: 5 additions & 0 deletions aws/elrond/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,8 @@ variable "iam_database_authentication_enabled" {
description = "Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled."
default = false
}

variable "teleport_cidr" {
type = string
description = "The Teleport CIDR block to allow access"
}
1 change: 1 addition & 0 deletions aws/provisioner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
| <a name="input_provisioner_replica_min"></a> [provisioner\_replica\_min](#input\_provisioner\_replica\_min) | n/a | `number` | n/a | yes |
| <a name="input_provisioner_service_name"></a> [provisioner\_service\_name](#input\_provisioner\_service\_name) | n/a | `string` | `"provisioner"` | no |
| <a name="input_provisioner_users"></a> [provisioner\_users](#input\_provisioner\_users) | n/a | `list(string)` | n/a | yes |
| <a name="input_teleport_cidr"></a> [teleport\_cidr](#input\_teleport\_cidr) | The Teleport CIDR block to allow access | `string` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | n/a | `string` | n/a | yes |

## Outputs
Expand Down
8 changes: 8 additions & 0 deletions aws/provisioner/provisioner-db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ resource "aws_security_group" "cec_to_postgress" {
description = "CLOUD VPN"
}

ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
}

ingress {
from_port = 5432
to_port = 5432
Expand Down
5 changes: 5 additions & 0 deletions aws/provisioner/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,8 @@ variable "iam_database_authentication_enabled" {
description = "Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled."
default = false
}

variable "teleport_cidr" {
type = string
description = "The Teleport CIDR block to allow access"
}
1 change: 1 addition & 0 deletions aws/subnet-and-networking-3az/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ No modules.
| [aws_security_group_rule.master_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.master_ingress_teleport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.master_ingress_worker](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.teleport_db_service_access_postgresql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_ingress_master](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_ingress_teleport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
Expand Down
12 changes: 12 additions & 0 deletions aws/subnet-and-networking-3az/security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@ resource "aws_security_group_rule" "gitlab_access_postgresql" {
to_port = 5432
type = "ingress"
}

resource "aws_security_group_rule" "teleport_db_service_access_postgresql" {
for_each = toset(var.vpc_cidrs)

cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
from_port = 5432
protocol = "TCP"
security_group_id = aws_security_group.db_sg_postgresql[each.value]["id"]
to_port = 5432
type = "ingress"
}
1 change: 1 addition & 0 deletions aws/subnet-and-networking-4az/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ No modules.
| [aws_security_group_rule.master_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.master_ingress_teleport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.master_ingress_worker](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.teleport_db_service_access_postgresql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_ingress_master](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_ingress_teleport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
Expand Down
12 changes: 12 additions & 0 deletions aws/subnet-and-networking-4az/security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@ resource "aws_security_group_rule" "gitlab_access_postgresql" {
to_port = 5432
type = "ingress"
}

resource "aws_security_group_rule" "teleport_db_service_access_postgresql" {
for_each = toset(var.vpc_cidrs)

cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
from_port = 5432
protocol = "TCP"
security_group_id = aws_security_group.db_sg_postgresql[each.value]["id"]
to_port = 5432
type = "ingress"
}
3 changes: 2 additions & 1 deletion aws/subnet-and-networking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ No modules.
| [aws_security_group_rule.master_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.master_ingress_teleport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.master_ingress_worker](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.teleport_db_service_access_postgresql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_ingress_master](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.worker_ingress_teleport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
Expand Down Expand Up @@ -183,7 +184,7 @@ No modules.
| <a name="input_security_group_referencing_support"></a> [security\_group\_referencing\_support](#input\_security\_group\_referencing\_support) | Security Group Referencing allows to specify other SGs as references, or matching criterion in inbound security rules to allow instance-to-instance traffic | `string` | `"enable"` | no |
| <a name="input_single_route_table_deployment"></a> [single\_route\_table\_deployment](#input\_single\_route\_table\_deployment) | This will defined whether a single route table for all subnets will be created. multi\_route\_table\_deployment and single\_route\_table\_deployment cannot be both set to true | `bool` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | n/a | yes |
| <a name="input_teleport_cidr"></a> [teleport\_cidr](#input\_teleport\_cidr) | n/a | `list(string)` | n/a | yes |
| <a name="input_teleport_cidr"></a> [teleport\_cidr](#input\_teleport\_cidr) | The Teleport DB CIDR block to allow access | `string` | n/a | yes |
| <a name="input_transit_gateway_id"></a> [transit\_gateway\_id](#input\_transit\_gateway\_id) | n/a | `string` | n/a | yes |
| <a name="input_transit_gtw_route_destination"></a> [transit\_gtw\_route\_destination](#input\_transit\_gtw\_route\_destination) | n/a | `string` | n/a | yes |
| <a name="input_transit_gtw_route_destination_gitlab"></a> [transit\_gtw\_route\_destination\_gitlab](#input\_transit\_gtw\_route\_destination\_gitlab) | n/a | `string` | n/a | yes |
Expand Down
12 changes: 12 additions & 0 deletions aws/subnet-and-networking/security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,15 @@ resource "aws_security_group_rule" "gitlab_access_postgresql" {
to_port = 5432
type = "ingress"
}

resource "aws_security_group_rule" "teleport_db_service_access_postgresql" {
for_each = toset(var.vpc_cidrs)

cidr_blocks = var.teleport_cidr
description = "Allow the Teleport DB Service"
from_port = 5432
protocol = "TCP"
security_group_id = aws_security_group.db_sg_postgresql[each.value]["id"]
to_port = 5432
type = "ingress"
}
5 changes: 5 additions & 0 deletions aws/subnet-and-networking/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ variable "security_group_referencing_support" {
type = string
default = "enable"
}

variable "teleport_cidr" {
type = string
description = "The Teleport DB CIDR block to allow access"
}

0 comments on commit eb3fb45

Please sign in to comment.