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: Provider produces inconsistent result after importing mongodbatlas_encryption_at_rest #1813

Merged
merged 3 commits into from Jan 5, 2024

Conversation

andreaangiolillo
Copy link
Collaborator

@andreaangiolillo andreaangiolillo commented Jan 5, 2024

Description

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

This PR fixes a bug in the mongodbatlas_encryption_at_rest resource where the IMPORT and READ logics were different causing tf plan to find differences when the resource was imported.

Link to any related issue(s): #1805

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

Local test

I tested my changes locally by importing the resource and verifying that the plan did not find any changes

terraform import mongodbatlas_encryption_at_rest.kms_encryption 6597de4d840fe16aadbbc713

2024-01-05T11:48:22.089Z [DEBUG] provider: plugin process exited: path=../bin/terraform-provider-mongodbatlas pid=7001
2024-01-05T11:48:22.090Z [DEBUG] provider: plugin exited
2024-01-05T11:48:22.090Z [INFO]  Writing state output to:

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
terraform plan


2024-01-05T11:48:46.390Z [INFO]  backend/local: plan operation completed

No changes. Your infrastructure matches the configuration.

Acceptance tests

  • I have updated the acceptance tests to test that the state file does not change on imports.
  • I ran the acceptance tests locally and tested that the resource import verify was successful
Running tool: /Users/andrea.angiolillo/.asdf/shims/go test -timeout 300000s -run ^TestAccAdvRSEncryptionAtRest_basicAWS$ github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrest

ok  	github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrest	13.032s

@github-actions github-actions bot added the bug label Jan 5, 2024
@andreaangiolillo andreaangiolillo marked this pull request as ready for review January 5, 2024 12:32
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner January 5, 2024 12:32
@andreaangiolillo andreaangiolillo changed the title fix: Provider produces inconsistent result after importing encryption_at_rest fix: Provider produces inconsistent result after importing mongodbatlas_encryption_at_rest Jan 5, 2024
// - the API returns the block AwsKmsConfig{enable=false} when the user does not provide the AWS KMS.
// - the API returns the block GoogleCloudKmsConfig{enable=false} if the user does not provider Google KMS
// - the API returns the block TfAzureKeyVaultConfigModel{enable=false} if the user does not provider AZURE KMS
func setEmpyArrayForEmptyBlocksReturnedFromImport(newStateFromImport *TfEncryptionAtRestRSModel) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func setEmpyArrayForEmptyBlocksReturnedFromImport(newStateFromImport *TfEncryptionAtRestRSModel) {
func setEmptyArrayForEmptyBlocksReturnedFromImport(newStateFromImport *TfEncryptionAtRestRSModel) {

Copy link
Collaborator

@maastha maastha left a comment

Choose a reason for hiding this comment

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

minor suggestion, LGTM

@andreaangiolillo andreaangiolillo merged commit f6404fa into master Jan 5, 2024
31 checks passed
@andreaangiolillo andreaangiolillo deleted the CLOUDP-220654 branch January 5, 2024 13:42
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.

None yet

2 participants