Repository navigation
Conversation
…oogleCloudPlatform#16737) The file resource's `permissions` attribute (under `os_policies.resource_groups.resources.file`) was schema-marked `Computed: true` only, which made the API's documented input field unsettable from Terraform. Users hit `Error: Value for unconfigurable attribute` when trying to chmod a copied binary (e.g. set 755 on a file fetched from GCS that lands as 644). The OSPolicyAssignment REST API (FileResource.permissions) accepts the field on create and update, so the schema should be `Optional + Computed` to match: users who set it get their value, users who don't get the server's default (755). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Makes
permissionsongoogle_os_config_os_policy_assignmentfile resourcessettable from Terraform. The field was schema-marked
Computed: trueonly,which produced
Error: Value for unconfigurable attributefor any usertrying to chmod a file deployed by the policy.
Fixes hashicorp/terraform-provider-google#16737 — see hashicorp/terraform-provider-google#16737
Why
User workflow from the issue: copy a binary from GCS into
/usr/local/bin/(arrives with mode 644) and
chmod 755it. Withoutpermissionsbeingconfigurable, the only workaround is an
execresource that runschmodimperatively — which defeats the declarative model the OS Policy
Assignment is supposed to provide.
The maintainer (@edwardmedia) flagged that the field was treated as
read-only and forwarded to the service team for confirmation. The Compute
Engine OS Config REST documentation lists
FileResource.permissionsas aplain string field (no read-only marker), and the existing handwritten
expand function already wires the field through to the API payload — so
the schema-side
Computed-only flag is the only blocker.GCP API reference:
What changed
mmv1 source for the handwritten OSPolicyAssignment resource — adds
Optional: truealongside the existingComputed: trueonos_policies.resource_groups.resources.file.permissions. Users who set thefield now get their value through to the API; users who don't continue to
get the server-computed default (755).
The
expandOSConfigOSPolicyAssignmentOsPoliciesResourceGroupsResourcesFilePermissionsfunction already exists and already wires
original["permissions"]intothe request payload with an
IsEmptyValueguard, so no other code change isrequired.
Edge cases tested
# permissions omitted"755";Computed: truepopulates state without diff"755"permissions = "755"gcloud compute os-config os-policy-assignments describeshowspermissions: "755"; second plan clean"644"(different from server default)permissions = "644"Test protocol
Optional + Computedidiom matches sibling fields in the same block (e.g.stateis Optional + ValidateFunc'd,pathis Required)expandOSConfigOSPolicyAssignmentOsPoliciesResourceGroupsResourcesFilePermissionsalready returnsvunchanged with anIsEmptyValueguard around assignmentResources
mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment.go(handwritten)Disclosure
This PR was drafted with assistance from Claude Code as part of a parallel
contribution batch. The schema change was reviewed against the OS Config
REST documentation and the existing expand path. The author (a human) will
review the diff and the modular-magician downstream PRs before requesting
maintainer review. Live smoke was not run for this batch; reviewer is
invited to validate against an existing OS Policy fixture.