Skip to content

plan -detailed-exitcode -destroy return "2" when nothing to destroy #18224

@evbo

Description

@evbo

To reproduce using Terraform 0.11.7:

define any resource (but don't create it), then run terraform plan -detailed-exitcode -destroy

I would expect the -destroy flag to switch the context, such that -detailed-exitcode reports back what's there to destroy - not create, but it returns a 2.

Returning codes that indicate what's there to destroy (rather than create) allows my jenkins pipeline to know if it was successful at planing a destroy. Based on the current error codes, if it gets back a "2", then it thinks there's something to destroy (when there isn't). Conversely, if there were no changes (to create), this incorrectly indicates that there's nothing to destroy when there definitely can be.

It's important to plan a destroy, so I don't want to skip that step, but I will for now work around this by ignoring the return code unless it's a 1 indicating error. Would be nice though if exit codes were context-specific in terms of either creation or destruction. BTW thanks for the great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions