pulumi_policy
The Pulumi Policy SDK for Python.
- class pulumi_policy.EnforcementLevel(value, names=<not given>, *values, 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.
- config_schema: PolicyConfigSchema | None
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.
- name: str
An ID for the policy. Must be unique within the current policy set.
- 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.
- required: List[str] | None
The configuration properties that are required.
- class pulumi_policy.PolicyCustomTimeouts(create_seconds: float, update_seconds: float, delete_seconds: float)
Custom timeout options.
- create_seconds: float
The create resource timeout.
- delete_seconds: float
The delete resource timeout.
- update_seconds: float
The update resource timeout.
- 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.
- name: str
The name of the provider resource.
- props: Mapping[str, Any]
The properties of the provider resource.
- resource_type: str
The type of the provider resource.
- urn: str
The URN 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.
- dependencies: List[PolicyResource]
The dependencies of the resource.
- name: str
The name of the resource.
- opts: PolicyResourceOptions
The options of the resource.
- parent: PolicyResource | None
An optional parent that this resource belongs to.
- property_dependencies: Dict[str, List[PolicyResource]]
The set of dependencies that affect each property.
- props: Mapping[str, Any]
The outputs of the resource.
- provider: PolicyProviderResource | None
The provider of the resource.
- resource_type: str
The type of the resource.
- urn: str
The URN of the resource.
- 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], parent: str | None = None)
PolicyResourceOptions is the bag of settings that control a resource’s behavior.
- additional_secret_outputs: List[str]
Outputs that should always be treated as secrets.
- aliases: List[str]
Additional URNs that should be aliased to this resource.
- custom_timeouts: PolicyCustomTimeouts
Custom timeouts for resource create, update, and delete operations.
- 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.
- ignore_changes: List[str]
Ignore changes to any of the specified properties.
- parent: str | None
An optional parent that this resource belongs to.
- protect: bool
When set to true, protect ensures this resource cannot be deleted.
- 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.
- name: str
The name of the resource.
- opts: PolicyResourceOptions
The options of the resource.
- props: Mapping[str, Any]
The inputs of the resource.
- provider: PolicyProviderResource | None
The provider of the resource.
- resource_type: str
The type of the resource.
- urn: str
The URN 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, remediate: Callable[[ResourceValidationArgs], Awaitable[Mapping[str, Any]] | None] | None = None, validate_remediate: Callable[[ResourceValidationArgs, Callable[[str, str | None], None]], Awaitable[Mapping[str, Any]] | None] | 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.
remediate (Optional[ResourceRemediation]) – A callback function that is given an opportunity to rewrite resource state in the event of a policy issue (e.g., “Auto-tag S3 buckets”).
validate_remediate (Optional[ResourceRemediation]) – A callback function that can act as both a policy validation as well as a remediation.
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.Secret(value: Any)
Secret allows values to be marked as sensitive, such that the Pulumi engine will encrypt them as normal with Pulumi secrets upon seeing one returned from a remediation.
- Parameters:
value (Any) – The plaintext value to turn into a secret.
- 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.