forked from terraform-aws-modules/terraform-aws-rds-aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
82 lines (65 loc) · 2.43 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
provider "aws" {
region = local.region
}
locals {
name = "postgresql"
region = "eu-west-1"
tags = {
Owner = "user"
Environment = "dev"
}
}
################################################################################
# Supporting Resources
################################################################################
resource "random_password" "master" {
length = 10
}
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"]
tags = local.tags
}
################################################################################
# RDS Aurora Module
################################################################################
module "aurora" {
source = "../../"
name = local.name
engine = "aurora-postgresql"
engine_version = "11.9"
instance_type = "db.r5.large"
instance_type_replica = "db.t3.medium"
vpc_id = module.vpc.vpc_id
db_subnet_group_name = module.vpc.database_subnet_group_name
create_security_group = true
allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks
replica_count = 2
iam_database_authentication_enabled = true
password = random_password.master.result
create_random_password = false
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"]
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
}