Skip to content

fix: Fix enforce field in google_securityposture_posture always being…#18224

Open
averbuks wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
averbuks:averbukh-sec-posture-fix
Open

fix: Fix enforce field in google_securityposture_posture always being…#18224
averbuks wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
averbuks:averbukh-sec-posture-fix

Conversation

@averbuks

@averbuks averbuks commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fix enforce field in google_securityposture_posture always being sent even for boolean constraints, which makes API call to fail with error.

Example config

resource "google_securityposture_posture" "posture1"{
  posture_id  = "posture_example"
  parent      = "organizations/123"
  location    = "global"
  state       = "ACTIVE"
  description = "a new posture"
  policy_sets {
    policy_set_id = "list_constraint_policy_set"
    description   = "set of org policies with a list constraint to reproduce bug"
    policies {
      policy_id = "resource_locations_policy"
      constraint {
        org_policy_constraint {
          canned_constraint_id = "constraints/gcp.resourceLocations"
          policy_rules {
            values {
              allowed_values = ["in:us-locations"]
            }
          }
        }
      }
    }
  }
}

Error:

│ Error: Error creating Posture: googleapi: Error 400: Invalid value at 'posture.policy_sets[2].policies[0].constraint.org_policy_constraint.policy_rules[0]' (oneof), oneof field 'kind' is already set. Cannot set 'values'
│ Details:
│ [
│   {
│     "@type": "type.googleapis.com/google.rpc.BadRequest",
│     "fieldViolations": [
│       {
│         "description": "Invalid value at 'posture.policy_sets[2].policies[0].constraint.org_policy_constraint.policy_rules[0]' (oneof), oneof field 'kind' is already set. Cannot set 'values'",
│         "field": "posture.policy_sets[2].policies[0].constraint.org_policy_constraint.policy_rules[0]"
│       }
│     ]
│   }
│ ]
│ 
│   with google_securityposture_posture.posture1,
│   on main.tf line 1, in resource "google_securityposture_posture" "posture1":
│    1: resource "google_securityposture_posture" "posture1"{
│ 

Issue was introduced in PR-16796
Fix proposed here

securityposture_posture: Fix enforce field in google_securityposture_posture always being set, while not supported for list constraints

@github-actions github-actions Bot requested a review from slevenick July 8, 2026 09:47
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@averbuks

averbuks commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

FYI: @steffencircle

@modular-magician

modular-magician commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 7e76383:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 3 files changed, 76 insertions(+)
google-beta provider View Diff 3 files changed, 76 insertions(+)
terraform-google-conversion View Diff 1 file changed, 32 insertions(+)

Test report

Analytics

Total Tests Passed Skipped Affected
3 2 0 1
Affected Service Packages
  • securityposture

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccSecurityposturePosture_securityposturePostureBasicExample

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
❌ Error · Log - TestAccSecurityposturePosture_securityposturePostureBasicExample

Caution

Issues requiring attention before PR completion

🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details.

Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer.

View the recording VCR build log or the debug logs folder for detailed results.

@averbuks, @slevenick VCR tests complete for 7e76383!

@modular-magician

modular-magician commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 552ded2:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 3 files changed, 76 insertions(+)
google-beta provider View Diff 3 files changed, 76 insertions(+)
terraform-google-conversion View Diff 1 file changed, 32 insertions(+)

Test report

Analytics

Total Tests Passed Skipped Affected
3 2 0 1
Affected Service Packages
  • securityposture

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccSecurityposturePosture_securityposturePostureBasicExample

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
❌ Error · Log - TestAccSecurityposturePosture_securityposturePostureBasicExample

Caution

Issues requiring attention before PR completion

🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details.

Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer.

View the recording VCR build log or the debug logs folder for detailed results.

@averbuks, @slevenick VCR tests complete for 552ded2!

@modular-magician

modular-magician commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit f486153:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 3 files changed, 562 insertions(+), 474 deletions(-)
google-beta provider View Diff 3 files changed, 562 insertions(+), 474 deletions(-)
terraform-google-conversion View Diff 1 file changed, 34 insertions(+)

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

  • Field policy_sets.policies changed from TypeList to TypeSet on google_securityposture_posture - reference
  • Field policy_sets changed from TypeList to TypeSet on google_securityposture_posture - reference

If you believe this detection to be incorrect please raise the concern with your reviewer.
If you intend to make this change you will need to wait for a major release window.
An override-breaking-change label can be added to allow merging.

Test report

Analytics

Total Tests Passed Skipped Affected
3 1 0 2
Affected Service Packages
  • securityposture

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccSecurityposturePosture_securityposturePostureBasicExample
  • TestAccSecurityposturePosture_securityposturePosture_update

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log TestAccSecurityposturePosture_securityposturePostureBasicExample
✅ Log TestAccSecurityposturePosture_securityposturePosture_update

🟢 All tests passed!

View the recording VCR build log or the debug logs folder for detailed results.

@averbuks, @slevenick VCR tests complete for f486153!

@modular-magician

modular-magician commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 5917810:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 3 files changed, 78 insertions(+)
google-beta provider View Diff 3 files changed, 78 insertions(+)
terraform-google-conversion View Diff 1 file changed, 32 insertions(+)

Test report

Analytics

Total Tests Passed Skipped Affected
3 1 0 2
Affected Service Packages
  • securityposture

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccSecurityposturePosture_securityposturePostureBasicExample
  • TestAccSecurityposturePosture_securityposturePosture_update

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log TestAccSecurityposturePosture_securityposturePostureBasicExample
✅ Log TestAccSecurityposturePosture_securityposturePosture_update

🟢 All tests passed!

View the recording VCR build log or the debug logs folder for detailed results.

@averbuks, @slevenick VCR tests complete for 5917810!

@slevenick

Copy link
Copy Markdown
Contributor

Please do a local review with a Google engineer from the service team as described at go/terraform-service-review. Let me know when that's finished and I'll follow up with final review & merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants