Skip to content

Commit

Permalink
output kubernetes_cluster_id from cluster_data
Browse files Browse the repository at this point in the history
  • Loading branch information
RMcVelia committed Dec 6, 2023
1 parent 279874d commit b42d12b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
7 changes: 0 additions & 7 deletions aks/application/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,3 @@ data "azurerm_monitor_action_group" "main" {
name = "${var.azure_resource_prefix}-${var.service_name}"
resource_group_name = data.azurerm_resource_group.monitoring[0].name
}

data "azurerm_kubernetes_cluster" "main" {
count = var.azure_enable_monitoring ? 1 : 0

name = "${var.cluster_configuration_map.resource_prefix}-aks"
resource_group_name = var.cluster_configuration_map.resource_group_name
}
2 changes: 1 addition & 1 deletion aks/application/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ resource "azurerm_monitor_metric_alert" "container_restarts" {

name = "${local.app_name}-container-restarts"
resource_group_name = data.azurerm_resource_group.monitoring[0].name
scopes = [data.azurerm_kubernetes_cluster.main[0].id]
scopes = [var.kubernetes_cluster_id]
description = "Action will be triggered when container restarts is greater than 0"
window_size = "PT30M"

Expand Down
2 changes: 1 addition & 1 deletion aks/application/tfdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ No modules.
| [kubernetes_pod_disruption_budget_v1.main](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod_disruption_budget_v1) | resource |
| [kubernetes_secret.ghcr_auth](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource |
| [kubernetes_service.main](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service) | resource |
| [azurerm_kubernetes_cluster.main](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) | data source |
| [azurerm_monitor_action_group.main](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/monitor_action_group) | data source |
| [azurerm_resource_group.monitoring](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |

Expand All @@ -40,6 +39,7 @@ No modules.
| <a name="input_github_personal_access_token"></a> [github\_personal\_access\_token](#input\_github\_personal\_access\_token) | Github Personal Access Token (PAT) of github\_username | `string` | `null` | no |
| <a name="input_github_username"></a> [github\_username](#input\_github\_username) | Github user authorised to access the private registry | `string` | `null` | no |
| <a name="input_is_web"></a> [is\_web](#input\_is\_web) | Whether this a web application | `bool` | `true` | no |
| <a name="input_kubernetes_cluster_id"></a> [kubernetes\_cluster\_id](#input\_kubernetes\_cluster\_id) | ID of the Kubernetes cluster | `string` | `null` | no |
| <a name="input_kubernetes_config_map_name"></a> [kubernetes\_config\_map\_name](#input\_kubernetes\_config\_map\_name) | Name of the Kubernetes configuration map | `string` | n/a | yes |
| <a name="input_kubernetes_secret_name"></a> [kubernetes\_secret\_name](#input\_kubernetes\_secret\_name) | Name of the Kubernetes secrets | `string` | n/a | yes |
| <a name="input_max_memory"></a> [max\_memory](#input\_max\_memory) | Maximum memory of the instance | `string` | `"1Gi"` | no |
Expand Down
6 changes: 6 additions & 0 deletions aks/application/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ variable "kubernetes_secret_name" {
description = "Name of the Kubernetes secrets"
}

variable "kubernetes_cluster_id" {
type = string
default = null
description = "ID of the Kubernetes cluster"
}

variable "docker_image" {
type = string
description = "Path to the docker image"
Expand Down
4 changes: 4 additions & 0 deletions aks/cluster_data/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ output "kubernetes_host" {
value = data.azurerm_kubernetes_cluster.main.kube_config.0.host
}

output "kubernetes_id" {
value = data.azurerm_kubernetes_cluster.main.id
}

output "kubernetes_client_certificate" {
value = base64decode(data.azurerm_kubernetes_cluster.main.kube_config.0.client_certificate)
}
Expand Down
1 change: 1 addition & 0 deletions aks/cluster_data/tfdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ No modules.
| <a name="output_kubernetes_client_key"></a> [kubernetes\_client\_key](#output\_kubernetes\_client\_key) | n/a |
| <a name="output_kubernetes_cluster_ca_certificate"></a> [kubernetes\_cluster\_ca\_certificate](#output\_kubernetes\_cluster\_ca\_certificate) | n/a |
| <a name="output_kubernetes_host"></a> [kubernetes\_host](#output\_kubernetes\_host) | n/a |
| <a name="output_kubernetes_id"></a> [kubernetes\_id](#output\_kubernetes\_id) | n/a |

0 comments on commit b42d12b

Please sign in to comment.