1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. projects
  5. getOrganizationPolicy
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

gcp.projects.getOrganizationPolicy

Explore with Pulumi AI

Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

Allows management of Organization policies for a Google Project. For more information see the official documentation

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const policy = gcp.projects.getOrganizationPolicy({
    project: "project-id",
    constraint: "constraints/serviceuser.services",
});
export const version = policy.then(policy => policy.version);
Copy
import pulumi
import pulumi_gcp as gcp

policy = gcp.projects.get_organization_policy(project="project-id",
    constraint="constraints/serviceuser.services")
pulumi.export("version", policy.version)
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/projects"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		policy, err := projects.LookupOrganizationPolicy(ctx, &projects.LookupOrganizationPolicyArgs{
			Project:    "project-id",
			Constraint: "constraints/serviceuser.services",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("version", policy.Version)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var policy = Gcp.Projects.GetOrganizationPolicy.Invoke(new()
    {
        Project = "project-id",
        Constraint = "constraints/serviceuser.services",
    });

    return new Dictionary<string, object?>
    {
        ["version"] = policy.Apply(getOrganizationPolicyResult => getOrganizationPolicyResult.Version),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.projects.ProjectsFunctions;
import com.pulumi.gcp.projects.inputs.GetOrganizationPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var policy = ProjectsFunctions.getOrganizationPolicy(GetOrganizationPolicyArgs.builder()
            .project("project-id")
            .constraint("constraints/serviceuser.services")
            .build());

        ctx.export("version", policy.applyValue(getOrganizationPolicyResult -> getOrganizationPolicyResult.version()));
    }
}
Copy
variables:
  policy:
    fn::invoke:
      function: gcp:projects:getOrganizationPolicy
      arguments:
        project: project-id
        constraint: constraints/serviceuser.services
outputs:
  version: ${policy.version}
Copy

Using getOrganizationPolicy

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getOrganizationPolicy(args: GetOrganizationPolicyArgs, opts?: InvokeOptions): Promise<GetOrganizationPolicyResult>
function getOrganizationPolicyOutput(args: GetOrganizationPolicyOutputArgs, opts?: InvokeOptions): Output<GetOrganizationPolicyResult>
Copy
def get_organization_policy(constraint: Optional[str] = None,
                            project: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetOrganizationPolicyResult
def get_organization_policy_output(constraint: Optional[pulumi.Input[str]] = None,
                            project: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetOrganizationPolicyResult]
Copy
func LookupOrganizationPolicy(ctx *Context, args *LookupOrganizationPolicyArgs, opts ...InvokeOption) (*LookupOrganizationPolicyResult, error)
func LookupOrganizationPolicyOutput(ctx *Context, args *LookupOrganizationPolicyOutputArgs, opts ...InvokeOption) LookupOrganizationPolicyResultOutput
Copy

> Note: This function is named LookupOrganizationPolicy in the Go SDK.

public static class GetOrganizationPolicy 
{
    public static Task<GetOrganizationPolicyResult> InvokeAsync(GetOrganizationPolicyArgs args, InvokeOptions? opts = null)
    public static Output<GetOrganizationPolicyResult> Invoke(GetOrganizationPolicyInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetOrganizationPolicyResult> getOrganizationPolicy(GetOrganizationPolicyArgs args, InvokeOptions options)
public static Output<GetOrganizationPolicyResult> getOrganizationPolicy(GetOrganizationPolicyArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:projects/getOrganizationPolicy:getOrganizationPolicy
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Constraint This property is required. string
(Required) The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
Project This property is required. string
The project ID.
Constraint This property is required. string
(Required) The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
Project This property is required. string
The project ID.
constraint This property is required. String
(Required) The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
project This property is required. String
The project ID.
constraint This property is required. string
(Required) The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
project This property is required. string
The project ID.
constraint This property is required. str
(Required) The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
project This property is required. str
The project ID.
constraint This property is required. String
(Required) The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
project This property is required. String
The project ID.

getOrganizationPolicy Result

The following output properties are available:

booleanPolicies List<Property Map>
constraint String
etag String
id String
The provider-assigned unique ID for this managed resource.
listPolicies List<Property Map>
project String
restorePolicies List<Property Map>
updateTime String
version Number

Supporting Types

GetOrganizationPolicyBooleanPolicy

Enforced This property is required. bool
If true, then the Policy is enforced. If false, then any configuration is acceptable.
Enforced This property is required. bool
If true, then the Policy is enforced. If false, then any configuration is acceptable.
enforced This property is required. Boolean
If true, then the Policy is enforced. If false, then any configuration is acceptable.
enforced This property is required. boolean
If true, then the Policy is enforced. If false, then any configuration is acceptable.
enforced This property is required. bool
If true, then the Policy is enforced. If false, then any configuration is acceptable.
enforced This property is required. Boolean
If true, then the Policy is enforced. If false, then any configuration is acceptable.

GetOrganizationPolicyListPolicy

Allows This property is required. List<GetOrganizationPolicyListPolicyAllow>
One or the other must be set.
Denies This property is required. List<GetOrganizationPolicyListPolicyDeny>
One or the other must be set.
InheritFromParent This property is required. bool
If set to true, the values from the effective Policy of the parent resource are inherited, meaning the values set in this Policy are added to the values inherited up the hierarchy.
SuggestedValue This property is required. string
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
Allows This property is required. []GetOrganizationPolicyListPolicyAllow
One or the other must be set.
Denies This property is required. []GetOrganizationPolicyListPolicyDeny
One or the other must be set.
InheritFromParent This property is required. bool
If set to true, the values from the effective Policy of the parent resource are inherited, meaning the values set in this Policy are added to the values inherited up the hierarchy.
SuggestedValue This property is required. string
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
allows This property is required. List<GetOrganizationPolicyListPolicyAllow>
One or the other must be set.
denies This property is required. List<GetOrganizationPolicyListPolicyDeny>
One or the other must be set.
inheritFromParent This property is required. Boolean
If set to true, the values from the effective Policy of the parent resource are inherited, meaning the values set in this Policy are added to the values inherited up the hierarchy.
suggestedValue This property is required. String
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
allows This property is required. GetOrganizationPolicyListPolicyAllow[]
One or the other must be set.
denies This property is required. GetOrganizationPolicyListPolicyDeny[]
One or the other must be set.
inheritFromParent This property is required. boolean
If set to true, the values from the effective Policy of the parent resource are inherited, meaning the values set in this Policy are added to the values inherited up the hierarchy.
suggestedValue This property is required. string
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
allows This property is required. Sequence[GetOrganizationPolicyListPolicyAllow]
One or the other must be set.
denies This property is required. Sequence[GetOrganizationPolicyListPolicyDeny]
One or the other must be set.
inherit_from_parent This property is required. bool
If set to true, the values from the effective Policy of the parent resource are inherited, meaning the values set in this Policy are added to the values inherited up the hierarchy.
suggested_value This property is required. str
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
allows This property is required. List<Property Map>
One or the other must be set.
denies This property is required. List<Property Map>
One or the other must be set.
inheritFromParent This property is required. Boolean
If set to true, the values from the effective Policy of the parent resource are inherited, meaning the values set in this Policy are added to the values inherited up the hierarchy.
suggestedValue This property is required. String
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.

GetOrganizationPolicyListPolicyAllow

All This property is required. bool
The policy allows or denies all values.
Values This property is required. List<string>
The policy can define specific values that are allowed or denied.
All This property is required. bool
The policy allows or denies all values.
Values This property is required. []string
The policy can define specific values that are allowed or denied.
all This property is required. Boolean
The policy allows or denies all values.
values This property is required. List<String>
The policy can define specific values that are allowed or denied.
all This property is required. boolean
The policy allows or denies all values.
values This property is required. string[]
The policy can define specific values that are allowed or denied.
all This property is required. bool
The policy allows or denies all values.
values This property is required. Sequence[str]
The policy can define specific values that are allowed or denied.
all This property is required. Boolean
The policy allows or denies all values.
values This property is required. List<String>
The policy can define specific values that are allowed or denied.

GetOrganizationPolicyListPolicyDeny

All This property is required. bool
The policy allows or denies all values.
Values This property is required. List<string>
The policy can define specific values that are allowed or denied.
All This property is required. bool
The policy allows or denies all values.
Values This property is required. []string
The policy can define specific values that are allowed or denied.
all This property is required. Boolean
The policy allows or denies all values.
values This property is required. List<String>
The policy can define specific values that are allowed or denied.
all This property is required. boolean
The policy allows or denies all values.
values This property is required. string[]
The policy can define specific values that are allowed or denied.
all This property is required. bool
The policy allows or denies all values.
values This property is required. Sequence[str]
The policy can define specific values that are allowed or denied.
all This property is required. Boolean
The policy allows or denies all values.
values This property is required. List<String>
The policy can define specific values that are allowed or denied.

GetOrganizationPolicyRestorePolicy

Default This property is required. bool
May only be set to true. If set, then the default Policy is restored.
Default This property is required. bool
May only be set to true. If set, then the default Policy is restored.
default_ This property is required. Boolean
May only be set to true. If set, then the default Policy is restored.
default This property is required. boolean
May only be set to true. If set, then the default Policy is restored.
default This property is required. bool
May only be set to true. If set, then the default Policy is restored.
default This property is required. Boolean
May only be set to true. If set, then the default Policy is restored.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi