generated from kedacore/github-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> * add sql server Signed-off-by: Jorge Turrado <[email protected]> --------- Signed-off-by: Jorge Turrado <[email protected]>
- Loading branch information
Showing
7 changed files
with
194 additions
and
3 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
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
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
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,86 @@ | ||
terraform { | ||
required_providers { | ||
mssql = { | ||
source = "betr-io/mssql" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features {} | ||
skip_provider_registration = true | ||
} | ||
|
||
locals { | ||
sql_server_name = "${var.unique_project_name}-e2e-sql-server" | ||
sql_server_network_name = "${var.unique_project_name}-e2e-sql-server-net" | ||
sql_server_subnet_name = "${var.unique_project_name}-e2e-sql-server-subnet" | ||
} | ||
|
||
data "azurerm_client_config" "current" {} | ||
|
||
data "azurerm_resource_group" "rg" { | ||
name = var.resource_group_name | ||
} | ||
|
||
resource "random_password" "admin_password" { | ||
length = 32 | ||
special = false | ||
min_lower = 1 | ||
min_numeric = 1 | ||
min_upper = 1 | ||
} | ||
|
||
resource "random_string" "admin_username" { | ||
length = 8 | ||
special = false | ||
numeric = false | ||
min_lower = 1 | ||
min_upper = 1 | ||
} | ||
|
||
resource "azurerm_mssql_server" "server" { | ||
name = local.sql_server_name | ||
resource_group_name = data.azurerm_resource_group.rg.name | ||
location = var.location | ||
version = var.sql_version | ||
minimum_tls_version = "1.2" | ||
|
||
administrator_login = random_string.admin_username.result | ||
administrator_login_password = random_password.admin_password.result | ||
|
||
azuread_administrator { | ||
login_username = "AzureAD Admin" | ||
object_id = data.azurerm_client_config.current.object_id | ||
} | ||
|
||
tags = var.tags | ||
} | ||
|
||
resource "azurerm_mssql_database" "database" { | ||
name = var.sql_database_name | ||
server_id = azurerm_mssql_server.server.id | ||
max_size_gb = var.sql_storage_gb | ||
sku_name = var.sql_sku_name | ||
tags = var.tags | ||
} | ||
|
||
provider "mssql" { | ||
debug = "true" | ||
} | ||
|
||
resource "mssql_user" "external_users" { | ||
server { | ||
host = azurerm_mssql_server.server.fully_qualified_domain_name | ||
login { | ||
username = random_string.admin_username.result | ||
password = random_password.admin_password.result | ||
} | ||
} | ||
|
||
database = azurerm_mssql_database.database.name | ||
username = "msi-admin-${azurerm_mssql_database.database.name}" | ||
object_id = var.user_managed_identity_sql_ad_admin.client_id | ||
|
||
roles = ["db_owner"] | ||
} |
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,16 @@ | ||
output "sql_server_fqdn" { | ||
value = azurerm_mssql_server.server.fully_qualified_domain_name | ||
} | ||
|
||
output "sql_database_name" { | ||
value = var.sql_database_name | ||
} | ||
|
||
output "admin_username" { | ||
value = random_string.admin_username.result | ||
} | ||
|
||
output "admin_password" { | ||
value = random_password.admin_password.result | ||
} | ||
|
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,54 @@ | ||
variable "resource_group_name" { | ||
type = string | ||
description = "Resource group name where event hub will be placed" | ||
} | ||
|
||
variable "location" { | ||
type = string | ||
description = "Location to place the resource" | ||
default = "westeurope" | ||
} | ||
|
||
variable "unique_project_name" { | ||
type = string | ||
description = "Value to make unique every resource name generated" | ||
} | ||
|
||
variable "tags" { | ||
type = map(any) | ||
description = "Tags to apply on resources accepting it" | ||
} | ||
|
||
variable "sql_version" { | ||
type = string | ||
description = "Sql version to use" | ||
default = "12.0" | ||
} | ||
|
||
variable "sql_sku_name" { | ||
type = string | ||
description = "The SKU Name" | ||
default = "BC_Gen4" | ||
} | ||
|
||
variable "sql_storage_gb" { | ||
type = number | ||
description = "The max storage allowed" | ||
default = 5 | ||
} | ||
|
||
variable "sql_vcores" { | ||
type = number | ||
description = "The vcores allowed" | ||
default = 1 | ||
} | ||
variable "sql_database_name" { | ||
type = string | ||
description = "Database name to create inside the server" | ||
default = "test_db" | ||
} | ||
|
||
variable "user_managed_identity_sql_ad_admin" { | ||
type = any | ||
description = "User managed identitiy that will be granted admin access on the SQL server" | ||
} |
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