Skip to content

Commit

Permalink
Deploy MS SQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Dec 12, 2024
1 parent 64715f4 commit 820a7fe
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
11 changes: 8 additions & 3 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ No providers.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_azure_container_apps_hosting"></a> [azure\_container\_apps\_hosting](#module\_azure\_container\_apps\_hosting) | github.com/DFE-Digital/terraform-azurerm-container-apps-hosting | v1.16.2 |
| <a name="module_azurerm_key_vault"></a> [azurerm\_key\_vault](#module\_azurerm\_key\_vault) | github.com/DFE-Digital/terraform-azurerm-key-vault-tfvars | v0.5.1 |
| <a name="module_data_protection"></a> [data\_protection](#module\_data\_protection) | github.com/DFE-Digital/terraform-azurerm-aspnet-data-protection | v1.2.0 |
| <a name="module_statuscake-tls-monitor"></a> [statuscake-tls-monitor](#module\_statuscake-tls-monitor) | github.com/dfe-digital/terraform-statuscake-tls-monitor | v0.1.5 |

## Resources

Expand Down Expand Up @@ -189,6 +186,7 @@ No resources.
| <a name="input_enable_health_insights_api"></a> [enable\_health\_insights\_api](#input\_enable\_health\_insights\_api) | Deploys a Function App that exposes the last 3 HTTP Web Tests via an API endpoint. 'enable\_app\_insights\_integration' and 'enable\_monitoring' must be set to 'true'. | `bool` | `false` | no |
| <a name="input_enable_logstash_consumer"></a> [enable\_logstash\_consumer](#input\_enable\_logstash\_consumer) | Create an Event Hub consumer group for Logstash | `bool` | `false` | no |
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Create an App Insights instance and notification group for the Container App | `bool` | n/a | yes |
| <a name="input_enable_mssql_database"></a> [enable\_mssql\_database](#input\_enable\_mssql\_database) | Set to true to create an Azure SQL server/database, with a private endpoint within the virtual network | `bool` | n/a | yes |
| <a name="input_environment"></a> [environment](#input\_environment) | Environment name. Will be used along with `project_name` as a prefix for all resources. | `string` | n/a | yes |
| <a name="input_eventhub_export_log_analytics_table_names"></a> [eventhub\_export\_log\_analytics\_table\_names](#input\_eventhub\_export\_log\_analytics\_table\_names) | List of Log Analytics table names that you want to export to Event Hub. See https://learn.microsoft.com/en-gb/azure/azure-monitor/logs/logs-data-export?tabs=portal#supported-tables for a list of supported tables | `list(string)` | `[]` | no |
| <a name="input_existing_logic_app_workflow"></a> [existing\_logic\_app\_workflow](#input\_existing\_logic\_app\_workflow) | Name, and Resource Group of an existing Logic App Workflow. Leave empty to create a new Resource | <pre>object({<br/> name : string<br/> resource_group_name : string<br/> })</pre> | <pre>{<br/> "name": "",<br/> "resource_group_name": ""<br/>}</pre> | no |
Expand All @@ -200,6 +198,13 @@ No resources.
| <a name="input_key_vault_access_ipv4"></a> [key\_vault\_access\_ipv4](#input\_key\_vault\_access\_ipv4) | List of IPv4 Addresses that are permitted to access the Key Vault | `list(string)` | n/a | yes |
| <a name="input_monitor_email_receivers"></a> [monitor\_email\_receivers](#input\_monitor\_email\_receivers) | A list of email addresses that should be notified by monitoring alerts | `list(string)` | n/a | yes |
| <a name="input_monitor_endpoint_healthcheck"></a> [monitor\_endpoint\_healthcheck](#input\_monitor\_endpoint\_healthcheck) | Specify a route that should be monitored for a 200 OK status | `string` | n/a | yes |
| <a name="input_mssql_azuread_admin_object_id"></a> [mssql\_azuread\_admin\_object\_id](#input\_mssql\_azuread\_admin\_object\_id) | Object ID of a User within Azure AD that you want to assign as the SQL Server Administrator | `string` | n/a | yes |
| <a name="input_mssql_azuread_admin_username"></a> [mssql\_azuread\_admin\_username](#input\_mssql\_azuread\_admin\_username) | Username of a User within Azure AD that you want to assign as the SQL Server Administrator | `string` | n/a | yes |
| <a name="input_mssql_database_name"></a> [mssql\_database\_name](#input\_mssql\_database\_name) | The name of the MSSQL database to create. Must be set if `enable_mssql_database` is true | `string` | n/a | yes |
| <a name="input_mssql_firewall_ipv4_allow_list"></a> [mssql\_firewall\_ipv4\_allow\_list](#input\_mssql\_firewall\_ipv4\_allow\_list) | A list of IPv4 Addresses that require remote access to the MSSQL Server | <pre>map(object({<br/> start_ip_range : string,<br/> end_ip_range : optional(string, "")<br/> }))</pre> | `{}` | no |
| <a name="input_mssql_managed_identity_assign_role"></a> [mssql\_managed\_identity\_assign\_role](#input\_mssql\_managed\_identity\_assign\_role) | Assign the 'Storage Blob Data Contributor' Role to the SQL Server User-Assigned Managed Identity. Note: If you do not have 'Microsoft.Authorization/roleAssignments/write' permission, you will need to manually assign the 'Storage Blob Data Contributor' Role to the identity | `bool` | `false` | no |
| <a name="input_mssql_server_admin_password"></a> [mssql\_server\_admin\_password](#input\_mssql\_server\_admin\_password) | The local administrator password for the MSSQL server | `string` | n/a | yes |
| <a name="input_mssql_server_public_access_enabled"></a> [mssql\_server\_public\_access\_enabled](#input\_mssql\_server\_public\_access\_enabled) | Enable public internet access to your MSSQL instance. Be sure to specify 'mssql\_firewall\_ipv4\_allow\_list' to restrict inbound connections | `bool` | `false` | no |
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Project name. Will be used along with `environment` as a prefix for all resources. | `string` | n/a | yes |
| <a name="input_registry_admin_enabled"></a> [registry\_admin\_enabled](#input\_registry\_admin\_enabled) | Do you want to enable access key based authentication for your Container Registry? | `bool` | `true` | no |
| <a name="input_registry_managed_identity_assign_role"></a> [registry\_managed\_identity\_assign\_role](#input\_registry\_managed\_identity\_assign\_role) | Assign the 'AcrPull' Role to the Container App User-Assigned Managed Identity. Note: If you do not have 'Microsoft.Authorization/roleAssignments/write' permission, you will need to manually assign the 'AcrPull' Role to the identity | `bool` | `false` | no |
Expand Down
9 changes: 9 additions & 0 deletions terraform/container-apps-hosting.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ module "azure_container_apps_hosting" {
cdn_frontdoor_vdp_destination_hostname = local.cdn_frontdoor_vdp_destination_hostname
container_apps_allow_ips_inbound = local.container_apps_allow_ips_inbound

enable_mssql_database = local.enable_mssql_database
mssql_server_admin_password = local.mssql_server_admin_password
mssql_azuread_admin_username = local.mssql_azuread_admin_username
mssql_azuread_admin_object_id = local.mssql_azuread_admin_object_id
mssql_database_name = local.mssql_database_name
mssql_firewall_ipv4_allow_list = local.mssql_firewall_ipv4_allow_list
mssql_server_public_access_enabled = local.mssql_server_public_access_enabled
mssql_managed_identity_assign_role = local.mssql_managed_identity_assign_role

enable_monitoring = local.enable_monitoring
monitor_email_receivers = local.monitor_email_receivers
container_health_probe_path = local.container_health_probe_path
Expand Down
8 changes: 8 additions & 0 deletions terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ locals {
enable_cdn_frontdoor_vdp_redirects = var.enable_cdn_frontdoor_vdp_redirects
cdn_frontdoor_vdp_destination_hostname = var.cdn_frontdoor_vdp_destination_hostname
enable_container_app_file_share = var.enable_container_app_file_share
enable_mssql_database = var.enable_mssql_database
mssql_server_admin_password = var.mssql_server_admin_password
mssql_azuread_admin_username = var.mssql_azuread_admin_username
mssql_azuread_admin_object_id = var.mssql_azuread_admin_object_id
mssql_database_name = var.mssql_database_name
mssql_firewall_ipv4_allow_list = var.mssql_firewall_ipv4_allow_list
mssql_server_public_access_enabled = var.mssql_server_public_access_enabled
mssql_managed_identity_assign_role = var.mssql_managed_identity_assign_role
}
47 changes: 47 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,50 @@ variable "container_port" {
type = number
default = 8080
}

variable "enable_mssql_database" {
description = "Set to true to create an Azure SQL server/database, with a private endpoint within the virtual network"
type = bool
}

variable "mssql_server_admin_password" {
description = "The local administrator password for the MSSQL server"
type = string
sensitive = true
}

variable "mssql_azuread_admin_username" {
description = "Username of a User within Azure AD that you want to assign as the SQL Server Administrator"
type = string
}

variable "mssql_azuread_admin_object_id" {
description = "Object ID of a User within Azure AD that you want to assign as the SQL Server Administrator"
type = string
}

variable "mssql_database_name" {
description = "The name of the MSSQL database to create. Must be set if `enable_mssql_database` is true"
type = string
}

variable "mssql_firewall_ipv4_allow_list" {
description = "A list of IPv4 Addresses that require remote access to the MSSQL Server"
type = map(object({
start_ip_range : string,
end_ip_range : optional(string, "")
}))
default = {}
}

variable "mssql_server_public_access_enabled" {
description = "Enable public internet access to your MSSQL instance. Be sure to specify 'mssql_firewall_ipv4_allow_list' to restrict inbound connections"
type = bool
default = false
}

variable "mssql_managed_identity_assign_role" {
description = "Assign the 'Storage Blob Data Contributor' Role to the SQL Server User-Assigned Managed Identity. Note: If you do not have 'Microsoft.Authorization/roleAssignments/write' permission, you will need to manually assign the 'Storage Blob Data Contributor' Role to the identity"
type = bool
default = false
}

0 comments on commit 820a7fe

Please sign in to comment.