AWS Amazon RDS Event Subscription
This page shows how to write Terraform and CloudFormation for Amazon RDS Event Subscription and write them securely.
aws_db_event_subscription (Terraform)
The Event Subscription in Amazon RDS can be configured in Terraform with the resource name aws_db_event_subscription
. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_db_event_subscription" "default-db-security-group" {
name = "rds-event-sub"
sns_topic = aws_sns_topic.default.arn
source_type = "db-security-group"
enabled = false
resource "aws_db_event_subscription" "snapshots" {
provider = aws.src
name = "rds-snapshots"
sns_topic = aws_sns_topic.rds_snapshots.arn
}
Parameters
-
arn
optional computed - string -
customer_aws_id
optional computed - string -
enabled
optional - bool -
event_categories
optional - set of string -
id
optional computed - string -
name
optional computed - string -
name_prefix
optional - string -
sns_topic
required - string -
source_ids
optional - set of string -
source_type
optional - string -
tags
optional - map from string to string -
timeouts
single block
Explanation in Terraform Registry
Provides a DB event subscription resource.
Tips: Best Practices for The Other AWS Amazon RDS Resources
In addition to the aws_db_instance, AWS Amazon RDS has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_db_instance
Ensure backup retension of your RDS instance is specified
It's better to set it explicitly to reduce the risk of availability issues.
aws_rds_cluster
Ensure backup retension of your RDS cluster is specified
It's better to set it explicitly to reduce the risk of availability issues.
aws_rds_cluster_instance
Ensure your RDS cluster instance blocks unwanted access
It's better to limit accessibily to the minimum that is required for the application to work.
AWS::RDS::EventSubscription (CloudFormation)
The EventSubscription in RDS can be configured in CloudFormation with the resource name AWS::RDS::EventSubscription
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::RDS::EventSubscription
DependsOn: RdsEventTopicPolicy
Properties:
SnsTopicArn: !Ref RdsEventTopic
Outputs:
Type: "AWS::RDS::EventSubscription"
Properties:
EventCategories:
- failover
- failure
- notification
Type: 'AWS::RDS::EventSubscription'
Properties:
EventCategories:
- failover
- failure
- notification
Type: 'AWS::RDS::EventSubscription'
Properties:
EventCategories:
- failover
- failure
- notification
Type: 'AWS::RDS::EventSubscription'
Properties:
EventCategories:
- failover
- failure
- notification
"rule": "$.Resources.*[?(@.Type == 'AWS::RDS::DBInstance')] size greater than 0 and (not $.Resources.*[?(@.Type == 'AWS::RDS::EventSubscription')].Properties[?(@.SourceType == 'db-security-group')].Enabled anyTrue)",
"id": "5b3c12cf-eef5-42de-afbe-4e80e1dfe600",
"enabled": false,
"recommendation": {
"name": "Recommended solution for enabling AWS RDS event subscription.",
"description": "It is recommended to enable subscriptions for AWS RDS event. Please make sure that if \"SourceType\" is equal to \"db-security-group\" under \"EventSubscription\", then \"Enabled\" should be set to true",
"Type": "AWS::RDS::EventSubscription",
"Properties": {
"EventCategories": [
"configuration change",
"failure",
"deletion"
"Type": "AWS::RDS::EventSubscription",
"Properties": {
"EventCategories": [
"configuration change",
"failure",
"deletion"
"Type": "AWS::RDS::EventSubscription",
"Properties": {
"EventCategories": [
"configuration change",
"failure",
"deletion"
"Type": "AWS::RDS::EventSubscription",
"Properties": {
"EventCategories": [
"configuration change",
"failure",
"deletion"
Parameters
-
Enabled
optional - Boolean -
EventCategories
optional - List -
SnsTopicArn
required - String -
SourceIds
optional - List -
SourceType
optional - String
Explanation in CloudFormation Registry
The
AWS::RDS::EventSubscription
resource allows you to receive notifications for Amazon Relational Database Service events through the Amazon Simple Notification Service (Amazon SNS). For more information, see Using Amazon RDS Event Notification in the Amazon RDS User Guide.
Frequently asked questions
What is AWS Amazon RDS Event Subscription?
AWS Amazon RDS Event Subscription is a resource for Amazon RDS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon RDS Event Subscription?
For Terraform, the prancer-io/prancer-terramerra and ag-pinguin/terraform_rds_replication source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the PokaInc/rds-events-to-cloudwatch, ibexmercado/crypto-mercado and sprintqaDevOps/AWS source code examples are useful. See the CloudFormation Example section for further details.