Skip to content

PlanResult

Represents the result of a plan operation.

PlanResult provides methods to analyze the planned infrastructure changes before actually applying them.

Example

from infraweave import Deployment, S3Bucket

bucket_module = S3Bucket(version='0.0.11-dev', track="dev")
bucket1 = Deployment(name="bucket1", namespace="playground", module=bucket_module, region="us-west-2")

bucket1.set_variables(bucket_name="my-bucket12347ydfs3", enable_acl=False)
plan_result = bucket1.plan()
print(f"Job ID: {plan_result.job_id}")
print(f"Plan output: {plan_result.get_output()}")

if plan_result.has_destructive_changes():
    print("Warning: This plan will destroy or replace resources!")
    destructive = plan_result.get_destructive_changes()
    for address, action in destructive:
        print(f"  - {action}: {address}")
    # Decide whether to proceed with apply

Properties

deployment_id

environment_id

job_id

region

Methods

__new__(args, kwargs)

Create and return a new object. See help(type) for accurate signature.

get_destructive_changes()

Gets detailed information about resources that will be destroyed or replaced.

Returns a list of tuples containing (resource_address, action) for each resource that will be deleted or replaced in the plan.

Returns

list[tuple[str, str]]: A list of tuples where each tuple contains: - resource_address (str): The Terraform resource address (e.g., "aws_s3_bucket.example") - action (str): Either "delete" or "replace"

Example

plan_result = deployment.plan()
destructive = plan_result.get_destructive_changes()
for address, action in destructive:
    print(f"{action}: {address}")
# Output might be:
# delete: aws_s3_bucket.old
# replace: aws_instance.web

get_output()

Gets the plan output from Terraform.

Returns the full text output from the terraform plan command, which includes details about what changes will be made.

Returns

str: The plan output text.

Example

plan_result = deployment.plan()
output = plan_result.get_output()
print(output)

has_destructive_changes()

Checks if the plan contains any destructive changes.

Returns True if the plan will delete or replace (recreate) any resources, False otherwise.

Returns

bool: True if destructive changes are present, False otherwise.

Example

plan_result = deployment.plan()
if plan_result.has_destructive_changes():
    print("Warning: This plan contains destructive changes!")