forked from terraform-aws-modules/terraform-aws-rds-aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
95 lines (77 loc) · 2.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
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
86
87
88
89
90
91
92
93
94
95
provider "aws" {
region = local.region
}
locals {
name = "custom-instance-settings"
region = "eu-west-1"
tags = {
Owner = "user"
Environment = "dev"
}
}
################################################################################
# Supporting Resources
################################################################################
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 3.0"
name = local.name
cidr = "10.99.0.0/18"
azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"]
private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"]
enable_dns_hostnames = true
enable_dns_support = true
tags = local.tags
}
################################################################################
# RDS Aurora Module
################################################################################
module "aurora" {
source = "../../"
name = local.name
engine = "aurora-postgresql"
engine_version = "11.9"
instance_type = "db.r5.large"
vpc_id = module.vpc.vpc_id
db_subnet_group_name = module.vpc.database_subnet_group_name
create_security_group = true
security_group_description = ""
allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks
replica_count = 3
apply_immediately = true
skip_final_snapshot = true
db_parameter_group_name = aws_db_parameter_group.example.id
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example.id
enabled_cloudwatch_logs_exports = ["postgresql"]
instances_parameters = [
# List index should be equal to `replica_count`
# Omitted keys replaced by module defaults
{
instance_type = "db.r5.2xlarge"
publicly_accessible = true
},
{
instance_type = "db.r5.2xlarge"
},
{
instance_name = "reporting"
instance_type = "db.r5.large"
instance_promotion_tier = 15
}
]
tags = local.tags
}
resource "aws_db_parameter_group" "example" {
name = "${local.name}-aurora-db-postgres11-parameter-group"
family = "aurora-postgresql11"
description = "${local.name}-aurora-db-postgres11-parameter-group"
tags = local.tags
}
resource "aws_rds_cluster_parameter_group" "example" {
name = "${local.name}-aurora-postgres11-cluster-parameter-group"
family = "aurora-postgresql11"
description = "${local.name}-aurora-postgres11-cluster-parameter-group"
tags = local.tags
}