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

Ops 5460 allow sharing datacenter #16

Merged
merged 3 commits into from
Nov 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
2 changes: 2 additions & 0 deletions modules/ionos-datacenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ No modules.
| <a name="input_create_service_crossconnect"></a> [create\_service\_crossconnect](#input\_create\_service\_crossconnect) | Specifies whether crossconnect shall be created. Default: false. | `bool` | `false` | no |
| <a name="input_crossconnect_shared_group_ids"></a> [crossconnect\_shared\_group\_ids](#input\_crossconnect\_shared\_group\_ids) | Specifies which groups crossconnect shall be shared with. Default: []. | `list(string)` | `[]` | no |
| <a name="input_datacenter_location"></a> [datacenter\_location](#input\_datacenter\_location) | n/a | `string` | `"de/txl"` | no |
| <a name="input_datacenter_shares"></a> [datacenter\_shares](#input\_datacenter\_shares) | Which groups have access to the datacenter | <pre>list(object({<br> group = string<br> edit = optional(bool, false)<br> share = optional(bool, false)<br> }))</pre> | `[]` | no |
| <a name="input_routes_map"></a> [routes\_map](#input\_routes\_map) | map which links based on the lan id to a list in which the routes in form of an object ('network'='###' and 'gateway\_ip'='###') are saved | `any` | `{}` | no |
## Outputs

Expand Down Expand Up @@ -68,6 +69,7 @@ No modules.
| [ionoscloud_private_crossconnect.frontend_cc](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/private_crossconnect) | resource |
| [ionoscloud_private_crossconnect.service_cc](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/private_crossconnect) | resource |
| [ionoscloud_share.backend_cc](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/share) | resource |
| [ionoscloud_share.datacenter_permissions](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/share) | resource |
| [ionoscloud_share.frontend_cc](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/share) | resource |
| [ionoscloud_share.service_cc](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/share) | resource |
<!-- END_TF_DOCS -->
8 changes: 8 additions & 0 deletions modules/ionos-datacenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ resource "ionoscloud_datacenter" "datacenter" {
description = ""
}

resource "ionoscloud_share" "datacenter_permissions" {
for_each = { for share in var.datacenter_shares : share.group => share}
group_id = each.key
resource_id = ionoscloud_datacenter.datacenter.id
edit_privilege = each.value.edit
share_privilege = each.value.share
}

resource "ionoscloud_private_crossconnect" "frontend_cc" {
count = local.create_frontend_crossconnect ? 1 : 0
name = "${var.datacenter_name}-frontend-lan-cc"
Expand Down
10 changes: 10 additions & 0 deletions modules/ionos-datacenter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ variable "datacenter_location" {
default = "de/txl"
}

variable "datacenter_shares" {
type = list(object({
group = string
edit = optional(bool, false)
share = optional(bool, false)
}))
description = "Which groups have access to the datacenter"
default = []
}

variable "create_frontend_crossconnect" {
type = bool
description = "Specifies whether crossconnect shall be created. Default: false."
Expand Down