hashicorp / hashicorp/terraform-plugin-sdk

External providers are not loaded automatically in acceptance tests

Open
#562 0 comments 3 reactions 0 assignees View on GitHub
bug subsystem/tests
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

### SDK version

```json
{
"Path": "github.com/hashicorp/terraform-plugin-sdk/v2",
"Version": "v2.0.1"
}
```

### Terraform Configuration Files

```terraform
resource "aws_guardduty_filter" "test" {
detector_id = "${aws_guardduty_detector.test.id}"
name = "test-filter"
action = "ARCHIVE"
rank = 1

finding_criteria {
criterion {
field = "region"
equals = ["eu-west-1"]
}

criterion {
field = "service.additionalInfo.threatListName"
not_equals = ["some-threat", "another-threat"]
}

criterion {
field = "updatedAt"
greater_than = time_static.start_time.unix*1000
less_than = 1570744740000
}
}
}

resource "aws_guardduty_detector" "test" {
enable = true
}

resource "time_static" "start_time" {
rfc3339 = "2020-01-01T00:00:00Z"
}
```

### Expected Behavior

The `time` provider should have been loaded.

The [`ExternalProviders ` field documentation](https://github.com/hashicorp/terraform-plugin-sdk/blob/d396282344328e3fe869c3ffaae0ac3ee22cdcfd/helper/resource/testing.go#L304-310) states
```go
// ExternalProviders [are] only really
// necessary to set if you're using import, as providers in your config
// will be automatically retrieved during init.
```

### Actual Behavior

The `time` provider is not loaded and the acceptance test fails with

```console
TestAccAWSGuardDuty_serial/Filter/basic: resource_aws_guardduty_filter_test.go:20: Step 1/3 error: terraform failed: exit status 1

stderr:

Error: Could not load plugin


Plugin reinitialization required. Please run "terraform init".

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".

Failed to instantiate provider "registry.terraform.io/hashicorp/time" to
obtain schema: unknown provider "registry.terraform.io/hashicorp/time"
```

When the `ExternalProviders` field is explicitly set, it works.

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.