forked from terraform-aws-modules/terraform-aws-rds-aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
85 lines (74 loc) · 2.49 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
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
76
77
78
79
80
81
82
83
84
85
provider "aws" {
region = "us-east-1"
}
variable "azs" {
type = "list"
default = [
"us-east-1a",
"us-east-1b",
"us-east-1c",
]
}
module "aurora" {
source = "../../"
name = "aurora-example"
engine = "aurora-postgresql"
engine_version = "9.6.3"
subnets = ["${module.vpc.database_subnets}"]
availability_zones = ["${var.azs}"]
vpc_id = "${module.vpc.vpc_id}"
replica_count = 1
replica_scale_enabled = true
replica_scale_min = 1
replica_scale_max = 5
monitoring_interval = 60
instance_type = "db.r4.large"
apply_immediately = true
skip_final_snapshot = true
db_parameter_group_name = "${aws_db_parameter_group.aurora_db_postgres96_parameter_group.id}"
db_cluster_parameter_group_name = "${aws_rds_cluster_parameter_group.aurora_cluster_postgres96_parameter_group.id}"
}
resource "aws_db_parameter_group" "aurora_db_postgres96_parameter_group" {
name = "test-aurora-db-postgres96-parameter-group"
family = "aurora-postgresql9.6"
description = "test-aurora-db-postgres96-parameter-group"
}
resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres96_parameter_group" {
name = "test-aurora-postgres96-cluster-parameter-group"
family = "aurora-postgresql9.6"
description = "test-aurora-postgres96-cluster-parameter-group"
}
resource "aws_security_group" "app_servers" {
name = "app-servers"
description = "For application servers"
vpc_id = "${module.vpc.vpc_id}"
}
resource "aws_security_group_rule" "allow_access" {
type = "ingress"
from_port = "${module.aurora.this_rds_cluster_port}"
to_port = "${module.aurora.this_rds_cluster_port}"
protocol = "tcp"
source_security_group_id = "${aws_security_group.app_servers.id}"
security_group_id = "${module.aurora.this_security_group_id}"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "example"
cidr = "10.0.0.0/16"
azs = ["${var.azs}"]
private_subnets = [
"10.0.1.0/24",
"10.0.2.0/24",
"10.0.3.0/25",
]
public_subnets = [
"10.0.4.0/24",
"10.0.5.0/24",
"10.0.6.0/25",
]
database_subnets = [
"10.0.7.0/24",
"10.0.8.0/24",
"10.0.9.0/25",
]
}