terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Manual step resource

Open czmirek opened this issue 1 year ago • 0 comments

Terraform Version

1.3.3

Use Cases

Make manual steps needed to setup a particular project before and after running terraform apply to be an integral part of the terraform project for purely bookkeeping purposes in a workspace scope.

Terraform code then becomes a complete documentation for both automatically compiled resources handled by terraform and manual steps that are needed to perform any manual steps before and after terraform completes a state update.

Once a manual step is confirmed by the user, it does not need to be confirmed again.

Attempted Solutions

You have a documentation file in your terraform project named something like MANUAL-SETUP.md where you describe every manual step that needs to be done before and after running terraform apply for the first time (after creating a new workspace for a new environment).

Proposal

Create a new type of resource, something like manual resource "name"

manual resource "create_auth0_tenant" {
    type = "before apply"
    require = "Please create the Auth0 tenant first."
}
manual resource "post_apply_add_env_to_confluence" {
    type = "after apply"
    require = "Please add env to the company's Confluence environment table."
}

When you run terraform apply, terraform first asks for confirmation of all manual steps with type = "before apply". These steps are required before terraform apply is run.

terraform apply
> Manual step before apply required: Please create the Auth0 tenant first.
> Type "Done" to confirm.
No
> Error: Manual steps before apply must be all confirmed.

terraform apply
> Manual step before apply required: Please create the Auth0 tenant first.
> Type "Done" to confirm.
Done
> Manual step saved.

Preparing the remote plan...
...

After apply is done, terraform checks any manual resources with type = "after apply". The user is always asked to perform these operations until the step is confirmed to be "Done".

...
Apply finished: 12 added, 0 changed, 0 destroyed

> Manual step after apply required: Please add env to the company's Confluence env table.
> Type "Done" to confirm
Done
> Manual step saved

Once you confirm step with "Done" terraform will not ask you again about that step.

References

Couldn't find anything similar to this.

czmirek avatar Oct 21 '22 18:10 czmirek