This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
115 lines (93 loc) · 2.78 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
terraform {
required_version = ">= 1.1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.63"
}
}
}
provider "aws" {
region = local.region
default_tags {
tags = {
Env = local.env
Region = local.region
OwnedBy = "Padok"
ManagedByTF = true
}
}
}
provider "aws" {
region = local.backups_region
alias = "backups"
default_tags {
tags = {
Env = local.env
Region = local.backups_region
OwnedBy = "Padok"
ManagedByTF = true
}
}
}
# some variables to make life easier
locals {
name = "basic_private"
env = "test"
region = "eu-west-3"
backups_region = "eu-west-2"
}
################################################################################
# RDS
################################################################################
module "rds" {
source = "../.."
providers = {
aws = aws
aws.backups = aws.backups
}
## GENERAL
identifier = "rds-poc-library-cross-region-backups"
## DATABASE
engine = "postgres"
engine_version = "13.4"
db_parameter_family = "postgres13"
name = "aws_rds_instance_postgresql_db_poc_cross_region_backups"
username = "aws_rds_instance_postgresql_user_poc_cross_region_backups"
parameters = [{
name = "application_name"
value = "mydb"
apply_method = "immediate"
},
{
name = "rds.rds_superuser_reserved_connections"
value = 4
apply_method = "pending-reboot"
}]
## NETWORK
subnet_ids = module.my_vpc.private_subnets_ids
vpc_id = module.my_vpc.vpc_id
security_group_ids = [aws_security_group.a_basic_security_group.id]
}
# Use this security group to allow access to the RDS instance
# For example by adding your EC2 instance to the security group
resource "aws_security_group" "a_basic_security_group" {
name = "a_basic_security_group"
description = "A example of a security group for my backend"
vpc_id = module.my_vpc.vpc_id
}
################################################################################
# Supporting resources
################################################################################
module "my_vpc" {
source = "[email protected]:padok-team/terraform-aws-network.git"
vpc_name = local.name
vpc_availability_zone = ["eu-west-3a", "eu-west-3b"]
vpc_cidr = "10.142.0.0/16"
public_subnet_cidr = ["10.142.1.0/28", "10.142.2.0/28"] # small subnets for natgateway
private_subnet_cidr = ["10.142.64.0/18", "10.142.128.0/18"] # big subnet for EKS
single_nat_gateway = true # warning : not for production !
tags = {
CostCenter = "Network"
}
}