-
Notifications
You must be signed in to change notification settings - Fork 0
/
rds.tf
64 lines (57 loc) · 1.75 KB
/
rds.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
module "rds_cluster_aurora_postgresql_serverless" {
source = "git::https://github.com/cloudposse/terraform-aws-rds-cluster.git?ref=master"
namespace = "prnx-perm"
stage = "prod"
name = ""
engine = "aurora-postgresql"
engine_mode = "serverless"
cluster_family = "aurora-postgresql10"
cluster_size = "0"
admin_user = "prnx_dbadmin"
admin_password = "ug7cae7RahlahRoe6Aefeata"
db_name = "perm"
db_port = "5432"
vpc_id = "${module.vpc.vpc_id}"
security_groups = [
"${module.web_server_sg.this_security_group_id}",
"${aws_security_group.aurora_postgresql_sg.id}"
]
subnets = "${module.vpc.database_subnets}"
#zone_id = "Zxxxxxxxx"
retention_period = 10
scaling_configuration = [
{
auto_pause = true
max_capacity = 4
min_capacity = 2
seconds_until_auto_pause = 300
}
]
tags = {
Terraform = "true"
Environment = "prnx-perm"
}
}
# create IAM role for monitoring
resource "aws_iam_role" "enhanced_monitoring" {
name = "rds-cluster-prnx-perm"
assume_role_policy = data.aws_iam_policy_document.enhanced_monitoring.json
}
# Attach Amazon's managed policy for RDS enhanced monitoring
resource "aws_iam_role_policy_attachment" "enhanced_monitoring" {
role = aws_iam_role.enhanced_monitoring.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"
}
# allow rds to assume this role
data "aws_iam_policy_document" "enhanced_monitoring" {
statement {
actions = [
"sts:AssumeRole",
]
effect = "Allow"
principals {
type = "Service"
identifiers = ["monitoring.rds.amazonaws.com"]
}
}
}