forked from Azure/terraform-azurerm-database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
41 lines (37 loc) · 1.65 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
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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"
# }
resource "azurerm_resource_group" "rg" {
name = "${var.resource_group_name}"
location = "${var.location}"
}
resource "azurerm_sql_database" "db" {
name = "${var.db_name}"
resource_group_name = "${azurerm_resource_group.rg.name}"
location = "${var.location}"
edition = "${var.db_edition}"
collation = "${var.collation}"
server_name = "${azurerm_sql_server.server.name}"
create_mode = "Default"
requested_service_objective_name = "${var.service_objective_name}"
tags = "${var.tags}"
}
resource "azurerm_sql_server" "server" {
name = "${var.db_name}-sqlsvr"
resource_group_name = "${azurerm_resource_group.rg.name}"
location = "${var.location}"
version = "${var.server_version}"
administrator_login = "${var.sql_admin_username}"
administrator_login_password = "${var.sql_password}"
tags = "${var.tags}"
}
resource "azurerm_sql_firewall_rule" "fw" {
name = "${var.db_name}-fwrules"
resource_group_name = "${azurerm_resource_group.rg.name}"
server_name = "${azurerm_sql_server.server.name}"
start_ip_address = "${var.start_ip_address}"
end_ip_address = "${var.end_ip_address}"
}