|
1 | 1 |
|
2 |
| -# Create PostgreSQL RDS Database | Terraform Module |
| 2 | +# PostgreSQL RDS | Enterprise Grade | Terraform Module |
3 | 3 |
|
4 |
| -Create a simple 32G AWS PostgreSQL RDS database. This module suits rapid proof of concept development - it is not designed to provision a production quality enterprise database. |
| 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 | +- a 48 long password chosen from a set of 70 characters |
| 6 | +- a non predictable master database username string |
| 7 | +- a high redundancy multi-availability zone database |
| 8 | +- private subnet residency in a non-default VPC (if you so wish) |
| 9 | +- behind the scenes encryption at rest |
| 10 | +- robust options for backup (maintenance) windows and retention period |
| 11 | +- sensible descriptive resource tags |
5 | 12 |
|
6 |
| -The username is readwrite and the database listens on port 5432. Just provide a security group, private subnet ids, the database name and the ubiquitous tag information. |
| 13 | +## From Snapshot or New |
7 | 14 |
|
8 |
| -The only outputs needed are the out_database_hostname and the simple terraform generated out_database_password. |
| 15 | +This module will conditionally **instantiate from a snapshot** depending on a boolean variable that you provide. |
9 | 16 |
|
10 |
| -## Usage |
| 17 | +## integration test | Jenkinsfile |
11 | 18 |
|
12 |
| - locals |
13 |
| - { |
14 |
| - ecosystem_name = "business-app" |
15 |
| - } |
| 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. |
16 | 20 |
|
17 |
| - module postgres_db |
18 |
| - { |
19 |
| - source = "github.com/devops4me/terraform-aws-postgres-rds" |
20 |
| - in_security_group_id = "${ module.security-group.out_security_group_id }" |
21 |
| - in_db_subnet_ids = "${ module.vpc-network.out_private_subnet_ids }" |
| 21 | +## Test Drive | Create Two Databases |
22 | 22 |
|
23 |
| - in_database_name = "businessdata" |
| 23 | +Why not test drive this PostgreSQL terraform module. |
24 | 24 |
|
25 |
| - in_ecosystem_name = "${ local.ecosystem_name }" |
26 |
| - in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }" |
27 |
| - in_tag_description = "${ module.resource-tags.out_tag_description }" |
28 |
| - } |
| 25 | +``` |
| 26 | +git clone https://github.com/devops4me/terraform-aws-postgres-rds |
| 27 | +cd terraform-aws-postgres-rds/integration |
| 28 | +# Export your AWS Credentials and Region |
| 29 | +terraform init |
| 30 | +terraform deploy |
| 31 | +``` |
| 32 | + |
| 33 | +## Usage | Creating New and Cloned Databases |
29 | 34 |
|
30 |
| - module vpc-network |
31 |
| - { |
32 |
| - source = "github.com/devops4me/terraform-aws-vpc-network" |
33 |
| - in_vpc_cidr = "10.66.0.0/16" |
34 |
| - in_num_public_subnets = 3 |
35 |
| - in_num_private_subnets = 3 |
| 35 | +This is a small insight |
36 | 36 |
|
37 |
| - in_ecosystem_name = "${ local.ecosystem_name }" |
38 |
| - in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }" |
39 |
| - in_tag_description = "${ module.resource-tags.out_tag_description }" |
| 37 | +``` |
| 38 | + locals { |
| 39 | + ecosystem_name = "canary" |
| 40 | + fresh_db_name = "freshdb" |
| 41 | + clone_db_name = "clonedb" |
40 | 42 | }
|
41 | 43 |
|
42 |
| - module security-group |
43 |
| - { |
44 |
| - source = "github.com/devops4me/terraform-aws-security-group" |
45 |
| - in_ingress = [ "ssh", "https", ] |
46 |
| - in_vpc_id = "${ module.vpc-network.out_vpc_id }" |
| 44 | + module fresh_db { |
| 45 | +
|
| 46 | + source = "github.com/devops4me/terraform-aws-postgres-rds" |
| 47 | +
|
| 48 | + in_security_group_id = module.security-group.out_security_group_id |
| 49 | + in_db_subnet_ids = module.vpc-network.out_private_subnet_ids |
| 50 | + in_database_name = local.fresh_db_name |
47 | 51 |
|
48 |
| - in_ecosystem_name = "${ local.ecosystem_name }" |
49 |
| - in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }" |
50 |
| - in_tag_description = "${ module.resource-tags.out_tag_description }" |
| 52 | + in_ecosystem_name = local.ecosystem_name |
| 53 | + in_tag_timestamp = module.resource-tags.out_tag_timestamp |
| 54 | + in_tag_description = module.resource-tags.out_tag_description |
51 | 55 | }
|
52 | 56 |
|
53 |
| - module resource-tags |
54 |
| - { |
55 |
| - source = "github.com/devops4me/terraform-aws-resource-tags" |
| 57 | + module clone_db { |
| 58 | +
|
| 59 | + source = "github.com/devops4me/terraform-aws-postgres-rds" |
| 60 | +
|
| 61 | + in_security_group_id = module.security-group.out_security_group_id |
| 62 | + in_db_subnet_ids = module.vpc-network.out_private_subnet_ids |
| 63 | + in_id_of_db_to_clone = var.in_id_of_db_to_clone |
| 64 | + in_clone_snapshot = true |
| 65 | +
|
| 66 | + in_database_name = local.clone_db_name |
| 67 | +
|
| 68 | + in_ecosystem_name = local.ecosystem_name |
| 69 | + in_tag_timestamp = module.resource-tags.out_tag_timestamp |
| 70 | + in_tag_description = module.resource-tags.out_tag_description |
56 | 71 | }
|
| 72 | +``` |
57 | 73 |
|
| 74 | +The important outputs are the **out_database_hostname**, **out_database_username** and the **out_database_password**. |
58 | 75 |
|
59 |
| -The important outputs are the **out_database_hostname** and the terraform generated **out_database_password**. |
| 76 | +Look at the integration test for the bells and whistles that terraform demands. |
60 | 77 |
|
| 78 | +--- |
61 | 79 |
|
62 | 80 | ## Inputs
|
63 | 81 |
|
|
0 commit comments