hashicorp / hashicorp/terraform-plugin-sdk
Can't use datasource in an ExpectError test
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
### Terraform Version
```
0.12.7 (SDK)
```
### Terraform Configuration Files
```hcl
data "google_compute_image" "my_image" {
family = "centos-7"
project = "gce-uefi-images"
}
resource "google_compute_instance_template" "foobar" {
name = "instancet-test-%s"
machine_type = "n1-standard-1"
can_ip_forward = false
disk {
source_image = "${data.google_compute_image.my_image.self_link}"
auto_delete = true
boot = true
}
disk {
source_image = "${data.google_compute_image.my_image.self_link}"
auto_delete = true
type = "SCRATCH"
disk_type = "local-ssd"
}
disk {
source_image = "${data.google_compute_image.my_image.self_link}"
auto_delete = true
type = "SCRATCH"
}
network_interface {
network = "default"
}
}
```
### Debug Output
https://gist.github.com/rileykarson/c1024b54a0ebff4166f13f34133c3a63
### Crash Output
N/A
### Expected Behavior
The test case should pass.
### Actual Behavior
```
--- FAIL: TestAccComputeInstanceTemplate_invalidDiskType (1.13s)
testing.go:630: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during refresh: 1 error occurred:
* SCRATCH disks must have a disk_type of local-ssd
State:
```
### Steps to Reproduce
`TF_LOG=DEBUG make testacc TEST=./google TESTARGS='-run=TestAccComputeInstanceTemplate_invalidDiskType'`
Using a hardcoded value instead of a datasource, I don't encounter the error and the test passes.
### Additional Context
This test isn't merged yet, but is staged at https://github.com/GoogleCloudPlatform/magic-modules/pull/2282
### References
Possible related to https://github.com/hashicorp/terraform/issues/18948
Contributor guide
Assessment
This issue has not been assessed yet.