terraform-aws-rds-cluster
terraform-aws-rds-cluster copied to clipboard
Aurora Serverless "BackupWindow" parameter not working
Describe the Bug
It seems like AWS does not support (or maybe is bugged) "preferred_maintenance_window " and "preferred_backup_window" Existing AWS issue: https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/396 This was also reported internally in AWS team
Expected Behavior
Everything should work as expected
Steps to Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Run '....'
- Enter '....'
- See error
Screenshots
Create a serverless database from a snapshot. Right after it's finished terraform will throw:
Error: error modifying RDS Cluster (tc-staging-shared-main-rds): InvalidParameterCombination: You currently can't modify BackupWindow with Aurora Serverless. status code: 400, request id: aa5042ba-f0be-49ea-a695-e68da91a01f8
If you run terraform again it will say the cluster is tainted and must be replaced. Moreover a lot of values are just wrong. The created resource has totally different values than specified in terraform code:
- backup_retention_period (1 day instead of configured 7)
- preferred_backup_window
- preferred_maintenance_window
- master_username (the module passes a default but the instance was created from a snapshot)

Environment (please complete the following information):
- OS: Windows 10
Additional Context
I think you could have a dedicated resource for serverless clusters with the above fields omitted
@sebastianmacarescu thanks for reporting this.
Will it work if you just set all those parameters to null?
Tried to set it to null but I get validation error, preferred_maintenance_window must be of format ...
+1
From this commit e82b41f
@joshmello @sebastianmacarescu does it work if you tried setting the following to null ?
maintenance_window = null
backup_window = null
retention_period = null
@nitrocode when I tested last year no, it did not work setting to null. Got validation error, preferred_maintenance_window must be of format ...
It seems like an aws api issue. A serverless aurora does have these parameters and these can be modified in the browser but not from the aws api. The workaround from the issue you linked above is to comment out the preferred parameters and we do that in terraform by setting them to null which seems to error out because of a presumably API bug... not much we can do here since a dynamic only works on blocks and not root level arguments.
You can see from the below code we're passing in the input vars unaltered to the corresponding resource.
https://github.com/cloudposse/terraform-aws-rds-cluster/blob/28e76def91186eef0baae3cdbea09905a10215f9/main.tf#L61
https://github.com/cloudposse/terraform-aws-rds-cluster/blob/28e76def91186eef0baae3cdbea09905a10215f9/main.tf#L71
https://github.com/cloudposse/terraform-aws-rds-cluster/blob/28e76def91186eef0baae3cdbea09905a10215f9/main.tf#L143
https://github.com/cloudposse/terraform-aws-rds-cluster/blob/28e76def91186eef0baae3cdbea09905a10215f9/main.tf#L153
Looks like a user has documented that serverless engine mode has a few limitations which could be worked around by the aws provider.
https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/396#issuecomment-684002416
@joshmello @sebastianmacarescu you may have better luck creating another ticket with the aws provider. When you do, please include a minimal example using the raw resource aws_rds_cluster to reproduce the issue.