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
Copy file name to clipboardExpand all lines: README.md
+27-1
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ This Terraform module provisions an Amazon RDS PostgreSQL database on AWS. Amazo
17
17
6. Supports encryption at rest using AWS Key Management Service (KMS) for enhanced security.
18
18
7. Enables fine-grained control over network access through security groups and VPC settings.
19
19
8. Offers customizable tags for resource categorization and management.
20
+
9. CloudWatch Alerts: Set up CloudWatch alarms to monitor the health and performance of your Redis cluster. Integrate these alarms with AWS Simple Notification Service (SNS) to receive real-time alerts. Use AWS Lambda functions to customize your alerting logic, and send notifications to Slack channels for immediate visibility into your RDS POstgresql status.
20
21
21
22
## Usage Examples
22
23
```hcl
@@ -41,9 +42,15 @@ module "rds-pg" {
41
42
deletion_protection = false
42
43
allowed_security_groups = ["sg-013cbf880"]
43
44
final_snapshot_identifier_prefix = "final"
45
+
cloudwatch_metric_alarms_enabled = true
46
+
alarm_cpu_threshold_percent = 70
47
+
disk_free_storage_space = "10000000" # in bytes
48
+
slack_username = "John"
49
+
slack_channel = "skaf-dev"
50
+
slack_webhook_url = "https://hooks/xxxxxxxx"
44
51
}
45
52
```
46
-
Refer [examples](https://github.com/squareops/terraform-aws-rds-postgresql/tree/main/example/complete) for more details.
53
+
Refer [examples](https://github.com/squareops/terraform-aws-rds-postgresql/tree/main/examples/complete) for more details.
47
54
48
55
## IAM Permissions
49
56
The required IAM permissions to create resources from this module can be found [here](https://github.com/squareops/terraform-aws-rds-postgresql/blob/main/IAM.md)
@@ -60,21 +67,31 @@ The required IAM permissions to create resources from this module can be found [
| <aname="input_additional_tags"></a> [additional\_tags](#input\_additional\_tags)| A map of additional tags to apply to the AWS resources |`map(string)`| <pre>{<br> "automation": "true"<br>}</pre> | no |
103
+
| <aname="input_alarm_actions"></a> [alarm\_actions](#input\_alarm\_actions)| Alarm action list |`list(string)`|`[]`| no |
104
+
| <aname="input_alarm_cpu_threshold_percent"></a> [alarm\_cpu\_threshold\_percent](#input\_alarm\_cpu\_threshold\_percent)| CPU threshold alarm level |`number`|`75`| no |
86
105
| <aname="input_allocated_storage"></a> [allocated\_storage](#input\_allocated\_storage)| The allocated storage capacity for the database in gibibytes (GiB) |`number`|`20`| no |
87
106
| <aname="input_allowed_cidr_blocks"></a> [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks)| A list of CIDR blocks that are allowed to access the database |`list(any)`|`[]`| no |
88
107
| <aname="input_allowed_security_groups"></a> [allowed\_security\_groups](#input\_allowed\_security\_groups)| A list of Security Group IDs to allow access to the database |`list(any)`|`[]`| no |
89
108
| <aname="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately)| Specifies whether any cluster modifications are applied immediately or during the next maintenance window |`bool`|`false`| no |
90
109
| <aname="input_backup_retention_period"></a> [backup\_retention\_period](#input\_backup\_retention\_period)| The number of days to retain backups for |`number`|`5`| no |
91
110
| <aname="input_backup_window"></a> [backup\_window](#input\_backup\_window)| The preferred window for taking automated backups of the database |`string`|`""`| no |
111
+
| <aname="input_cloudwatch_metric_alarms_enabled"></a> [cloudwatch\_metric\_alarms\_enabled](#input\_cloudwatch\_metric\_alarms\_enabled)| Boolean flag to enable/disable CloudWatch metrics alarms |`bool`|`false`| no |
92
112
| <aname="input_create_random_password"></a> [create\_random\_password](#input\_create\_random\_password)| Whether to create a random password for the RDS primary cluster |`bool`|`true`| no |
93
113
| <aname="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group)| Whether to create a security group for the database |`bool`|`true`| no |
114
+
| <aname="input_cw_sns_topic_arn"></a> [cw\_sns\_topic\_arn](#input\_cw\_sns\_topic\_arn)| The username to use when sending notifications to Slack. |`string`|`""`| no |
94
115
| <aname="input_db_name"></a> [db\_name](#input\_db\_name)| The name of the automatically created database on cluster creation |`string`|`""`| no |
95
116
| <aname="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection)| Specifies whether accidental deletion protection is enabled |`bool`|`true`| no |
117
+
| <aname="input_disk_free_storage_space"></a> [disk\_free\_storage\_space](#input\_disk\_free\_storage\_space)| Alarm threshold for the 'lowFreeStorageSpace' alarm |`string`|`"10000000000"`| no |
96
118
| <aname="input_enable_ssl_connection"></a> [enable\_ssl\_connection](#input\_enable\_ssl\_connection)| Whether to enable SSL connection to the database |`bool`|`false`| no |
97
119
| <aname="input_engine"></a> [engine](#input\_engine)| The name of the database engine to be used for this DB cluster |`string`|`"postgres"`| no |
98
120
| <aname="input_engine_version"></a> [engine\_version](#input\_engine\_version)| The database engine version. Updating this argument results in an outage |`string`|`""`| no |
@@ -106,11 +128,15 @@ The required IAM permissions to create resources from this module can be found [
106
128
| <aname="input_master_username"></a> [master\_username](#input\_master\_username)| The username for the RDS primary cluster |`string`|`""`| no |
107
129
| <aname="input_multi_az"></a> [multi\_az](#input\_multi\_az)| Enable multi-AZ for disaster recovery |`bool`|`false`| no |
108
130
| <aname="input_name"></a> [name](#input\_name)| The name of the RDS instance |`string`|`""`| no |
131
+
| <aname="input_ok_actions"></a> [ok\_actions](#input\_ok\_actions)| The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN) |`list(string)`|`[]`| no |
109
132
| <aname="input_port"></a> [port](#input\_port)| The port number for the database |`number`|`5432`| no |
110
133
| <aname="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible)| Specifies whether the RDS instance is publicly accessible over the internet |`bool`|`false`| no |
111
134
| <aname="input_random_password_length"></a> [random\_password\_length](#input\_random\_password\_length)| The length of the randomly generated password for the RDS primary cluster (default: 10) |`number`|`10`| no |
112
135
| <aname="input_replicate_source_db"></a> [replicate\_source\_db](#input\_replicate\_source\_db)| Specifies that this resource is a replicate database, and uses the specified value as the source database identifier |`string`|`null`| no |
113
136
| <aname="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot)| Determines whether a final DB snapshot is created before the DB instance is deleted. If set to true, no DB snapshot is created. If set to false, a DB snapshot is created before the DB instance is deleted, using the value from final\_snapshot\_identifier |`bool`|`true`| no |
137
+
| <aname="input_slack_channel"></a> [slack\_channel](#input\_slack\_channel)| The Slack channel where notifications will be posted. |`string`|`""`| no |
138
+
| <aname="input_slack_username"></a> [slack\_username](#input\_slack\_username)| The username to use when sending notifications to Slack. |`string`|`""`| no |
139
+
| <aname="input_slack_webhook_url"></a> [slack\_webhook\_url](#input\_slack\_webhook\_url)| The Slack Webhook URL where notifications will be sent. |`string`|`""`| no |
114
140
| <aname="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier)| Specifies whether to create the database from a snapshot. Use the snapshot ID found in the RDS console, e.g., rds:production-2015-06-26-06-05|`string`|`null`| no |
115
141
| <aname="input_storage_encrypted"></a> [storage\_encrypted](#input\_storage\_encrypted)| Specifies whether to enable database encryption |`bool`|`true`| no |
116
142
| <aname="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids)| A list of subnet IDs used by the database subnet group |`list(any)`|`[]`| no |
|[aws_iam_policy_document.lambda_cwl_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
34
+
|[aws_iam_policy_document.lambda_exec_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
35
+
36
+
## Inputs
37
+
38
+
| Name | Description | Type | Default | Required |
| <aname="input_artifact_file"></a> [artifact\_file](#input\_artifact\_file)| The path to the function's deployment package within the local filesystem |`string`|`null`| no |
41
+
| <aname="input_cwl_retention_days"></a> [cwl\_retention\_days](#input\_cwl\_retention\_days)| The retention time in days for the CloudWatch Logs Stream. |`number`|`30`| no |
42
+
| <aname="input_description"></a> [description](#input\_description)| Description of what the Lambda Function does. |`string`|`null`| no |
43
+
| <aname="input_environment"></a> [environment](#input\_environment)| The Lambda environment's configuration settings. |`map(string)`|`{}`| no |
44
+
| <aname="input_handler"></a> [handler](#input\_handler)| The function entrypoint in the code. |`string`|`"index.handler"`| no |
45
+
| <aname="input_memory_size"></a> [memory\_size](#input\_memory\_size)| Amount of memory in MB your Lambda Function can use at runtime. |`number`|`128`| no |
46
+
| <aname="input_name"></a> [name](#input\_name)| A unique name for the Lambda Function. |`string`| n/a | yes |
47
+
| <aname="input_runtime"></a> [runtime](#input\_runtime)| The Runtime used in the Lambda Function. |`string`| n/a | yes |
48
+
| <aname="input_tags"></a> [tags](#input\_tags)| A mapping of tags to assign to the module resources. |`map(string)`|`{}`| no |
49
+
| <aname="input_timeout"></a> [timeout](#input\_timeout)| The amount of time your Lambda Function has to run in seconds. |`number`|`6`| no |
50
+
51
+
## Outputs
52
+
53
+
| Name | Description |
54
+
|------|-------------|
55
+
| <aname="output_arn"></a> [arn](#output\_arn)| The ARN identifying the Lambda Function. |
56
+
| <aname="output_exec_role_id"></a> [exec\_role\_id](#output\_exec\_role\_id)| The ID of the Function's IAM Role. |
57
+
| <aname="output_invoke_arn"></a> [invoke\_arn](#output\_invoke\_arn)| The ARN to be used for invoking Lambda Function from API Gateway. |
58
+
| <aname="output_name"></a> [name](#output\_name)| The name of the Lambda Function. |
0 commit comments