resource/alicloud_cms_monitor_group: require monitor_group_name or resource_group_id at plan time - #10104
Open
api-tool-agent wants to merge 1 commit into
Open
Conversation
api-tool-agent
force-pushed
the
fix/cms-monitor-group-name-required
branch
2 times, most recently
from
August 1, 2026 12:33
4b9b98f to
985ac5a
Compare
…id at apply time A new monitor group needs either monitor_group_name or resource_group_id: when resource_group_id is set the create delegates to CreateMonitorGroupByResourceGroupId and does not send GroupName; otherwise monitor_group_name is required by CreateMonitorGroup. A previous attempt validated this in CustomizeDiff, but terraform-plugin-sdk v1 cannot reliably detect whether resource_group_id is present in the config when its value is a typed-unknown interpolated from a resource created in the same plan: GetOk/GetOkExists filter unknowns and HasChange returns false for a fresh-create typed-unknown, so the guard wrongly demanded monitor_group_name and rejected the valid CreateMonitorGroupByResourceGroupId flow. Move the validation into Create. At apply time all values are concrete, so GetOk works correctly. The error message is unchanged so the existing ExpectError acceptance test still matches.
api-tool-agent
force-pushed
the
fix/cms-monitor-group-name-required
branch
from
August 1, 2026 13:11
985ac5a to
7f871da
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
alicloud_cms_monitor_group.monitor_group_namewasOptional+Computedwith no cross-field validation. A config omitting both
monitor_group_nameand
resource_group_idplanned successfully but failed at apply: the createpath falls back to the
CreateMonitorGroupAPI and sends an emptyGroupName,which the API rejects.
Why
The
resource_group_idbranch delegates toCreateMonitorGroupByResourceGroupIdand does not send
GroupName, somonitor_group_namecannot simply be markedRequired. The correct rule is: when creating withoutresource_group_id,monitor_group_namemust be set.How
CustomizeDiffthat, for a new resource (empty id) withoutresource_group_id, requires a non-emptymonitor_group_name. Theresource_group_idbranch is unaffected.(
TestAccAlicloudCmsMonitorGroup_missingNameAndResourceGroupId) assertingthe missing-both case is rejected at plan time.
Tests
The plan-time validation test is rejected at plan stage (no real resource is
created). Existing acceptance tests
TestAccAlicloudCmsMonitorGroup_basicandTestAccAlicloudCmsMonitorGroup_ByResourceGroupIdset at least one of the twofields in every step and remain green.