(rds): DatabaseInstanceFromSnapshot ignoring enhanced monitoring and performance insights
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When creating a Database Instance from a snapshot, CDK appears to properly creating the CFN object correctly. However, when the DB instance is created, Enhanced Monitoring is not enabled and Performance Insights is not enabled. No errors seem to
### Expected Behavior
The expected behavior is that when the DB Instance is created, Enhanced Monitoring is enabled and Performance Insights is enabled.
### Current Behavior
Enhanced Monitoring is disabled and Performance Insights is disabled.
### Reproduction Steps
Create a DB Instance with the following definition.
```
rds_instance_size = ec2.InstanceSize.MEDIUM
rds_instance_class = ec2.InstanceClass.BURSTABLE4_GRAVITON
db_instance = rds.DatabaseInstanceFromSnapshot(self, "Db",
instance_identifier = "db-{}".format(env_context),
engine = rds.DatabaseInstanceEngine.mysql(
version = rds.MysqlEngineVersion.VER_8_0_32,
),
storage_type=rds.StorageType.IO1,
iops=nonessential_iops,
allocated_storage=1000,
max_allocated_storage=2000,
vpc=vpc,
vpc_subnets = ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS),
security_groups = [
mysql_security_group
],
removal_policy = RemovalPolicy.DESTROY,
snapshot_identifier = self.node.try_get_context(env_context)["DBSnapshotArn"],
instance_type = ec2.InstanceType.of(
rds_instance_class,
rds_instance_size
),
auto_minor_version_upgrade=True,
credentials= rds.SnapshotCredentials.from_generated_secret(
username = "admin",
exclude_characters = ".-=\\(@\" %+~`#$&()|[]{}:;<>?!'/)*,"
),
monitoring_interval=Duration.minutes(1),
cloudwatch_logs_exports= [ 'error', 'slowquery', 'audit' ],
cloudwatch_logs_retention = logs.RetentionDays.SIX_MONTHS,
enable_performance_insights = True,
)
```
This is the DatabaseInstance portion of the synth of the template .
```
Db74F67513": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"AllocatedStorage": "1000",
"AutoMinorVersionUpgrade": true,
"CopyTagsToSnapshot": true,
"DBInstanceClass": "db.t4g.medium",
"DBInstanceIdentifier": "db-test",
"DBSnapshotIdentifier": "arn:aws:rds:us-west-2::snapshot:db-snapshot",
"DBSubnetGroupName": {
"Ref": "DbSubnetGroup96467FE5"
},
"EnableCloudwatchLogsExports": [
"error",
"slowquery",
"audit"
],
"EnablePerformanceInsights": true,
"Engine": "mysql",
"EngineVersion": "8.0.32",
"Iops": 3500,
"MasterUserPassword": {
"Fn::Join": [
"",
[
"{{resolve:secretsmanager:",
{
"Ref": "StackDbSecret27A88B9D97d2022154130aa861a3bb7feab61e3c"
},
":SecretString:password::}}"
]
]
},
"MaxAllocatedStorage": 2000,
"MonitoringInterval": 60,
"MonitoringRoleArn": {
"Fn::GetAtt": [
"DbMonitoringRoleAE3F4B7B",
"Arn"
]
},
"PerformanceInsightsRetentionPeriod": 7,
"PubliclyAccessible": false,
"StorageType": "io1",
"VPCSecurityGroups": [
{
"Fn::GetAtt": [
"MySQLSecGrp93698302",
"GroupId"
]
}
]
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "Stack/Db/Resource"
}
```
### Possible Solution
_No response_
### Additional Information/Context
By examining CloudTrail for the [RestoreDBInstanceFromDBSnapshot] event, it does not appear that either setting is passed.
### CDK CLI Version
2.68
### Framework Version
_No response_
### Node.js Version
18.15
### OS
Linux
### Language
Python
### Language Version
3.10.6
### Other information
_No response_
Contributor guide
Research direction
Start with the DatabaseInstanceFromSnapshot construct and its synthesized AWS::RDS::DBInstance, using the reproduction to compare the template with the CloudTrail RestoreDBInstanceFromDBSnapshot event. Trace how monitoring_interval and enable_performance_insights are handled during snapshot restoration, then add coverage showing both settings reach the restore operation and remain enabled on the created instance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, databases, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100