Skip to content

test: Ensures project withDefaultAlertsSettings works with import and introduce create_only plan modifier #3105

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
53de463
fix: Sets default value for WithDefaultAlertsSettings during state im…
EspenAlbert Feb 25, 2025
26f7353
chore: Adds release note
EspenAlbert Feb 25, 2025
5e67e14
fix: Removes 'with_default_alerts_settings' from ImportStateVerifyIgn…
EspenAlbert Feb 25, 2025
57ddae6
doc: update changelog message
EspenAlbert Feb 25, 2025
7bc763e
doc: Add back reference based on comments
EspenAlbert Feb 26, 2025
de2589d
revert changes of old implementation
EspenAlbert Mar 3, 2025
7934ad0
refactor: Introduce Modifier interface and enhance non-updatable attr…
EspenAlbert Mar 3, 2025
af84e38
refactor: Mark with_default_alerts_settings as NonUpdateable
EspenAlbert Mar 3, 2025
66e55e9
refactor:Rename NonUpdatableAttributePlanModifier with CreateOnlyAttr…
EspenAlbert Mar 3, 2025
e11fc3f
Merge branch 'master' into CLOUDP-302586_fix_project_no_plan_change_f…
EspenAlbert Mar 12, 2025
bd76a93
feat: Implement CreateOnlyAttributePlanModifier with default boolean …
EspenAlbert Mar 12, 2025
d0cb772
chore: small fix to planModifier using state value when Unknown in th…
EspenAlbert Mar 12, 2025
57f8e64
test: Support testing plan error after importing
EspenAlbert Mar 13, 2025
4ae2ccc
doc: Update error message in addDiags to clarify import restrictions
EspenAlbert Mar 13, 2025
8c7f8c6
Merge branch 'master' into CLOUDP-302586_fix_project_no_plan_change_f…
EspenAlbert Jul 11, 2025
c8abacd
chore: revert old changes for advancedclustertpf
EspenAlbert Jul 11, 2025
078b07c
test: remove migration test util in favor of acc test step for empty …
EspenAlbert Jul 11, 2025
fae76d4
revert old changes
EspenAlbert Jul 11, 2025
9bb557b
doc: Updates docs with latest API docs
EspenAlbert Jul 11, 2025
6a551b7
refactor: remove the withDefaultAlertSettings override for plan
EspenAlbert Jul 11, 2025
954229a
refactor: Add create only attribute plan modifier for project_owner_id
EspenAlbert Jul 11, 2025
8a03248
chore: update related docs
EspenAlbert Jul 11, 2025
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
3 changes: 3 additions & 0 deletions .changelog/3105.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/mongodbatlas_project: Sets default value for `with_default_alerts_settings` during state import
```
10 changes: 7 additions & 3 deletions internal/service/project/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,13 @@ func (r *projectRS) ImportState(ctx context.Context, req resource.ImportStateReq
}

func updatePlanFromConfig(projectPlanNewPtr, projectPlan *TFProjectRSModel) {
// we need to reset defaults from what was previously in the state:
// https://discuss.hashicorp.com/t/boolean-optional-default-value-migration-to-framework/55932
projectPlanNewPtr.WithDefaultAlertsSettings = projectPlan.WithDefaultAlertsSettings
// After import the state&plan will be null so we set to true (default value)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The user will still get a plan change after import if they have set with_default_alert_settings=false in their config. But we don't have access to that information in the import

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is still a possibility, I'm thinking if we should even implement this fix. This sounds like it should be expected behavior that WithDefaultAlertsSettings will not be set during import and maybe something we can call out in our documentation instead.

I'd find it harder to explain to users why import shows an update if with_default_alert_settings=false in their config but works when it's true.

if projectPlanNewPtr.WithDefaultAlertsSettings.IsNull() && projectPlan.WithDefaultAlertsSettings.IsNull() {
projectPlanNewPtr.WithDefaultAlertsSettings = types.BoolValue(true)
} else {
// Force value from plan as this is not returned from the API to avoid inconsistent result errors
Copy link
Collaborator

Choose a reason for hiding this comment

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

it just feels a workaround from an API limitation, have we reached out to the team owning this feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand is a create-only parameter that has a side effect of creating alert settings, but I'll check with upstream. Api Docs

projectPlanNewPtr.WithDefaultAlertsSettings = projectPlan.WithDefaultAlertsSettings
}
projectPlanNewPtr.ProjectOwnerID = projectPlan.ProjectOwnerID
if projectPlan.Tags.IsNull() && len(projectPlanNewPtr.Tags.Elements()) == 0 {
projectPlanNewPtr.Tags = types.MapNull(types.StringType)
Expand Down