[Bug]: mongodbatlas_maintenance_window changes every time
Closed this issue · 3 comments
Is there an existing issue for this?
- I have searched the existing issues
Provider Version
v1.17.3
Terraform Version
v1.5.3
Terraform Edition
Terraform Open Source (OSS)
Current Behavior
Every plan and apply we run the maintence windows change, even though the code hasn't changed at all.
# module.atlas_project.mongodbatlas_maintenance_window.this["fri"] will be updated in-place
~ resource "mongodbatlas_maintenance_window" "this" {
~ day_of_week = 1 -> 6
id = "63c76c38b4933e38a7c081f4"
# (5 unchanged attributes hidden)
}
# module.atlas_project.mongodbatlas_maintenance_window.this["mon"] will be updated in-place
~ resource "mongodbatlas_maintenance_window" "this" {
~ day_of_week = 1 -> 2
id = "63c76c38b4933e38a7c081f4"
# (5 unchanged attributes hidden)
}
# module.atlas_project.mongodbatlas_maintenance_window.this["sat"] will be updated in-place
~ resource "mongodbatlas_maintenance_window" "this" {
~ day_of_week = 1 -> 7
~ hour_of_day = 0 -> 16
id = "63c76c38b4933e38a7c081f4"
# (4 unchanged attributes hidden)
}
# module.atlas_project.mongodbatlas_maintenance_window.this["sun"] will be updated in-place
~ resource "mongodbatlas_maintenance_window" "this" {
~ hour_of_day = 0 -> 16
id = "63c76c38b4933e38a7c081f4"
# (5 unchanged attributes hidden)
}
# module.atlas_project.mongodbatlas_maintenance_window.this["thu"] will be updated in-place
~ resource "mongodbatlas_maintenance_window" "this" {
~ day_of_week = 1 -> 5
id = "63c76c38b4933e38a7c081f4"
# (5 unchanged attributes hidden)
}
# module.atlas_project.mongodbatlas_maintenance_window.this["tue"] will be updated in-place
~ resource "mongodbatlas_maintenance_window" "this" {
~ day_of_week = 1 -> 3
id = "63c76c38b4933e38a7c081f4"
# (5 unchanged attributes hidden)
}
Terraform configuration to reproduce the issue
locals {
# On weekdays, midnight UTC (so no one is working)
# On weekends, 4p UTC (so folks are awake in PT)
windows = {
"mon" = { day = 2, hour = 0 },
"tue" = { day = 3, hour = 0 },
"wed" = { day = 4, hour = 0 },
"thu" = { day = 5, hour = 0 },
"fri" = { day = 6, hour = 0 },
"sat" = { day = 7, hour = 16 },
"sun" = { day = 1, hour = 16 },
}
}
resource "mongodbatlas_maintenance_window" "this" {
for_each = local.windows
project_id = resource.mongodbatlas_project.project.id
day_of_week = each.value.day
hour_of_day = each.value.hour
}
Steps To Reproduce
- create a project (
resource.mongodbatlas_project.project
) - apply the attached config
- apply it again and see that it changes the windows every time
Logs
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:
- Terraform configuration file used to reproduce the issue
- Terraform log files from the run where the issue occurred
- Terraform Atlas provider version used to reproduce the issue
- Terraform version used to reproduce the issue
- Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment
The ticket CLOUDP-261296 was created for internal tracking.
Hi @icco, thank you for raising the ticket.
The main issue with the configuration shared above is that there are multiple mongodbatlas_maintenance_window
resources defined for the same project, which is not the intended use case. Only a single maintenance window configuration is expected to be defined per project. From the Maintenance Window documentation you will see that automated maintenance runs on a weekly basis, giving users the flexibility to define at which day and hour it is run.
Opened a PR so we clarify this in our mongodbatlas_maintenance_window
resource documentation: #2418.
Fascinating. Thank you. I kind of wish the backend would throw an error, given it looks like each window has a unique ID.