1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. orgpolicy
  5. Policy
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

gcp.orgpolicy.Policy

Explore with Pulumi AI

gcp logo
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

    An organization policy gives you programmatic control over your organization’s cloud resources. Using Organization Policies, you will be able to configure constraints across your entire resource hierarchy.

    For more information, see:

    Example Usage

    Enforce_policy

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var basic = new Gcp.Organizations.Project("basic", new()
        {
            OrgId = "123456789",
            ProjectId = "id",
        });
    
        var primary = new Gcp.OrgPolicy.Policy("primary", new()
        {
            Parent = basic.Name.Apply(name => $"projects/{name}"),
            Spec = new Gcp.OrgPolicy.Inputs.PolicySpecArgs
            {
                Rules = new[]
                {
                    new Gcp.OrgPolicy.Inputs.PolicySpecRuleArgs
                    {
                        Enforce = "FALSE",
                    },
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/orgpolicy"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
    			OrgId:     pulumi.String("123456789"),
    			ProjectId: pulumi.String("id"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = orgpolicy.NewPolicy(ctx, "primary", &orgpolicy.PolicyArgs{
    			Parent: basic.Name.ApplyT(func(name string) (string, error) {
    				return fmt.Sprintf("projects/%v", name), nil
    			}).(pulumi.StringOutput),
    			Spec: &orgpolicy.PolicySpecArgs{
    				Rules: orgpolicy.PolicySpecRuleArray{
    					&orgpolicy.PolicySpecRuleArgs{
    						Enforce: pulumi.String("FALSE"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.organizations.Project;
    import com.pulumi.gcp.organizations.ProjectArgs;
    import com.pulumi.gcp.orgpolicy.Policy;
    import com.pulumi.gcp.orgpolicy.PolicyArgs;
    import com.pulumi.gcp.orgpolicy.inputs.PolicySpecArgs;
    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) {
            var basic = new Project("basic", ProjectArgs.builder()        
                .orgId("123456789")
                .projectId("id")
                .build());
    
            var primary = new Policy("primary", PolicyArgs.builder()        
                .parent(basic.name().applyValue(name -> String.format("projects/%s", name)))
                .spec(PolicySpecArgs.builder()
                    .rules(PolicySpecRuleArgs.builder()
                        .enforce("FALSE")
                        .build())
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    basic = gcp.organizations.Project("basic",
        org_id="123456789",
        project_id="id")
    primary = gcp.orgpolicy.Policy("primary",
        parent=basic.name.apply(lambda name: f"projects/{name}"),
        spec=gcp.orgpolicy.PolicySpecArgs(
            rules=[gcp.orgpolicy.PolicySpecRuleArgs(
                enforce="FALSE",
            )],
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const basic = new gcp.organizations.Project("basic", {
        orgId: "123456789",
        projectId: "id",
    });
    const primary = new gcp.orgpolicy.Policy("primary", {
        parent: pulumi.interpolate`projects/${basic.name}`,
        spec: {
            rules: [{
                enforce: "FALSE",
            }],
        },
    });
    
    resources:
      primary:
        type: gcp:orgpolicy:Policy
        properties:
          parent: projects/${basic.name}
          spec:
            rules:
              - enforce: FALSE
      basic:
        type: gcp:organizations:Project
        properties:
          orgId: '123456789'
          projectId: id
    

    Folder_policy

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var basic = new Gcp.Organizations.Folder("basic", new()
        {
            Parent = "organizations/123456789",
            DisplayName = "folder",
        });
    
        var primary = new Gcp.OrgPolicy.Policy("primary", new()
        {
            Parent = basic.Name,
            Spec = new Gcp.OrgPolicy.Inputs.PolicySpecArgs
            {
                InheritFromParent = true,
                Rules = new[]
                {
                    new Gcp.OrgPolicy.Inputs.PolicySpecRuleArgs
                    {
                        DenyAll = "TRUE",
                    },
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/orgpolicy"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		basic, err := organizations.NewFolder(ctx, "basic", &organizations.FolderArgs{
    			Parent:      pulumi.String("organizations/123456789"),
    			DisplayName: pulumi.String("folder"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = orgpolicy.NewPolicy(ctx, "primary", &orgpolicy.PolicyArgs{
    			Parent: basic.Name,
    			Spec: &orgpolicy.PolicySpecArgs{
    				InheritFromParent: pulumi.Bool(true),
    				Rules: orgpolicy.PolicySpecRuleArray{
    					&orgpolicy.PolicySpecRuleArgs{
    						DenyAll: pulumi.String("TRUE"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.organizations.Folder;
    import com.pulumi.gcp.organizations.FolderArgs;
    import com.pulumi.gcp.orgpolicy.Policy;
    import com.pulumi.gcp.orgpolicy.PolicyArgs;
    import com.pulumi.gcp.orgpolicy.inputs.PolicySpecArgs;
    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) {
            var basic = new Folder("basic", FolderArgs.builder()        
                .parent("organizations/123456789")
                .displayName("folder")
                .build());
    
            var primary = new Policy("primary", PolicyArgs.builder()        
                .parent(basic.name())
                .spec(PolicySpecArgs.builder()
                    .inheritFromParent(true)
                    .rules(PolicySpecRuleArgs.builder()
                        .denyAll("TRUE")
                        .build())
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    basic = gcp.organizations.Folder("basic",
        parent="organizations/123456789",
        display_name="folder")
    primary = gcp.orgpolicy.Policy("primary",
        parent=basic.name,
        spec=gcp.orgpolicy.PolicySpecArgs(
            inherit_from_parent=True,
            rules=[gcp.orgpolicy.PolicySpecRuleArgs(
                deny_all="TRUE",
            )],
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const basic = new gcp.organizations.Folder("basic", {
        parent: "organizations/123456789",
        displayName: "folder",
    });
    const primary = new gcp.orgpolicy.Policy("primary", {
        parent: basic.name,
        spec: {
            inheritFromParent: true,
            rules: [{
                denyAll: "TRUE",
            }],
        },
    });
    
    resources:
      primary:
        type: gcp:orgpolicy:Policy
        properties:
          parent: ${basic.name}
          spec:
            inheritFromParent: true
            rules:
              - denyAll: TRUE
      basic:
        type: gcp:organizations:Folder
        properties:
          parent: organizations/123456789
          displayName: folder
    

    Organization_policy

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var primary = new Gcp.OrgPolicy.Policy("primary", new()
        {
            Parent = "organizations/123456789",
            Spec = new Gcp.OrgPolicy.Inputs.PolicySpecArgs
            {
                Reset = true,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/orgpolicy"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := orgpolicy.NewPolicy(ctx, "primary", &orgpolicy.PolicyArgs{
    			Parent: pulumi.String("organizations/123456789"),
    			Spec: &orgpolicy.PolicySpecArgs{
    				Reset: pulumi.Bool(true),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.orgpolicy.Policy;
    import com.pulumi.gcp.orgpolicy.PolicyArgs;
    import com.pulumi.gcp.orgpolicy.inputs.PolicySpecArgs;
    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) {
            var primary = new Policy("primary", PolicyArgs.builder()        
                .parent("organizations/123456789")
                .spec(PolicySpecArgs.builder()
                    .reset(true)
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    primary = gcp.orgpolicy.Policy("primary",
        parent="organizations/123456789",
        spec=gcp.orgpolicy.PolicySpecArgs(
            reset=True,
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const primary = new gcp.orgpolicy.Policy("primary", {
        parent: "organizations/123456789",
        spec: {
            reset: true,
        },
    });
    
    resources:
      primary:
        type: gcp:orgpolicy:Policy
        properties:
          parent: organizations/123456789
          spec:
            reset: true
    

    Project_policy

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var basic = new Gcp.Organizations.Project("basic", new()
        {
            OrgId = "123456789",
            ProjectId = "id",
        });
    
        var primary = new Gcp.OrgPolicy.Policy("primary", new()
        {
            Parent = basic.Name.Apply(name => $"projects/{name}"),
            Spec = new Gcp.OrgPolicy.Inputs.PolicySpecArgs
            {
                Rules = new[]
                {
                    new Gcp.OrgPolicy.Inputs.PolicySpecRuleArgs
                    {
                        Condition = new Gcp.OrgPolicy.Inputs.PolicySpecRuleConditionArgs
                        {
                            Description = "A sample condition for the policy",
                            Expression = "resource.matchLabels('labelKeys/123', 'labelValues/345')",
                            Location = "sample-location.log",
                            Title = "sample-condition",
                        },
                        Values = new Gcp.OrgPolicy.Inputs.PolicySpecRuleValuesArgs
                        {
                            AllowedValues = new[]
                            {
                                "projects/allowed-project",
                            },
                            DeniedValues = new[]
                            {
                                "projects/denied-project",
                            },
                        },
                    },
                    new Gcp.OrgPolicy.Inputs.PolicySpecRuleArgs
                    {
                        AllowAll = "TRUE",
                    },
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/orgpolicy"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
    			OrgId:     pulumi.String("123456789"),
    			ProjectId: pulumi.String("id"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = orgpolicy.NewPolicy(ctx, "primary", &orgpolicy.PolicyArgs{
    			Parent: basic.Name.ApplyT(func(name string) (string, error) {
    				return fmt.Sprintf("projects/%v", name), nil
    			}).(pulumi.StringOutput),
    			Spec: &orgpolicy.PolicySpecArgs{
    				Rules: orgpolicy.PolicySpecRuleArray{
    					&orgpolicy.PolicySpecRuleArgs{
    						Condition: &orgpolicy.PolicySpecRuleConditionArgs{
    							Description: pulumi.String("A sample condition for the policy"),
    							Expression:  pulumi.String("resource.matchLabels('labelKeys/123', 'labelValues/345')"),
    							Location:    pulumi.String("sample-location.log"),
    							Title:       pulumi.String("sample-condition"),
    						},
    						Values: &orgpolicy.PolicySpecRuleValuesArgs{
    							AllowedValues: pulumi.StringArray{
    								pulumi.String("projects/allowed-project"),
    							},
    							DeniedValues: pulumi.StringArray{
    								pulumi.String("projects/denied-project"),
    							},
    						},
    					},
    					&orgpolicy.PolicySpecRuleArgs{
    						AllowAll: pulumi.String("TRUE"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.organizations.Project;
    import com.pulumi.gcp.organizations.ProjectArgs;
    import com.pulumi.gcp.orgpolicy.Policy;
    import com.pulumi.gcp.orgpolicy.PolicyArgs;
    import com.pulumi.gcp.orgpolicy.inputs.PolicySpecArgs;
    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) {
            var basic = new Project("basic", ProjectArgs.builder()        
                .orgId("123456789")
                .projectId("id")
                .build());
    
            var primary = new Policy("primary", PolicyArgs.builder()        
                .parent(basic.name().applyValue(name -> String.format("projects/%s", name)))
                .spec(PolicySpecArgs.builder()
                    .rules(                
                        PolicySpecRuleArgs.builder()
                            .condition(PolicySpecRuleConditionArgs.builder()
                                .description("A sample condition for the policy")
                                .expression("resource.matchLabels('labelKeys/123', 'labelValues/345')")
                                .location("sample-location.log")
                                .title("sample-condition")
                                .build())
                            .values(PolicySpecRuleValuesArgs.builder()
                                .allowedValues("projects/allowed-project")
                                .deniedValues("projects/denied-project")
                                .build())
                            .build(),
                        PolicySpecRuleArgs.builder()
                            .allowAll("TRUE")
                            .build())
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    basic = gcp.organizations.Project("basic",
        org_id="123456789",
        project_id="id")
    primary = gcp.orgpolicy.Policy("primary",
        parent=basic.name.apply(lambda name: f"projects/{name}"),
        spec=gcp.orgpolicy.PolicySpecArgs(
            rules=[
                gcp.orgpolicy.PolicySpecRuleArgs(
                    condition=gcp.orgpolicy.PolicySpecRuleConditionArgs(
                        description="A sample condition for the policy",
                        expression="resource.matchLabels('labelKeys/123', 'labelValues/345')",
                        location="sample-location.log",
                        title="sample-condition",
                    ),
                    values=gcp.orgpolicy.PolicySpecRuleValuesArgs(
                        allowed_values=["projects/allowed-project"],
                        denied_values=["projects/denied-project"],
                    ),
                ),
                gcp.orgpolicy.PolicySpecRuleArgs(
                    allow_all="TRUE",
                ),
            ],
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const basic = new gcp.organizations.Project("basic", {
        orgId: "123456789",
        projectId: "id",
    });
    const primary = new gcp.orgpolicy.Policy("primary", {
        parent: pulumi.interpolate`projects/${basic.name}`,
        spec: {
            rules: [
                {
                    condition: {
                        description: "A sample condition for the policy",
                        expression: "resource.matchLabels('labelKeys/123', 'labelValues/345')",
                        location: "sample-location.log",
                        title: "sample-condition",
                    },
                    values: {
                        allowedValues: ["projects/allowed-project"],
                        deniedValues: ["projects/denied-project"],
                    },
                },
                {
                    allowAll: "TRUE",
                },
            ],
        },
    });
    
    resources:
      primary:
        type: gcp:orgpolicy:Policy
        properties:
          parent: projects/${basic.name}
          spec:
            rules:
              - condition:
                  description: A sample condition for the policy
                  expression: resource.matchLabels('labelKeys/123', 'labelValues/345')
                  location: sample-location.log
                  title: sample-condition
                values:
                  allowedValues:
                    - projects/allowed-project
                  deniedValues:
                    - projects/denied-project
              - allowAll: TRUE
      basic:
        type: gcp:organizations:Project
        properties:
          orgId: '123456789'
          projectId: id
    

    Create Policy Resource

    new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
    @overload
    def Policy(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               name: Optional[str] = None,
               parent: Optional[str] = None,
               spec: Optional[PolicySpecArgs] = None)
    @overload
    def Policy(resource_name: str,
               args: PolicyArgs,
               opts: Optional[ResourceOptions] = None)
    func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
    public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
    public Policy(String name, PolicyArgs args)
    public Policy(String name, PolicyArgs args, CustomResourceOptions options)
    
    type: gcp:orgpolicy:Policy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Policy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The Policy resource accepts the following input properties:

    Parent string

    The parent of the resource.


    Name string

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    Spec PolicySpec

    Basic information about the Organization Policy.

    Parent string

    The parent of the resource.


    Name string

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    Spec PolicySpecArgs

    Basic information about the Organization Policy.

    parent String

    The parent of the resource.


    name String

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    spec PolicySpec

    Basic information about the Organization Policy.

    parent string

    The parent of the resource.


    name string

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    spec PolicySpec

    Basic information about the Organization Policy.

    parent str

    The parent of the resource.


    name str

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    spec PolicySpecArgs

    Basic information about the Organization Policy.

    parent String

    The parent of the resource.


    name String

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    spec Property Map

    Basic information about the Organization Policy.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Policy resource produces the following output properties:

    Id string

    The provider-assigned unique ID for this managed resource.

    Id string

    The provider-assigned unique ID for this managed resource.

    id String

    The provider-assigned unique ID for this managed resource.

    id string

    The provider-assigned unique ID for this managed resource.

    id str

    The provider-assigned unique ID for this managed resource.

    id String

    The provider-assigned unique ID for this managed resource.

    Look up Existing Policy Resource

    Get an existing Policy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: PolicyState, opts?: CustomResourceOptions): Policy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            name: Optional[str] = None,
            parent: Optional[str] = None,
            spec: Optional[PolicySpecArgs] = None) -> Policy
    func GetPolicy(ctx *Context, name string, id IDInput, state *PolicyState, opts ...ResourceOption) (*Policy, error)
    public static Policy Get(string name, Input<string> id, PolicyState? state, CustomResourceOptions? opts = null)
    public static Policy get(String name, Output<String> id, PolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Name string

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    Parent string

    The parent of the resource.


    Spec PolicySpec

    Basic information about the Organization Policy.

    Name string

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    Parent string

    The parent of the resource.


    Spec PolicySpecArgs

    Basic information about the Organization Policy.

    name String

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    parent String

    The parent of the resource.


    spec PolicySpec

    Basic information about the Organization Policy.

    name string

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    parent string

    The parent of the resource.


    spec PolicySpec

    Basic information about the Organization Policy.

    name str

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    parent str

    The parent of the resource.


    spec PolicySpecArgs

    Basic information about the Organization Policy.

    name String

    Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, "projects/123/policies/compute.disableSerialPortAccess". Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

    parent String

    The parent of the resource.


    spec Property Map

    Basic information about the Organization Policy.

    Supporting Types

    PolicySpec, PolicySpecArgs

    Etag string

    An opaque tag indicating the current version of the Policy, used for concurrency control. This field is ignored if used in a CreatePolicy request. When the Policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current Policy to use when executing a read-modify-write loop. When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

    InheritFromParent bool

    Determines the inheritance behavior for this Policy. If inherit_from_parent is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.

    Reset bool

    Ignores policies set above this resource and restores the constraint_default enforcement behavior of the specific Constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inherit_from_parent must be set to false.

    Rules List<PolicySpecRule>

    Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

    UpdateTime string

    Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that Policy.

    Etag string

    An opaque tag indicating the current version of the Policy, used for concurrency control. This field is ignored if used in a CreatePolicy request. When the Policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current Policy to use when executing a read-modify-write loop. When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

    InheritFromParent bool

    Determines the inheritance behavior for this Policy. If inherit_from_parent is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.

    Reset bool

    Ignores policies set above this resource and restores the constraint_default enforcement behavior of the specific Constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inherit_from_parent must be set to false.

    Rules []PolicySpecRule

    Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

    UpdateTime string

    Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that Policy.

    etag String

    An opaque tag indicating the current version of the Policy, used for concurrency control. This field is ignored if used in a CreatePolicy request. When the Policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current Policy to use when executing a read-modify-write loop. When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

    inheritFromParent Boolean

    Determines the inheritance behavior for this Policy. If inherit_from_parent is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.

    reset Boolean

    Ignores policies set above this resource and restores the constraint_default enforcement behavior of the specific Constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inherit_from_parent must be set to false.

    rules List<PolicySpecRule>

    Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

    updateTime String

    Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that Policy.

    etag string

    An opaque tag indicating the current version of the Policy, used for concurrency control. This field is ignored if used in a CreatePolicy request. When the Policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current Policy to use when executing a read-modify-write loop. When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

    inheritFromParent boolean

    Determines the inheritance behavior for this Policy. If inherit_from_parent is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.

    reset boolean

    Ignores policies set above this resource and restores the constraint_default enforcement behavior of the specific Constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inherit_from_parent must be set to false.

    rules PolicySpecRule[]

    Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

    updateTime string

    Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that Policy.

    etag str

    An opaque tag indicating the current version of the Policy, used for concurrency control. This field is ignored if used in a CreatePolicy request. When the Policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current Policy to use when executing a read-modify-write loop. When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

    inherit_from_parent bool

    Determines the inheritance behavior for this Policy. If inherit_from_parent is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.

    reset bool

    Ignores policies set above this resource and restores the constraint_default enforcement behavior of the specific Constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inherit_from_parent must be set to false.

    rules Sequence[PolicySpecRule]

    Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

    update_time str

    Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that Policy.

    etag String

    An opaque tag indicating the current version of the Policy, used for concurrency control. This field is ignored if used in a CreatePolicy request. When the Policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current Policy to use when executing a read-modify-write loop. When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

    inheritFromParent Boolean

    Determines the inheritance behavior for this Policy. If inherit_from_parent is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.

    reset Boolean

    Ignores policies set above this resource and restores the constraint_default enforcement behavior of the specific Constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inherit_from_parent must be set to false.

    rules List<Property Map>

    Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

    updateTime String

    Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that Policy.

    PolicySpecRule, PolicySpecRuleArgs

    AllowAll string

    Setting this to true means that all values are allowed. This field can be set only in Policies for list constraints.

    Condition PolicySpecRuleCondition

    A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

    DenyAll string

    Setting this to true means that all values are denied. This field can be set only in Policies for list constraints.

    Enforce string

    If true, then the Policy is enforced. If false, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.

    Values PolicySpecRuleValues

    List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

    AllowAll string

    Setting this to true means that all values are allowed. This field can be set only in Policies for list constraints.

    Condition PolicySpecRuleCondition

    A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

    DenyAll string

    Setting this to true means that all values are denied. This field can be set only in Policies for list constraints.

    Enforce string

    If true, then the Policy is enforced. If false, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.

    Values PolicySpecRuleValues

    List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

    allowAll String

    Setting this to true means that all values are allowed. This field can be set only in Policies for list constraints.

    condition PolicySpecRuleCondition

    A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

    denyAll String

    Setting this to true means that all values are denied. This field can be set only in Policies for list constraints.

    enforce String

    If true, then the Policy is enforced. If false, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.

    values PolicySpecRuleValues

    List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

    allowAll string

    Setting this to true means that all values are allowed. This field can be set only in Policies for list constraints.

    condition PolicySpecRuleCondition

    A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

    denyAll string

    Setting this to true means that all values are denied. This field can be set only in Policies for list constraints.

    enforce string

    If true, then the Policy is enforced. If false, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.

    values PolicySpecRuleValues

    List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

    allow_all str

    Setting this to true means that all values are allowed. This field can be set only in Policies for list constraints.

    condition PolicySpecRuleCondition

    A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

    deny_all str

    Setting this to true means that all values are denied. This field can be set only in Policies for list constraints.

    enforce str

    If true, then the Policy is enforced. If false, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.

    values PolicySpecRuleValues

    List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

    allowAll String

    Setting this to true means that all values are allowed. This field can be set only in Policies for list constraints.

    condition Property Map

    A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

    denyAll String

    Setting this to true means that all values are denied. This field can be set only in Policies for list constraints.

    enforce String

    If true, then the Policy is enforced. If false, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.

    values Property Map

    List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

    PolicySpecRuleCondition, PolicySpecRuleConditionArgs

    Description string

    Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.

    Expression string

    Textual representation of an expression in Common Expression Language syntax.

    Location string

    Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.

    Title string

    Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.

    Description string

    Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.

    Expression string

    Textual representation of an expression in Common Expression Language syntax.

    Location string

    Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.

    Title string

    Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.

    description String

    Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.

    expression String

    Textual representation of an expression in Common Expression Language syntax.

    location String

    Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.

    title String

    Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.

    description string

    Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.

    expression string

    Textual representation of an expression in Common Expression Language syntax.

    location string

    Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.

    title string

    Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.

    description str

    Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.

    expression str

    Textual representation of an expression in Common Expression Language syntax.

    location str

    Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.

    title str

    Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.

    description String

    Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.

    expression String

    Textual representation of an expression in Common Expression Language syntax.

    location String

    Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.

    title String

    Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.

    PolicySpecRuleValues, PolicySpecRuleValuesArgs

    AllowedValues List<string>

    List of values allowed at this resource.

    DeniedValues List<string>

    List of values denied at this resource.

    AllowedValues []string

    List of values allowed at this resource.

    DeniedValues []string

    List of values denied at this resource.

    allowedValues List<String>

    List of values allowed at this resource.

    deniedValues List<String>

    List of values denied at this resource.

    allowedValues string[]

    List of values allowed at this resource.

    deniedValues string[]

    List of values denied at this resource.

    allowed_values Sequence[str]

    List of values allowed at this resource.

    denied_values Sequence[str]

    List of values denied at this resource.

    allowedValues List<String>

    List of values allowed at this resource.

    deniedValues List<String>

    List of values denied at this resource.

    Import

    Policy can be imported using any of these accepted formats:

     $ pulumi import gcp:orgpolicy/policy:Policy default {{parent}}/policies/{{name}}
    

    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.

    gcp logo
    Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi