Skip to content

Check if workspace exists before terraform destroy in destroy-workspace #368

Open
@DCamma

Description

@DCamma

Suggestion

Use-case

My use case is the following:

  • our feature branches are deployed whenever we open a PR and use the dflook tf-apply action selecting a workspace to differentiate from the main environment, deploying the testing infrastructure.
  • feature branch PRs can remain open for a while but infrastructure might be destroyed by auto-cleanup jobs to reduce costs and are re-created when a new commit is pushed.
  • On PR close we use the dflook destroy-workspace action, but the infra (and the workspace) might already be gone. Hence the dflook action fails not finding the workspace when attempting the destroy.

Proposal:

I would be interested in understanding if it is within the project scope to check if a workspace exists before running the terraform destroy and if the workspace doesn't exist simply terminate successfully the destroy-workspace job.

We implemented the check on our side, but I thought of proposing to handle this use case if others need it as well. Additionally there could be a flag: check-if-workspace-exists or fail-if-workspace-doesn't-exist with defaults that retain the current functionalities.

I would be happy to open a PR exploring this concept.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions