Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: mongodbatlas_maintenance_window changes every time #2410

Closed
2 tasks done
icco opened this issue Jul 11, 2024 · 3 comments
Closed
2 tasks done

[Bug]: mongodbatlas_maintenance_window changes every time #2410

icco opened this issue Jul 11, 2024 · 3 comments

Comments

@icco
Copy link

icco commented Jul 11, 2024

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

  1. create a project (resource.mongodbatlas_project.project)
  2. apply the attached config
  3. 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
Copy link
Contributor

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.

@AgustinBettati
Copy link
Member

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.

@icco
Copy link
Author

icco commented Jul 12, 2024

Fascinating. Thank you. I kind of wish the backend would throw an error, given it looks like each window has a unique ID.

@icco icco closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants