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

azurerm_mongo_cluster - remove the check logic for administrator_password #28215

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/acceptance/testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ func (td TestData) externalProviders() map[string]resource.ExternalProvider {
VersionConstraint: "=2.47.0",
Source: "registry.terraform.io/hashicorp/azuread",
},
"random": {
VersionConstraint: "=3.6.3",
Source: "registry.terraform.io/hashicorp/random",
},
"time": {
VersionConstraint: "=0.9.1",
Source: "registry.terraform.io/hashicorp/time",
Expand Down
4 changes: 0 additions & 4 deletions internal/services/mongocluster/mongo_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ func (r MongoClusterResource) CustomizeDiff() sdk.ResourceFunc {
return fmt.Errorf("`administrator_username` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault))
}

if state.AdministratorPassword == "" {
return fmt.Errorf("`administrator_password` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault))
}
Comment on lines -491 to -493
Copy link
Member

Choose a reason for hiding this comment

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

This validation should probably be moved to the Create function instead of removed entirely

Copy link
Contributor Author

@neil-yechenwei neil-yechenwei Dec 13, 2024

Choose a reason for hiding this comment

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

Even if the validation is placed in the create function, this code will never be hit because administrator_username already has the constraint RequiredWith: []string{"administrator_password"}.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for pointing that out 👍


if state.ComputeTier == "" {
return fmt.Errorf("`compute_tier` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,19 @@ func (r MongoClusterResource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "random_password" "test" {
length = 8
numeric = true
upper = true
lower = true
}

resource "azurerm_mongo_cluster" "test" {
name = "acctest-mc%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
administrator_username = "adminTerraform"
administrator_password = "QAZwsx123"
administrator_password = random_password.test.result
shard_count = "1"
compute_tier = "Free"
high_availability_mode = "Disabled"
Expand Down
Loading