Policy

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

Example Usage

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var serialPortPolicy = new Gcp.Organizations.Policy("serialPortPolicy", new Gcp.Organizations.PolicyArgs
        {
            BooleanPolicy = new Gcp.Organizations.Inputs.PolicyBooleanPolicyArgs
            {
                Enforced = true,
            },
            Constraint = "compute.disableSerialPortAccess",
            OrgId = "123456789",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := organizations.NewPolicy(ctx, "serialPortPolicy", &organizations.PolicyArgs{
			BooleanPolicy: &organizations.PolicyBooleanPolicyArgs{
				Enforced: pulumi.Bool(true),
			},
			Constraint: pulumi.String("compute.disableSerialPortAccess"),
			OrgId:      pulumi.String("123456789"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_gcp as gcp

serial_port_policy = gcp.organizations.Policy("serialPortPolicy",
    boolean_policy=gcp.organizations.PolicyBooleanPolicyArgs(
        enforced=True,
    ),
    constraint="compute.disableSerialPortAccess",
    org_id="123456789")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const serialPortPolicy = new gcp.organizations.Policy("serial_port_policy", {
    booleanPolicy: {
        enforced: true,
    },
    constraint: "compute.disableSerialPortAccess",
    orgId: "123456789",
});

Create a Policy Resource

new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
@overload
def Policy(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           boolean_policy: Optional[PolicyBooleanPolicyArgs] = None,
           constraint: Optional[str] = None,
           list_policy: Optional[PolicyListPolicyArgs] = None,
           org_id: Optional[str] = None,
           restore_policy: Optional[PolicyRestorePolicyArgs] = None,
           version: Optional[int] = 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)
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.

Policy Resource Properties

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

Inputs

The Policy resource accepts the following input properties:

Constraint string
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
OrgId string
The numeric ID of the organization to set the policy for.
BooleanPolicy PolicyBooleanPolicyArgs
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
ListPolicy PolicyListPolicyArgs
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
RestorePolicy PolicyRestorePolicyArgs
A restore policy is a constraint to restore the default policy. Structure is documented below.
Version int
Version of the Policy. Default version is 0.
Constraint string
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
OrgId string
The numeric ID of the organization to set the policy for.
BooleanPolicy PolicyBooleanPolicy
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
ListPolicy PolicyListPolicy
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
RestorePolicy PolicyRestorePolicy
A restore policy is a constraint to restore the default policy. Structure is documented below.
Version int
Version of the Policy. Default version is 0.
constraint string
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
orgId string
The numeric ID of the organization to set the policy for.
booleanPolicy PolicyBooleanPolicyArgs
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
listPolicy PolicyListPolicyArgs
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
restorePolicy PolicyRestorePolicyArgs
A restore policy is a constraint to restore the default policy. Structure is documented below.
version number
Version of the Policy. Default version is 0.
constraint str
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
org_id str
The numeric ID of the organization to set the policy for.
boolean_policy PolicyBooleanPolicyArgs
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
list_policy PolicyListPolicyArgs
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
restore_policy PolicyRestorePolicyArgs
A restore policy is a constraint to restore the default policy. Structure is documented below.
version int
Version of the Policy. Default version is 0.

Outputs

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

Etag string
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
Id string
The provider-assigned unique ID for this managed resource.
UpdateTime string
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
Etag string
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
Id string
The provider-assigned unique ID for this managed resource.
UpdateTime string
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
etag string
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
id string
The provider-assigned unique ID for this managed resource.
updateTime string
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
etag str
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
id str
The provider-assigned unique ID for this managed resource.
update_time str
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.

Look up an 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,
        boolean_policy: Optional[PolicyBooleanPolicyArgs] = None,
        constraint: Optional[str] = None,
        etag: Optional[str] = None,
        list_policy: Optional[PolicyListPolicyArgs] = None,
        org_id: Optional[str] = None,
        restore_policy: Optional[PolicyRestorePolicyArgs] = None,
        update_time: Optional[str] = None,
        version: Optional[int] = 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)
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.

The following state arguments are supported:

BooleanPolicy PolicyBooleanPolicyArgs
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
Constraint string
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
Etag string
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
ListPolicy PolicyListPolicyArgs
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
OrgId string
The numeric ID of the organization to set the policy for.
RestorePolicy PolicyRestorePolicyArgs
A restore policy is a constraint to restore the default policy. Structure is documented below.
UpdateTime string
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
Version int
Version of the Policy. Default version is 0.
BooleanPolicy PolicyBooleanPolicy
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
Constraint string
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
Etag string
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
ListPolicy PolicyListPolicy
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
OrgId string
The numeric ID of the organization to set the policy for.
RestorePolicy PolicyRestorePolicy
A restore policy is a constraint to restore the default policy. Structure is documented below.
UpdateTime string
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
Version int
Version of the Policy. Default version is 0.
booleanPolicy PolicyBooleanPolicyArgs
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
constraint string
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
etag string
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
listPolicy PolicyListPolicyArgs
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
orgId string
The numeric ID of the organization to set the policy for.
restorePolicy PolicyRestorePolicyArgs
A restore policy is a constraint to restore the default policy. Structure is documented below.
updateTime string
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
version number
Version of the Policy. Default version is 0.
boolean_policy PolicyBooleanPolicyArgs
A boolean policy is a constraint that is either enforced or not. Structure is documented below.
constraint str
The name of the Constraint the Policy is configuring, for example, serviceuser.services. Check out the complete list of available constraints.
etag str
(Computed) The etag of the organization policy. etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
list_policy PolicyListPolicyArgs
A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
org_id str
The numeric ID of the organization to set the policy for.
restore_policy PolicyRestorePolicyArgs
A restore policy is a constraint to restore the default policy. Structure is documented below.
update_time str
(Computed) The timestamp in RFC3339 UTC “Zulu” format, accurate to nanoseconds, representing when the variable was last updated. Example: “2016-10-09T12:33:37.578138407Z”.
version int
Version of the Policy. Default version is 0.

Supporting Types

PolicyBooleanPolicy

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

PolicyListPolicy

Allow PolicyListPolicyAllowArgs
or deny - (Optional) One or the other must be set.
Deny PolicyListPolicyDenyArgs
InheritFromParent 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 string
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
Allow PolicyListPolicyAllow
or deny - (Optional) One or the other must be set.
Deny PolicyListPolicyDeny
InheritFromParent 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 string
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
allow PolicyListPolicyAllowArgs
or deny - (Optional) One or the other must be set.
deny PolicyListPolicyDenyArgs
inheritFromParent 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 string
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.
allow PolicyListPolicyAllowArgs
or deny - (Optional) One or the other must be set.
deny PolicyListPolicyDenyArgs
inherit_from_parent 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 str
The Google Cloud Console will try to default to a configuration that matches the value specified in this field.

PolicyListPolicyAllow

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

PolicyListPolicyDeny

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

PolicyRestorePolicy

Default bool
May only be set to true. If set, then the default Policy is restored.
Default bool
May only be set to true. If set, then the default Policy is restored.
default boolean
May only be set to true. If set, then the default Policy is restored.
default bool
May only be set to true. If set, then the default Policy is restored.

Import

Organization Policies can be imported using the org_id and the constraint, e.g.

 $ pulumi import gcp:organizations/policy:Policy services_policy 123456789/constraints/serviceuser.services

It is all right if the constraint contains a slash, as in the example above.

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.