-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added module for creating a lan and firewall rules
- Loading branch information
Showing
7 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,40 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_ionoscloud"></a> [ionoscloud](#provider\_ionoscloud) | 6.4.18 | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_datacenter_id"></a> [datacenter_id](#input\_datacenter_id) | n/a | `string` | n/a | yes | | ||
| <a name="input_name"></a> [name](#input\_name) | n/a | `string` | n/a | yes | | ||
| <a name="input_server_id"></a> [server_id](#input\_server_ids) | n/a | `string` | n/a | yes | | ||
| <a name="input_ports"></a> [ports](#input\_ports) | n/a | `list` | n/a | yes | | ||
| <a name="input_is_public"></a> [is_public](#input\_is_public) | n/a | `bool` | n/a | yes | | ||
|
||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_lan_id"></a> [lan_id](lan\_id) | n/a | | ||
| <a name="output_nic_id"></a> [nic_id](nic\_id) | n/a | | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_ionoscloud"></a> [ionoscloud](#requirement\_ionoscloud) | 6.4.18 | | ||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [ionoscloud_firewall.range_rule](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/resources/firewall) | resource | | ||
| [ionoscloud_firewall.rule](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/resources/firewall) | resource | | ||
| [ionoscloud_ipblock.public_ip](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/resources/ipblock) | resource | | ||
| [ionoscloud_lan.basic_vm_server_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/resources/lan) | resource | | ||
|
||
<!-- END_TF_DOCS --> |
Empty file.
This file contains 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,2 @@ | ||
|
||
|
This file contains 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,30 @@ | ||
# Create a LAN ( private or public ) | ||
resource "ionoscloud_lan" "lan" { | ||
datacenter_id = var.datacenter_id | ||
public = var.is_public | ||
name = format( "%s-%s",var.name,"intern-connection-lan") | ||
} | ||
|
||
# Create a NIC for the basic VM and connect it to the LAN | ||
resource "ionoscloud_nic" "nic" { | ||
datacenter_id = var.datacenter_id | ||
server_id = var.server_id | ||
dhcp = true | ||
lan = ionoscloud_lan.lan.id | ||
firewall_active = true | ||
|
||
} | ||
|
||
# Add The Ports The VM | ||
resource "ionoscloud_firewall" "rule" { | ||
count = length(var.ports) | ||
datacenter_id = var.datacenter_id | ||
server_id = var.server_id | ||
nic_id = ionoscloud_nic.nic.id | ||
protocol = var.ports[count.index]["protocol"] | ||
name = var.ports[count.index]["name"] | ||
port_range_start = var.ports[count.index]["port"] | ||
port_range_end = var.ports[count.index]["port"] | ||
source_ip = lookup(var.ports[count.index], "source_ip", null) | ||
} | ||
|
This file contains 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,9 @@ | ||
output "lan_id" { | ||
description = "The id of the lan created" | ||
value = ionoscloud_lan.lan.id | ||
} | ||
|
||
output "nic_id" { | ||
description = "The id of the nic created" | ||
value = ionoscloud_nic.nic.id | ||
} |
This file contains 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,25 @@ | ||
variable "datacenter_id" { | ||
description = "The Datacenter id" | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
description = "The name given for the module" | ||
type = string | ||
} | ||
|
||
variable "server_id" { | ||
description = "The Server id for the lan" | ||
type = string | ||
} | ||
|
||
variable "ports" { | ||
description = "List of Ports toprovided to rule" | ||
type = list | ||
} | ||
|
||
variable "is_public" { | ||
description = "The Type of lan is public (true) or private (false)" | ||
type = bool | ||
default = false | ||
} |
This file contains 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,8 @@ | ||
terraform { | ||
required_providers { | ||
ionoscloud = { | ||
source = "ionos-cloud/ionoscloud" | ||
version = "6.4.18" | ||
} | ||
} | ||
} |