AWS: RDS logs, export to the CloudWatch Logs and CloudFormation template

DB Parameter Groups — enabling logs

...
"MasterDBParamGroup": {
"Type": "AWS::RDS::DBParameterGroup",
"Properties": {
"Description": "Master Database Parameter Group",
"Family": "mariadb10.0",
"Parameters" : {
"net_read_timeout": 60
},
"Tags" : [
{"Key" : "Name", "Value" : { "Fn::Join" : [ "-", [ {"Ref" : "AWS::StackName"}, "master-db-params"] ] } },
{"Key" : "Env", "Value" : {"Ref" : "ENV"} }
]
}
},
...
$ aws rds — profile bm-backend describe-db-parameters — db-parameter-group-name mobilebackend-dev-masterdbparamgroup-258i35vgxvdi | grep -A1 ‘slow_query_log\|general_log\|log_error’
“ParameterName”: “general_log”,
“ParameterValue”: “1”,

“ParameterName”: “general_log_file”,
“ParameterValue”: “/rdsdbdata/log/general/mysql-general.log”,

“ParameterName”: “log_error”,
“ParameterValue”: “/rdsdbdata/log/error/mysql-error.log”,

“ParameterName”: “slow_query_log”,
“ParameterValue”: “1”,

“ParameterName”: “slow_query_log_file”,
“ParameterValue”: “/rdsdbdata/log/slowquery/mysql-slowquery.log”,

CloudWatch Logs export

CloudFormation template

...
"MasterDBParamGroup": {
"Type": "AWS::RDS::DBParameterGroup",
"Properties": {
"Description": "Master Database Parameter Group",
"Family": "mariadb10.0",
"Parameters" : {
"log_output": "FILE",
"general_log": 1,
"slow_query_log": 1,
"long_query_time": 10,
"log_queries_not_using_indexes": 1,
"net_read_timeout": 60
},
"Tags" : [
{"Key" : "Name", "Value" : { "Fn::Join" : [ "-", [ {"Ref" : "AWS::StackName"}, "master-db-params"] ] } },
{"Key" : "Env", "Value" : {"Ref" : "ENV"} }
]
}
},
...
...
"DB1MasterRDS" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"DBInstanceIdentifier" : { "Fn::Join" : [ "-", [ {"Ref" : "AWS::StackName"}, "db1-master-rds"] ] },
"MasterUsername" : { "Ref" : "DB1RootUser" },
"MasterUserPassword" : { "Ref" : "DB1RootPassword" },
"AllocatedStorage" : { "Ref" : "DB1AllocatedStorage" },
"Engine" : "mariadb",
"StorageType": "gp2",
"AutoMinorVersionUpgrade": false,
"PubliclyAccessible" : false,
"DBInstanceClass" : { "Ref" : "DB1MasterDBInstanceClass" },
"DBSubnetGroupName" : { "Ref" : "DB1SubnetGroup" },
"DBParameterGroupName" : {"Ref" : "MasterDBParamGroup" },
"EnableCloudwatchLogsExports": [
"error",
"general",
"slowquery"
],
"BackupRetentionPeriod": {"Ref" : "BackupRetentionPeriod" },
"PreferredBackupWindow": {"Ref" : "PreferredBackupWindow" },
"VPCSecurityGroups" : [ { "Fn::GetAtt" : [ "MasterDBSecurityGroup", "GroupId" ] } ],
"MultiAZ": {"Ref" : "MultiAZ" },
"Tags" : [
{"Key" : "Name", "Value" : { "Fn::Join" : [ "-", [ {"Ref" : "AWS::StackName"}, "db1-master-rds"] ] } },
{"Key" : "Env", "Value" : {"Ref" : "ENV"} }
]
},
"DeletionPolicy" : "Snapshot"
},
...

--

--

--

Cloud Infrastructure and DevOps engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Scaling Enterprise MLOps with Modern Cloud Operations

Lessons From a Java Interview

Learn Neo4j Cypher basics in 30 minutes

WOT: simple distributed leader consensus

My journey becoming a Unity game developer: 2.5D

What is V2V? How to select the V2V migration tool?

How we used Google App Engine to deploy Django Application (with Postgres DB)at DUIT Technologies

Animation 101 for Front End Development

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arseny Zinchenko (setevoy)

Arseny Zinchenko (setevoy)

Cloud Infrastructure and DevOps engineer

More from Medium

Setup TKG 1.5.1 Management cluster on AWS cloud

Radaar AWS DevOps Transformation

Terratest - Infrastructure Automated Testing

A programmatic way to create an account in AWS Control Tower.