Skip to content

Commit

Permalink
fix: tflint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vjdbj committed Sep 12, 2024
1 parent 6e469c8 commit 2c84383
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "azurerm_mysql_flexible_server" "main" {
administrator_password = var.admin_password == null ? random_password.main[0].result : var.admin_password
backup_retention_days = var.backup_retention_days
delegated_subnet_id = var.delegated_subnet_id
private_dns_zone_id = var.private_dns ? join("", azurerm_private_dns_zone.main[0].id) : var.existing_private_dns_zone_id
private_dns_zone_id = var.private_dns ? azurerm_private_dns_zone.main[0].id : var.existing_private_dns_zone_id
sku_name = var.sku_name
create_mode = var.create_mode
geo_redundant_backup_enabled = var.geo_redundant_backup_enabled
Expand Down Expand Up @@ -88,7 +88,7 @@ resource "azurerm_mysql_flexible_database" "main" {
count = var.enabled ? 1 : 0
name = var.db_name
resource_group_name = local.resource_group_name
server_name = join("", azurerm_mysql_flexible_server.main[0].name)
server_name = azurerm_mysql_flexible_server.main[0].name
charset = var.charset
collation = var.collation
depends_on = [azurerm_mysql_flexible_server.main]
Expand All @@ -102,7 +102,7 @@ resource "azurerm_mysql_flexible_server_configuration" "main" {
count = var.enabled ? length(var.server_configuration_names) : 0
name = element(var.server_configuration_names, count.index)
resource_group_name = local.resource_group_name
server_name = join("", azurerm_mysql_flexible_server.main[0].name)
server_name = azurerm_mysql_flexible_server.main[0].name
value = element(var.values, count.index)
}

Expand All @@ -122,7 +122,7 @@ resource "azurerm_private_dns_zone" "main" {
resource "azurerm_private_dns_zone_virtual_network_link" "main" {
count = var.enabled && var.private_dns ? 1 : 0
name = format("mysql-endpoint-link-%s", module.labels.id)
private_dns_zone_name = join("", azurerm_private_dns_zone.main[0].name)
private_dns_zone_name = azurerm_private_dns_zone.main[0].name
virtual_network_id = var.virtual_network_id
resource_group_name = local.resource_group_name
registration_enabled = var.registration_enabled
Expand Down
11 changes: 5 additions & 6 deletions output.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
output "mysql_flexible_server_id" {
value = join("", azurerm_mysql_flexible_server.main[0].id)
value = azurerm_mysql_flexible_server.main[0].id
description = "The ID of the MySQL Flexible Server."
}

output "azurerm_private_dns_zone_virtual_network_link_id" {
value = join("", azurerm_private_dns_zone_virtual_network_link.main[0].id)
value = azurerm_private_dns_zone_virtual_network_link.main[0].id
description = "The ID of the Private DNS Zone Virtual Network Link."
}
output "existing_private_dns_zone_virtual_network_link_id" {
value = join("", azurerm_private_dns_zone_virtual_network_link.main2[0].id)
description = "The ID of the Private DNS Zone Virtual Network Link."
value = length(azurerm_private_dns_zone_virtual_network_link.main2) > 0 ? azurerm_private_dns_zone_virtual_network_link.main2[0].id : null
}
output "azurerm_mysql_flexible_server_configuration_id" {
value = join("", azurerm_mysql_flexible_server_configuration.main.*.id)
value = azurerm_mysql_flexible_server_configuration.main[0].id
description = "The ID of the MySQL Flexible Server Configuration."
}
output "azurerm_private_dns_zone_id" {
value = join("", azurerm_private_dns_zone.main.*.id)
value = azurerm_private_dns_zone.main[0].id
description = "The Private DNS Zone ID."
}

Expand Down
21 changes: 2 additions & 19 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ variable "managedby" {
}

variable "resource_group_name" {
type = string
description = "A container that holds related resources for an Azure solution"
default = ""
}
Expand All @@ -49,11 +50,6 @@ variable "existing_private_dns_zone" {
default = false
}

variable "enable_private_endpoint" {
description = "Manages a Private Endpoint to Azure database for MySQL"
default = false
}

variable "registration_enabled" {
type = bool
description = "Is auto-registration of virtual machine records in the virtual network in the Private DNS zone enabled"
Expand All @@ -62,14 +58,11 @@ variable "registration_enabled" {
###########azurerm_mysql_flexible_server######

variable "admin_username" {
type = string
description = "The administrator login name for the new SQL Server"
default = null
}

variable "mysql_server_name" {
type = string
default = ""
}
variable "admin_password" {
type = string
description = "The password associated with the admin_username user"
Expand Down Expand Up @@ -142,16 +135,6 @@ variable "source_server_id" {
description = "The resource ID of the source MySQL Flexible Server to be restored. Required when create_mode is PointInTimeRestore, GeoRestore, and Replica. Changing this forces a new MySQL Flexible Server to be created."
}

variable "start_ip_address" {
type = string
default = ""
}

variable "end_ip_address" {
type = string
default = ""
}

variable "virtual_network_id" {
type = string
description = "The name of the virtual network"
Expand Down
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ terraform {
source = "hashicorp/azurerm"
version = ">=3.112.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.1"
}
}
}

0 comments on commit 2c84383

Please sign in to comment.