CustomConstraint

class CustomConstraint : KotlinCustomResource

Example Usage

Org Policy Custom Constraint Basic

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.orgpolicy.CustomConstraint;
import com.pulumi.gcp.orgpolicy.CustomConstraintArgs;
import com.pulumi.resources.CustomResourceOptions;
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 constraint = new CustomConstraint("constraint", CustomConstraintArgs.builder()
.parent("organizations/123456789")
.actionType("ALLOW")
.condition("resource.management.autoUpgrade == false")
.methodTypes(
"CREATE",
"UPDATE")
.resourceTypes("container.googleapis.com/NodePool")
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
}
}

Org Policy Custom Constraint Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.orgpolicy.CustomConstraint;
import com.pulumi.gcp.orgpolicy.CustomConstraintArgs;
import com.pulumi.gcp.orgpolicy.Policy;
import com.pulumi.gcp.orgpolicy.PolicyArgs;
import com.pulumi.gcp.orgpolicy.inputs.PolicySpecArgs;
import com.pulumi.resources.CustomResourceOptions;
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 constraint = new CustomConstraint("constraint", CustomConstraintArgs.builder()
.parent("organizations/123456789")
.displayName("Disable GKE auto upgrade")
.description("Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.")
.actionType("ALLOW")
.condition("resource.management.autoUpgrade == false")
.methodTypes(
"CREATE",
"UPDATE")
.resourceTypes("container.googleapis.com/NodePool")
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
var bool = new Policy("bool", PolicyArgs.builder()
.parent("organizations/123456789")
.spec(PolicySpecArgs.builder()
.rules(PolicySpecRuleArgs.builder()
.enforce("TRUE")
.build())
.build())
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
}
}

Import

CustomConstraint can be imported using any of these accepted formats:

$ pulumi import gcp:orgpolicy/customConstraint:CustomConstraint default {{parent}}/customConstraints/{{name}}

Properties

Link copied to clipboard
val actionType: Output<String>

The action to take if the condition is met. Possible values are: ALLOW, DENY.

Link copied to clipboard
val condition: Output<String>

A CEL condition that refers to a supported service resource, for example resource.management.autoUpgrade == false. For details about CEL usage, see Common Expression Language.

Link copied to clipboard
val description: Output<String>?

A human-friendly description of the constraint to display as an error message when the policy is violated.

Link copied to clipboard
val displayName: Output<String>?

A human-friendly name for the constraint.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val methodTypes: Output<List<String>>

A list of RESTful methods for which to enforce the constraint. Can be CREATE, UPDATE, or both. Not all Google Cloud services support both methods. To see supported methods for each service, find the service in Supported services.

Link copied to clipboard
val name: Output<String>

Immutable. The name of the custom constraint. This is unique within the organization.

Link copied to clipboard
val parent: Output<String>

The parent of the resource, an organization. Format should be organizations/{organization_id}.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val resourceTypes: Output<List<String>>

Immutable. The fully qualified name of the Google Cloud REST resource containing the object and field you want to restrict. For example, container.googleapis.com/NodePool.

Link copied to clipboard
val updateTime: Output<String>

Output only. The timestamp representing when the constraint was last updated.

Link copied to clipboard
val urn: Output<String>