Closed nleite closed 2 years ago
@nleite we'll have the team take a look and get back to you.
@nleite The terraform resource is designed correctly. In order to set the number of auto-deferrals, it is important for the maintenance window to exist.
Therefore, initially the resource should be as below -
resource "mongodbatlas_maintenance_window" "cluster_maintenance_window" {
project_id = mongodbatlas_project.atlas_project.id
// auto_defer = var.maintenance_auto_defer
day_of_week = var.maintenance_day_of_week
hour_of_day = var.maintenance_hour_of_day
}
- Run `terraform apply`
Once completed, alter the resource as below -
```terraform
resource "mongodbatlas_maintenance_window" "cluster_maintenance_window" {
project_id = mongodbatlas_project.atlas_project.id
auto_defer = var.maintenance_auto_defer
day_of_week = var.maintenance_day_of_week
hour_of_day = var.maintenance_hour_of_day
}
terraform apply
again and this should do what you are trying to accomplish.The above difference is because there are two different API calls required to accomplish this.
The create maintenance window call is -
PATCH /api/atlas/v1.0/groups/{GROUPID}/maintenanceWindow
While when the auto_defer is set it calls for the below API -
POST /api/atlas/v1.0/groups/{GROUPID}/maintenanceWindow/autoDefer
Since these two API calls cannot be combined, and when terraform finds auto_defer
as mentioned in resource it straightaway hits the second API call which fails with 400 error as there is no maintenance window to autodefer.
I hope I have been able to answer your question.
Thanks
Internal ticket INTMDB-305 to investigate solutions.
@nleite This fix will be in version 1.3.1 pre release for testing soon
@nleite Pre-release with the fix is out if you'd like to test it. We'll likely release Monday. https://github.com/mongodb/terraform-provider-mongodbatlas/releases/tag/untagged-bcc6453f1acaa220dd7e
1.3.1 is released
Atlas terraform provider throwing back a 400 while creating a project maintenance window with
auto_defer
option set. Seems like there is an out-of-order (or something similar) API call that tries to set theautoDefer
before the maintenance window is set or gets completed.Terraform CLI and Terraform MongoDB Atlas Provider Version
Terraform Config
Steps to Reproduce
terraform init terraform plan terraform apply
Expected Behavior
Should create the maintenance window for the project without any issues
Actual Behavior