hashicorp / hashicorp/terraform-plugin-testing

Add `--invoke` flag to CLI options for config mode testing of actions

Open
#580 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
68
Forks
22
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### terraform-plugin-testing version
```
github.com/hashicorp/terraform-plugin-testing v1.13.3
```

### Use cases

Currently, to test an action with `Config` mode, you can only do so with the `lifecycle.action_trigger` field. If there isn't a natural choice for a managed resource to add this to, you can use a `terraform_data` managed resource as a workaround (which is a null resource that does nothing but take up space in the graph 😆 ):
- https://developer.hashicorp.com/terraform/language/invoke-actions#trigger-an-action-when-applying-a-configuration
- `local_command` action using this pattern

### Proposal

We should consider adding the CLI flag pass-throughs for invoking an action directly, to provide a more direct test:
- https://developer.hashicorp.com/terraform/language/invoke-actions#invoke-an-action-from-the-cli
- https://github.com/hashicorp/terraform-plugin-testing/blob/main/helper/resource/additional_cli_options.go

We already have a place to put CLI options in `terraform-plugin-testing`, but we'll need to update `terraform-exec` to accept the flag (if it hasn't been updated already):
- https://github.com/hashicorp/terraform-exec

### References
- https://github.com/hashicorp/terraform-plugin-testing/issues/557

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.