-
Notifications
You must be signed in to change notification settings - Fork 81
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
Support of GCP Custom Org Policy via Module #147
Comments
@Gauravkumargupta you need to use org policy module v2 for custom constraint. |
@imrannayer I'm getting below error while running the plan to create the custom org policy, using below backend.tf & main.tf #backend.tf provider "google" { terraform { #main.tf resource "google_org_policy_custom_constraint" "constraint" { #ERROR The provider hashicorp/google does not support resource type "google_org_policy_custom_constraint" |
Make sure you are using provider version 5.3+ as it was GA in version 5.3 |
@imrannayer we don’t set any specific version of google provider in our code, that means it takes the latest one. I shared the backend.tf code in above response. Does it require any change in backend.tf? I'm also using below module to enforce the custom org policy once it's created via google_org_policy_custom_constraint resource block, can it be any dependency issue? module "gcp_org_policy_v2" { |
Also when I'm defining the specific version of google provider in backend.tf - it also throws error - not sure why it's checking for this condition at 12:56:42 "Finding hashicorp/google versions matching ">= 3.53.0, < 5.0.0, 5.34.0"..." backend.tf provider "google" { } } terraform { required_providers { Jenkins Job while running terraform init & plan: 12:56:42 Initializing the backend... |
@imrannayer I fixed the issue, the error was because the module version which I was using source = "terraform-google-modules/org-policy/google//modules/org_policy_v2" when I switched to version 5.3.0 of module, I don't see no more error for resource type "google_org_policy_custom_constraint" Is there any dependency on both? |
You code was failing for 5.2 has max provider version 4.X allowed. 5.3 relaxed the requirement
|
TL;DR
Google cloud supports the creation of custom organisation policy but we're not able to enforce the custom org policy via terraform module. I tried different versions of module i.e 5.4.0, 4.0.0, 3.0.2 but none works.
Expected behavior
It should be enforced as prebuilt policies enforcement are working fine via above module code.
Observed behavior
module.orgPolicy-RestrictOwnerEditorRole.google_organization_policy.org_policy_boolean[0]: Creating...
╷
│ Error: googleapi: Error 404: Requested entity was not found., notFound
│
│ with module.orgPolicy-RestrictOwnerEditorRole.google_organization_policy.org_policy_boolean[0],
│ on .terraform/modules/RestrictOwnerEditorRole/boolean_constraints.tf line 20, in resource "google_organization_policy" "org_policy_boolean":
│ 20: resource "google_organization_policy" "org_policy_boolean" {
Terraform Configuration
Terraform Version
Additional information
No response
The text was updated successfully, but these errors were encountered: