Pulumi Policy
The Pulumi Policy SDK for Python.
- class pulumi_policy.EnforcementLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Indicates the impact of a policy violation.
- class pulumi_policy.Policy(name: str, description: str, enforcement_level: EnforcementLevel | None = None, config_schema: PolicyConfigSchema | None = None)
A policy function that returns true if a resource definition violates some policy (e.g., “no public S3 buckets”), and a set of metadata useful for generating helpful messages when the policy is violated.
- Parameters:
name (str) – An ID for the policy. Must be unique within the current policy set.
description (str) – A brief description of the policy rule. e.g., “S3 buckets should have default encryptionenabled.”
enforcement_level (Optional[EnforcementLevel]) – Indicates what to do on policy violation, e.g., block deployment but allow override with proper permissions.
config_schema (Optional[PolicyConfigSchema]) – This policy’s configuration schema.
- description: str
A brief description of the policy rule. e.g., “S3 buckets should have default encryption enabled.”
- enforcement_level: EnforcementLevel | None
Indicates what to do on policy violation, e.g., block deployment but allow override with proper permissions.
- config_schema: PolicyConfigSchema | None
This policy’s configuration schema.
- class pulumi_policy.PolicyConfigSchema(properties: Dict[str, Dict[str, Any]], required: List[str] | None = None)
Represents the configuration schema for a policy.
- Parameters:
properties (Dict[str, Dict[str, Any]]) – The policy’s configuration properties.
required (Optional[List[str]]) – The configuration properties that are required.
- properties: Dict[str, Dict[str, Any]]
The policy’s configuration properties.
- class pulumi_policy.PolicyCustomTimeouts(create_seconds: float, update_seconds: float, delete_seconds: float)
Custom timeout options.
- class pulumi_policy.PolicyPack(name: str, policies: List[Policy], enforcement_level: EnforcementLevel | None = None, initial_config: Dict[str, EnforcementLevel | Dict[str, Any]] | None = None)
A policy pack contains one or more policies to enforce.
- Parameters:
name (str) – The name of the policy pack.
policies (List[Policy]) – The policies associated with a policy pack.
enforcement_level (Optional[EnforcementLevel]) – Indicates what to do on policy violation, e.g., block deployment but allow override with proper permissions. This is the default used for all policies in the policy pack. Individual policies can override.
initial_config (Optional[Dict[str, Union['EnforcementLevel', Dict[str, Any]]]]) – Initial configuration for the policy pack. Allows specifying configuration programmatically from reusable policy libraries.
- class pulumi_policy.PolicyProviderResource(resource_type: str, props: Mapping[str, Any], urn: str, name: str)
Information about the provider.
- props: Mapping[str, Any]
The properties of the provider resource.
- class pulumi_policy.PolicyResource(resource_type: str, props: Mapping[str, Any], urn: str, name: str, opts: PolicyResourceOptions, provider: PolicyProviderResource | None, parent: PolicyResource | None, dependencies: List[PolicyResource], property_dependencies: Dict[str, List[PolicyResource]])
PolicyResource represents a resource in the stack.
- props: Mapping[str, Any]
The outputs of the resource.
- opts: PolicyResourceOptions
The options of the resource.
- provider: PolicyProviderResource | None
The provider of the resource.
- parent: PolicyResource | None
An optional parent that this resource belongs to.
- dependencies: List[PolicyResource]
The dependencies of the resource.
- property_dependencies: Dict[str, List[PolicyResource]]
The set of dependencies that affect each property.
- class pulumi_policy.PolicyResourceOptions(protect: bool, ignore_changes: List[str], delete_before_replace: bool | None, aliases: List[str], custom_timeouts: PolicyCustomTimeouts, additional_secret_outputs: List[str])
PolicyResourceOptions is the bag of settings that control a resource’s behavior.
- delete_before_replace: bool | None
When set to true, indicates that this resource should be deleted before its replacement is created when replacement is necessary.
- custom_timeouts: PolicyCustomTimeouts
Custom timeouts for resource create, update, and delete operations.
- class pulumi_policy.ResourceValidationArgs(resource_type: str, props: Mapping[str, Any], urn: str, name: str, opts: PolicyResourceOptions, provider: PolicyProviderResource | None, config: Mapping[str, Any] | None = None)
ResourceValidationArgs is the argument bag passed to a resource validation.
- get_config() Mapping[str, Any]
Returns configuration for the policy.
- props: Mapping[str, Any]
The inputs of the resource.
- opts: PolicyResourceOptions
The options of the resource.
- provider: PolicyProviderResource | None
The provider of the resource.
- class pulumi_policy.ResourceValidationPolicy(name: str, description: str, validate: Callable[[ResourceValidationArgs, Callable[[str, str | None], None]], Awaitable | None] | List[Callable[[ResourceValidationArgs, Callable[[str, str | None], None]], Awaitable | None]] | None = None, enforcement_level: EnforcementLevel | None = None, config_schema: PolicyConfigSchema | None = None)
ResourceValidationPolicy is a policy that validates a resource definition.
- Parameters:
name (str) – An ID for the policy. Must be unique within the current policy set.
description (str) – A brief description of the policy rule. e.g., “S3 buckets should have default encryptionenabled.”
validate (Optional[Union[ResourceValidation, List[ResourceValidation]]]) – A callback function that validates if a resource definition violates a policy (e.g. “S3 buckets can’t be public”). A single callback function can be specified, or multiple functions, which are called in order.
enforcement_level (Optional[EnforcementLevel]) – Indicates what to do on policy violation, e.g., block deployment but allow override with proper permissions.
config_schema (Optional[PolicyConfigSchema]) – This policy’s configuration schema.
- class pulumi_policy.StackValidationArgs(resources: List[PolicyResource], config: Mapping[str, Any] | None = None)
StackValidationArgs is the argument bag passed to a stack validation.
- get_config() Mapping[str, Any]
Returns configuration for the policy.
- resources: List[PolicyResource]
The resources in the stack.
- class pulumi_policy.StackValidationPolicy(name: str, description: str, validate: Callable[[StackValidationArgs, Callable[[str, str | None], None]], Awaitable | None] | None = None, enforcement_level: EnforcementLevel | None = None, config_schema: PolicyConfigSchema | None = None)
StackValidationPolicy is a policy that validates a stack.
- Parameters:
name (str) – An ID for the policy. Must be unique within the current policy set.
description (str) – A brief description of the policy rule. e.g., “S3 buckets should have default encryptionenabled.”
validate (Optional[StackValidation]) – A callback function that validates if a stack violates a policy.
enforcement_level (Optional[EnforcementLevel]) – Indicates what to do on policy violation, e.g., block deployment but allow override with proper permissions.
config_schema (Optional[PolicyConfigSchema]) – This policy’s configuration schema.
Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.