You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# PostgreSQL RDS | Create from Snapshot or Create New
3
3
4
-
Provision either a new **enterprise grade** PostgreSQL RDS database or**create a clone of another database from its snapshot**. In this context enterprise grade means
4
+
Provision _either_ a new **enterprise grade** PostgreSQL RDS database _or_**create a clone of another database from its snapshot**. In this context enterprise grade means
5
5
- a 48 long password chosen from a set of 70 characters
6
6
- a non predictable master database username string
7
7
- a high redundancy multi-availability zone database
@@ -10,118 +10,88 @@ Provision either a new **enterprise grade** PostgreSQL RDS database or **create
10
10
- robust options for backup (maintenance) windows and retention period
11
11
- sensible descriptive resource tags
12
12
13
-
## From Snapshot or New
14
13
15
-
This module will conditionally **instantiate from a snapshot** depending on a boolean variable that you provide.
16
-
17
-
## integration test | Jenkinsfile
18
-
19
-
This module comes with an **[integraion test](integration/postgres.test-main.tf)** and a Jenkinsfile so you know that it has been validated day in, day out. It doesn't grow stale and stop working like many other Terraform modules.
20
-
21
-
## Test Drive | Create Two Databases
22
-
23
-
Why not test drive this PostgreSQL terraform module.
## Module Usage | Create New and/or Cloned RDS DBs
34
18
35
-
This is a small insight
19
+
This module will conditionally **instantiate from a snapshot** depending on whether **`var.in_clone_snapshot`** is true or false. If true the RDS ID of the database to clone must be provided. This last available snapshot is chosen as the baseline for creating the cloned database.
The important outputs are the **out_database_hostname**, **out_database_username** and the **out_database_password**.
75
47
76
48
Look at the integration test for the bells and whistles that terraform demands.
77
49
50
+
78
51
---
79
52
53
+
80
54
## Inputs
81
55
82
56
This AWS PostgreSQL database terraform module requires these input variables.
83
57
**Important - the database name must start with a letter (not a digit) and can only contain alphanumerics.**
84
58
85
-
|Imported| Type | Comment |
59
+
|Input Variable| Type | Comment |
86
60
|:-------- |:---- |:------- |
87
-
**in_security_group_id** | String | security group constraining database traffic flows
88
-
**in_db_subnet_ids** | List | private subnet IDs in which to create the database
89
-
**in_database_name** | String | alphanumeric only name to give the new database
90
-
61
+
**in_database_name** | String | **alphanumeric only name** to give the new database and it must start with a letter - note that providing a different name causes terraform to create a different database
62
+
**in_clone_snapshot** | Boolean | if true the in_id_of_db_to_clone must be provided and will cause the database to be created from the last available snapshot of the specified database
63
+
**in_id_of_db_to_clone** | String | this ID must be provided if **`in_clone_snapshot`** is true causing the database to be created from the last available snapshot
64
+
**in_security_group_id** | String | the security group that will constrain traffic to and from the database
65
+
**in_db_subnet_ids** | List | list of private subnet IDs in at least two availability zones (see example) for housing database instances
91
66
92
-
## Outputs
93
67
94
-
| Exported | Type | Comment |
95
-
|:------------------------ |:------ |:------- |
96
-
**out_database_hostname** | String | The addressable hostname of the database
97
-
**out_database_password** | String | password protecting the database account
68
+
### Resource Tag Inputs
98
69
70
+
Most organisations have a mandatory set of tags that must be placed on AWS resources for cost and billing reports. Typically they denote owners and specify whether environments are prod or non-prod.
99
71
100
-
### Contributing
101
72
102
-
Bug reports and pull requests are welcome on GitHub at the https://github.com/devops4me/terraform-aws-postgres-rds page. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
73
+
Additionally you can denote
103
74
104
-
License
105
-
-------
75
+
| Input Variable | Variable Description | Input Example
**`in_ecosystem`** | the ecosystem (environment) name these resources belong to | **`my-app-test`** or **`kubernetes-cluster`**
78
+
**`in_timestamp`** | the timestamp in resource names helps you identify which environment instance resources belong to | **`1911021435`** as **`$(date +%y%m%d%H%M%S)`**
79
+
**`in_description`** | a human readable description usually stating who is creating the resource and when and where | "was created by $USER@$HOSTNAME on $(date)."
106
80
107
-
MIT License
108
-
Copyright (c) 2006 - 2014
81
+
Try **`echo $(date +%y%m%d%H%M%S)`** to check your timestamp and **`echo "was created by $USER@$HOSTNAME on $(date)."`** to check your description. Here is how you can send these values to terraform.
109
82
110
-
Permission is hereby granted, free of charge, to any person obtaining
111
-
a copy of this software and associated documentation files (the
112
-
'Software'), to deal in the Software without restriction, including
113
-
without limitation the rights to use, copy, modify, merge, publish,
114
-
distribute, sublicense, and/or sell copies of the Software, and to
115
-
permit persons to whom the Software is furnished to do so, subject to
Name ="db-subnet-group-${var.in_ecosystem_name}-${var.in_tag_timestamp}"
173
-
Desc ="This RDS postgres database subnet group for ${var.in_ecosystem_name}${var.in_tag_description}"
172
+
Name ="db-subnet-group-${var.in_ecosystem}-${var.in_timestamp}"
173
+
Desc ="This RDS postgres database subnet group for ${var.in_ecosystem}${var.in_description}"
174
174
}
175
175
176
176
database_tags={
177
177
Name = var.in_database_name
178
-
Id ="${var.in_database_name}-${var.in_ecosystem_name}-${var.in_tag_timestamp}"
178
+
Id ="${var.in_database_name}-${var.in_ecosystem}-${var.in_timestamp}"
179
179
}
180
180
181
181
cloned_database_tags={
182
-
Desc ="This PostgreSQL database named ${var.in_database_name} was cloned from snapshot ${data.aws_db_snapshot.from[0].id} and ${var.in_tag_description}"
182
+
Desc ="This PostgreSQL database named ${var.in_database_name} was cloned from snapshot ${data.aws_db_snapshot.from[0].id} and ${var.in_description}"
183
183
}
184
184
185
185
fresh_database_tags={
186
-
Desc ="This brand new PostgreSQL database named ${var.in_database_name}${var.in_tag_description}"
186
+
Desc ="This brand new PostgreSQL database named ${var.in_database_name}${var.in_description}"
0 commit comments