Skip to content

Commit 78fd24a

Browse files
authored
Initial implementation (#1)
1 parent ac40813 commit 78fd24a

30 files changed

+2790
-6
lines changed

.github/mergify.yml

+7
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ pull_request_rules:
5656
changes_requested: true
5757
approved: true
5858
message: "This Pull Request has been updated, so we're dismissing all reviews."
59+
60+
- name: "close Pull Requests without files changed"
61+
conditions:
62+
- "#files=0"
63+
actions:
64+
close:
65+
message: "This pull request has been automatically closed by Mergify because there are no longer any changes."

.github/workflows/auto-format.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
auto-format:
88
runs-on: ubuntu-latest
9-
container: cloudposse/build-harness:slim-latest
9+
container: cloudposse/build-harness:latest
1010
steps:
1111
# Checkout the pull request branch
1212
# "An action in a workflow run can’t trigger a new workflow run. For example, if an action pushes code using
@@ -29,6 +29,8 @@ jobs:
2929
- name: Auto Format
3030
if: github.event.pull_request.state == 'open'
3131
shell: bash
32+
env:
33+
GITHUB_TOKEN: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}"
3234
run: make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness pr/auto-format/host
3335

3436
# Commit changes (if any) to the PR branch

.github/workflows/auto-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: auto-release
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77

88
jobs:
99
publish:
1010
runs-on: ubuntu-latest
1111
steps:
12-
# Get PR from merged commit to master
12+
# Get PR from merged commit to main
1313
- uses: actions-ecosystem/action-get-merged-pull-request@v1
1414
id: get-merged-pull-request
1515
with:

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Compiled files
22
*.tfstate
33
*.tfstate.backup
4+
**.terraform.lock.hcl
5+
**.terraform.tfstate.lock.info
46

57
# Module directory
68
.terraform

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
181+
boilerplate notice, with the fields enclosed by brackets "{}"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a

README.md

+516-2
Large diffs are not rendered by default.

README.yaml

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: terraform-aws-rds-db-proxy
2+
3+
tags:
4+
- aws
5+
- terraform
6+
- terraform-modules
7+
- databases
8+
- rds
9+
- rds-database
10+
- proxy
11+
- proxy-pool
12+
- database-proxy
13+
- connection
14+
- connections
15+
- pool
16+
- connection-pool
17+
- aurora
18+
- mysql
19+
- postgres
20+
- cluster
21+
22+
categories:
23+
- terraform-modules/databases
24+
25+
license: APACHE2
26+
27+
github_repo: cloudposse/terraform-aws-rds-db-proxy
28+
29+
badges:
30+
- name: Latest Release
31+
image: https://img.shields.io/github/release/cloudposse/terraform-aws-rds-db-proxy.svg
32+
url: https://github.com/cloudposse/terraform-aws-rds-db-proxy/releases/latest
33+
- name: Slack Community
34+
image: https://slack.cloudposse.com/badge.svg
35+
url: https://slack.cloudposse.com
36+
37+
related:
38+
- name: terraform-aws-rds-cluster
39+
description: Terraform module to provision an RDS Aurora cluster for MySQL or Postgres.
40+
url: https://github.com/cloudposse/terraform-aws-rds-cluster
41+
- name: terraform-aws-rds
42+
description: Terraform module to provision AWS RDS instances.
43+
url: https://github.com/cloudposse/terraform-aws-rds
44+
- name: terraform-aws-rds-cloudwatch-sns-alarms
45+
description: Terraform module that configures important RDS alerts using CloudWatch and sends them to an SNS topic.
46+
url: https://github.com/cloudposse/terraform-aws-rds-cloudwatch-sns-alarms
47+
- name: terraform-aws-rds-replica
48+
description: Terraform module to provision AWS RDS replica instances. These are best suited for reporting purposes.
49+
url: https://github.com/cloudposse/terraform-aws-rds-replica
50+
- name: terraform-aws-backup
51+
description: Terraform module to provision AWS Backup, a fully managed backup service that makes it easy to centralize and automate
52+
the back up of data across AWS services such as Amazon EBS volumes, Amazon EC2 instances, Amazon RDS databases,
53+
Amazon DynamoDB tables, Amazon EFS file systems, and AWS Storage Gateway volumes.
54+
url: https://github.com/cloudposse/terraform-aws-backup
55+
56+
description: |-
57+
Terraform module to provision an Amazon [RDS Proxy](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html) for MySQL or Postgres.
58+
59+
usage: |2-
60+
61+
For a complete example, see [examples/complete](examples/complete).
62+
63+
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
64+
(which tests and deploys the example on AWS), see [test](test).
65+
66+
```hcl
67+
module "vpc" {
68+
source = "cloudposse/vpc/aws"
69+
version = "0.21.1"
70+
71+
cidr_block = "172.16.0.0/16"
72+
73+
context = module.this.context
74+
}
75+
76+
module "subnets" {
77+
source = "cloudposse/dynamic-subnets/aws"
78+
version = "0.38.0"
79+
80+
availability_zones = var.availability_zones
81+
vpc_id = module.vpc.vpc_id
82+
igw_id = module.vpc.igw_id
83+
cidr_block = module.vpc.vpc_cidr_block
84+
nat_gateway_enabled = false
85+
nat_instance_enabled = false
86+
87+
context = module.this.context
88+
}
89+
90+
resource "random_password" "admin_password" {
91+
count = var.database_password == "" || var.database_password == null ? 1 : 0
92+
length = 33
93+
special = false
94+
override_special = "!#$%^&*()<>-_"
95+
}
96+
97+
locals {
98+
database_password = var.database_password != "" && var.database_password != null ? var.database_password : join("", random_password.admin_password.*.result)
99+
100+
username_password = {
101+
username = var.database_user
102+
password = local.database_password
103+
}
104+
105+
auth = [
106+
{
107+
auth_scheme = "SECRETS"
108+
description = "Access the database instance using username and password from AWS Secrets Manager"
109+
iam_auth = "DISABLED"
110+
secret_arn = aws_secretsmanager_secret.rds_username_and_password.arn
111+
}
112+
]
113+
}
114+
115+
module "rds_instance" {
116+
source = "cloudposse/rds/aws"
117+
version = "0.34.0"
118+
119+
database_name = var.database_name
120+
database_user = var.database_user
121+
database_password = local.database_password
122+
database_port = var.database_port
123+
multi_az = var.multi_az
124+
storage_type = var.storage_type
125+
allocated_storage = var.allocated_storage
126+
storage_encrypted = var.storage_encrypted
127+
engine = var.engine
128+
engine_version = var.engine_version
129+
instance_class = var.instance_class
130+
db_parameter_group = var.db_parameter_group
131+
publicly_accessible = var.publicly_accessible
132+
vpc_id = module.vpc.vpc_id
133+
subnet_ids = module.subnets.private_subnet_ids
134+
security_group_ids = [module.vpc.vpc_default_security_group_id]
135+
apply_immediately = var.apply_immediately
136+
137+
context = module.this.context
138+
}
139+
140+
resource "aws_secretsmanager_secret" "rds_username_and_password" {
141+
name = module.this.id
142+
description = "RDS username and password"
143+
recovery_window_in_days = 0
144+
tags = module.this.tags
145+
}
146+
147+
resource "aws_secretsmanager_secret_version" "rds_username_and_password" {
148+
secret_id = aws_secretsmanager_secret.rds_username_and_password.id
149+
secret_string = jsonencode(local.username_password)
150+
}
151+
152+
module "rds_proxy" {
153+
source = "cloudposse/rds-db-proxy/aws"
154+
version = "0.1.0"
155+
156+
db_instance_identifier = module.rds_instance.instance_id
157+
auth = local.auth
158+
vpc_security_group_ids = [module.vpc.vpc_default_security_group_id]
159+
vpc_subnet_ids = module.subnets.public_subnet_ids
160+
161+
debug_logging = var.debug_logging
162+
engine_family = var.engine_family
163+
idle_client_timeout = var.idle_client_timeout
164+
require_tls = var.require_tls
165+
connection_borrow_timeout = var.connection_borrow_timeout
166+
init_query = var.init_query
167+
max_connections_percent = var.max_connections_percent
168+
max_idle_connections_percent = var.max_idle_connections_percent
169+
session_pinning_filters = var.session_pinning_filters
170+
existing_iam_role_arn = var.existing_iam_role_arn
171+
172+
context = module.this.context
173+
}
174+
175+
```
176+
177+
examples: |-
178+
Review the [complete example](examples/complete) to see how to use this module.
179+
180+
include:
181+
- docs/targets.md
182+
- docs/terraform.md
183+
184+
contributors:
185+
- name: Erik Osterman
186+
github: osterman
187+
- name: Andriy Knysh
188+
github: aknysh

0 commit comments

Comments
 (0)