Skip to content
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

Dbp 446 create nat gateway #20

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/ionos-datacenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ No modules.
| <a name="input_create_alb_target_lan"></a> [create\_alb\_target\_lan](#input\_create\_alb\_target\_lan) | Specifies whether a private target for the Application Load Balancer shall be created. | `bool` | `false` | no |
| <a name="input_create_backend_crossconnect"></a> [create\_backend\_crossconnect](#input\_create\_backend\_crossconnect) | Specifies whether crossconnect shall be created. Default: false. | `bool` | `false` | no |
| <a name="input_create_frontend_crossconnect"></a> [create\_frontend\_crossconnect](#input\_create\_frontend\_crossconnect) | Specifies whether crossconnect shall be created. Default: false. | `bool` | `false` | no |
| <a name="input_create_nat_lan"></a> [create\_nat\_lan](#input\_create\_nat\_lan) | Specifies whether a private lan to connect a NAT gateway shall be created. | `bool` | `false` | no |
| <a name="input_create_nfs_server_lan"></a> [create\_nfs\_server\_lan](#input\_create\_nfs\_server\_lan) | Specifies whether a private lan to connect an NFS server shall be created. | `bool` | `false` | no |
| <a name="input_create_nlb_target_lan"></a> [create\_nlb\_target\_lan](#input\_create\_nlb\_target\_lan) | Specifies whether a private target for the Network Load Balancer shall be created. | `bool` | `false` | no |
| <a name="input_create_postgres_lan"></a> [create\_postgres\_lan](#input\_create\_postgres\_lan) | Specifies whether a private lan to connect Postgres shall be created. | `bool` | `false` | no |
Expand All @@ -42,10 +43,12 @@ No modules.
| <a name="output_lan_alb_target"></a> [lan\_alb\_target](#output\_lan\_alb\_target) | n/a |
| <a name="output_lan_backend"></a> [lan\_backend](#output\_lan\_backend) | n/a |
| <a name="output_lan_frontend"></a> [lan\_frontend](#output\_lan\_frontend) | n/a |
| <a name="output_lan_nat"></a> [lan\_nat](#output\_lan\_nat) | n/a |
| <a name="output_lan_nfs_server"></a> [lan\_nfs\_server](#output\_lan\_nfs\_server) | n/a |
| <a name="output_lan_nlb_target"></a> [lan\_nlb\_target](#output\_lan\_nlb\_target) | n/a |
| <a name="output_lan_postgres"></a> [lan\_postgres](#output\_lan\_postgres) | n/a |
| <a name="output_lan_service"></a> [lan\_service](#output\_lan\_service) | n/a |
| <a name="output_nat_lan_id"></a> [nat\_lan\_id](#output\_nat\_lan\_id) | n/a |
| <a name="output_nfs_server_lan_id"></a> [nfs\_server\_lan\_id](#output\_nfs\_server\_lan\_id) | n/a |
| <a name="output_nlb_target_lan_id"></a> [nlb\_target\_lan\_id](#output\_nlb\_target\_lan\_id) | n/a |
| <a name="output_postgres_lan_id"></a> [postgres\_lan\_id](#output\_postgres\_lan\_id) | n/a |
Expand All @@ -64,6 +67,7 @@ No modules.
| [ionoscloud_lan.alb_target_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.backend_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.frontend_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.nat_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.nfs_server_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.nlb_target_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.postgres_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
Expand Down
32 changes: 17 additions & 15 deletions modules/ionos-datacenter/locals.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
locals {
create_frontend_crossconnect = var.create_frontend_crossconnect
create_frontend_lan = (local.create_frontend_crossconnect == true || var.associated_frontend_crossconnect_id != "") ? true : false
create_backend_crossconnect = var.create_backend_crossconnect
create_backend_lan = (local.create_backend_crossconnect == true || var.associated_backend_crossconnect_id != "") ? true : false
create_service_crossconnect = var.create_service_crossconnect
create_service_lan = (local.create_service_crossconnect == true || var.associated_service_crossconnect_id != "") ? true : false
create_public_lan = var.create_public_lan
create_nfs_server_lan = var.create_nfs_server_lan
create_alb_target_lan = var.create_alb_target_lan
create_nlb_target_lan = var.create_nlb_target_lan
frontend_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_frontend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
backend_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_backend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
service_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_frontend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
routes_map = var.routes_map
create_postgres_lan = var.create_postgres_lan
create_frontend_crossconnect = var.create_frontend_crossconnect
create_frontend_lan = (local.create_frontend_crossconnect == true || var.associated_frontend_crossconnect_id != "") ? true : false
create_backend_crossconnect = var.create_backend_crossconnect
create_backend_lan = (local.create_backend_crossconnect == true || var.associated_backend_crossconnect_id != "") ? true : false
create_service_crossconnect = var.create_service_crossconnect
create_service_lan = (local.create_service_crossconnect == true || var.associated_service_crossconnect_id != "") ? true : false
create_public_lan = var.create_public_lan
create_nfs_server_lan = var.create_nfs_server_lan
create_alb_target_lan = var.create_alb_target_lan
create_nlb_target_lan = var.create_nlb_target_lan
create_nat_lan = var.create_nat_lan
frontend_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_frontend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
backend_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_backend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
service_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_frontend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
routes_map = var.routes_map
create_postgres_lan = var.create_postgres_lan
# this saves the service/backend/frontend lans as an object in a list
# Example of an object:
# > type({"id" = "id", "routes_list" = [{"network" = "10.0.0.0/24", gateway_ip="10.0.0.0"}]})
Expand All @@ -34,4 +35,5 @@ locals {
lan_postgres = flatten([ for id in ionoscloud_lan.postgres_lan.*.id: { id = id, routes_list = [{}] }])
lan_alb_target = flatten([ for id in ionoscloud_lan.alb_target_lan.*.id: { id = id, routes_list =[{}] }])
lan_nlb_target = flatten([ for id in ionoscloud_lan.nlb_target_lan.*.id: { id = id, routes_list =[{}] }])
lan_nat = flatten([ for id in ionoscloud_lan.nat_lan.*.id: { id = id, routes_list = [{}] }])
}
7 changes: 7 additions & 0 deletions modules/ionos-datacenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,11 @@ resource "ionoscloud_lan" "nlb_target_lan" {
name = "${var.datacenter_name}-nlb-target-lan"
datacenter_id = ionoscloud_datacenter.datacenter.id
public = false
}

resource "ionoscloud_lan" "nat_lan" {
count = local.create_nat_lan ? 1 : 0
name = "${var.datacenter_name}-nat-lan"
datacenter_id = ionoscloud_datacenter.datacenter.id
public = false
}
8 changes: 8 additions & 0 deletions modules/ionos-datacenter/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ output "nlb_target_lan_id" {

output "lan_nlb_target" {
value = local.lan_nlb_target
}

output "nat_lan_id" {
value = join("", ionoscloud_lan.nat_lan.*.id)
}

output "lan_nat" {
value = local.lan_nat
}
6 changes: 6 additions & 0 deletions modules/ionos-datacenter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ variable "create_nlb_target_lan" {
type = bool
description = "Specifies whether a private target for the Network Load Balancer shall be created."
default = false
}

variable "create_nat_lan" {
type = bool
description = "Specifies whether a private lan to connect a NAT gateway shall be created."
default = false
}