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

fix: Update attributes copy_protection_enabled, pit_enabled and encryption_at_rest_enabled in the resource backup_compliance_policy to be Optional #1803

Merged
merged 3 commits into from
Jan 3, 2024

Conversation

andreaangiolillo
Copy link
Collaborator

@andreaangiolillo andreaangiolillo commented Jan 3, 2024

Description

Ticket: https://jira.mongodb.org/browse/CLOUDP-220487

mongodbatlas_backup_compliance_policy defines the copy_protection_enabled, pit_enabled and encryption_at_rest_enabled as required attributes when both the API documentation and the resource documentation say the opposite.

Link to any related issue(s): #1800

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Testing

I defined a new Acceptance tests

Running tool: /Users/andrea.angiolillo/.asdf/shims/go test -timeout 300000s -run ^TestAccGenericBackupRSBackupCompliancePolicy_withoutOptionals$ github.com/mongodb/terraform-provider-mongodbatlas/internal/service/backupcompliancepolicy

ok  	github.com/mongodb/terraform-provider-mongodbatlas/internal/service/backupcompliancepolicy	15.761s

Local test

  • I installed the provider version 1.14.0
  • I used the following TF conf
resource "mongodbatlas_project" "atlas-project" {
  name   = "test-andrea"
  org_id = "XXXXXXXXXXX"
}

resource "mongodbatlas_backup_compliance_policy" "backup_policy" {
  project_id                 = mongodbatlas_project.atlas-project.id
  authorized_email           = "[email protected]"
  authorized_user_first_name = "ssss"
  authorized_user_last_name  = "sss"
  copy_protection_enabled    = false
  pit_enabled                = false
  encryption_at_rest_enabled = false

  restore_window_days = 7

  on_demand_policy_item {
    frequency_interval = 1
    retention_unit     = "days"
    retention_value    = 3
  }

  policy_item_hourly {
    frequency_interval = 1
    retention_unit     = "days"
    retention_value    = 7
  }

  policy_item_daily {
    frequency_interval = 1
    retention_unit     = "days"
    retention_value    = 7
  }

  policy_item_weekly {
    frequency_interval = 1
    retention_unit     = "weeks"
    retention_value    = 4
  }

  policy_item_monthly {
    frequency_interval = 1
    retention_unit     = "months"
    retention_value    = 12
  }
}
  • Run terraform apply
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
  • I upgraded the provider to the local changes
  • I removed the optional fields from the tf conf
  • I run terraform apply
No changes. Your infrastructure matches the configuration.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

@andreaangiolillo andreaangiolillo changed the title fix: backup_compliance_policy resource missing required attribute fix: Resource backup_compliance_policy missing required attribute Jan 3, 2024
@github-actions github-actions bot added the bug label Jan 3, 2024
@@ -414,7 +417,7 @@ func resourceMongoDBAtlasBackupCompliancePolicyUpdate(ctx context.Context, d *sc

backupCompliancePolicyUpdate.AuthorizedEmail = d.Get("authorized_email").(string)

backupCompliancePolicyUpdate.AuthorizedUserFirstName = d.Get("authorized_user_fist_name").(string)
backupCompliancePolicyUpdate.AuthorizedUserFirstName = d.Get("authorized_user_first_name").(string)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[drive-by] This misspell was causing a crash during the update

│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-mongodbatlas plugin:

panic: interface conversion: interface {} is nil, not string

@andreaangiolillo andreaangiolillo marked this pull request as ready for review January 3, 2024 09:54
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner January 3, 2024 09:54
Copy link
Collaborator

@oarbusi oarbusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, do you think we can adjust the PR title to include more detail of the adjusted attributes?

@andreaangiolillo andreaangiolillo changed the title fix: Resource backup_compliance_policy missing required attribute fix: Update attributes copy_protection_enabled, pit_enabled and encryption_at_rest_enabled in the resource backup_compliance_policy to be Optional Jan 3, 2024
@andreaangiolillo andreaangiolillo merged commit f1d7c89 into master Jan 3, 2024
37 checks passed
@andreaangiolillo andreaangiolillo deleted the CLOUDP-220487 branch January 3, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants