-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrds-mssql.tf
75 lines (65 loc) · 2.44 KB
/
rds-mssql.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
resource "aws_db_subnet_group" "default_rds_mssql" {
name = "${var.environment}-rds-mssql-subnet-group"
description = "The ${var.environment} rds-mssql private subnet group."
subnet_ids = ["${var.vpc_subnet_ids}"]
tags {
Name = "${var.environment}-rds-mssql-subnet-group"
Env = "${var.environment}"
}
}
resource "aws_security_group" "rds_mssql_security_group" {
name = "${var.environment}-all-rds-mssql-internal"
description = "${var.environment} allow all vpc traffic to rds mssql."
vpc_id = "${var.vpc_id}"
ingress {
from_port = 1433
to_port = 1433
protocol = "tcp"
cidr_blocks = ["${var.vpc_cidr_blocks}"]
}
tags {
Name = "${var.environment}-all-rds-mssql-internal"
Env = "${var.environment}"
}
}
resource "aws_security_group" "rds_mssql_security_group_vpn" {
name = "${var.environment}-all-rds-mssql-vpn"
description = "Allow all inbound traffic from vpn to rds mssql."
vpc_id = "${var.vpc_id}"
ingress {
from_port = 1433
to_port = 1433
protocol = "tcp"
cidr_blocks = ["${var.vpc_cidr_blocks_vpn}"]
}
tags {
Name = "${var.environment}-all-rds-mssql-vpn"
Env = "${var.environment}"
}
}
resource "aws_db_instance" "default_mssql" {
depends_on = ["aws_db_subnet_group.default_rds_mssql"]
identifier = "${var.environment}-mssql"
allocated_storage = "${var.rds_allocated_storage}"
license_model = "license-included"
storage_type = "gp2"
engine = "sqlserver-se"
engine_version = "12.00.4422.0.v1"
instance_class = "${var.rds_instance_class}"
multi_az = "${var.rds_multi_az}"
username = "${var.mssql_admin_username}"
password = "${var.mssql_admin_password}"
vpc_security_group_ids = ["${aws_security_group.rds_mssql_security_group.id}", "${aws_security_group.rds_mssql_security_group_vpn.id}"]
db_subnet_group_name = "${aws_db_subnet_group.default_rds_mssql.id}"
backup_retention_period = 3
skip_final_snapshot = "${var.skip_final_snapshot}"
final_snapshot_identifier = "${var.environment}-mssql-final-snapshot"
}
// Identifier of the mssql DB instance.
output "mssql_id" {
value = "${aws_db_instance.default_mssql.id}"
}
// Address of the mssql DB instance.
output "mssql_address" {
value = "${aws_db_instance.default_mssql.address}"
}