-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.tf
28 lines (25 loc) · 1.11 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# provider "azurerm" {
# subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID"
# client_id = "REPLACE-WITH-YOUR-CLIENT-ID"
# client_secret = "REPLACE-WITH-YOUR-CLIENT-SECRET"
# tenant_id = "REPLACE-WITH-YOUR-TENANT-ID"
# }
locals {
db_server = "${split(".", var.db_server_fqdn)}"
}
resource "azurerm_sql_database" "db" {
name = "${var.db_name}"
location = "${var.location}"
resource_group_name = "${var.resource_group}"
server_name = "${local.db_server[0]}"
edition = "${var.db_edition}"
collation = "${var.collation}"
requested_service_objective_name = "${var.service_objective_name}"
create_mode = "Default"
provisioner "local-exec" {
environment = {
SQLCMDPASSWORD = var.sql_admin_password # Required so that the password does not spill to console when the resource fails
}
command = "sqlcmd -U ${var.sql_admin_username} -S ${var.db_server_fqdn} -d ${var.db_name} -i ${var.init_script_file} -o ${var.log_file}"
}
}