Closed
Description
Ever since the terraform-plugin-testing@v1.6.0
update a number of Terraform AWS Provider ImportStateVerify
state verify test steps that previously passed have been failing.
For example:
=== RUN TestAccAppMesh_serial/Route/grpcRouteEmptyMatch
route_test.go:568: Step 2/2 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import.
map[string]string{
+ "spec.0.grpc_route.0.action.0.weighted_target.0.port": "0",
}
The pattern I have observed is that these tests cases are all to do with values of attributes inside nested TypeSet
s that are themselves nested in other configuration blocks. The affected resource all use Terraform Plugin SDK v2.
For the example above (internal/service/appmesh/route.go
):
"grpc_route": {
Type: schema.TypeList,
Optional: true,
MinItems: 0,
MaxItems: 1,
ConflictsWith: []string{"spec.0.http2_route", "spec.0.http_route", "spec.0.tcp_route"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"action": {
Type: schema.TypeList,
Required: true,
MinItems: 1,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"weighted_target": {
Type: schema.TypeSet,
Required: true,
MinItems: 1,
MaxItems: 10,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IsPortNumber,
},
Acceptance test case (testAccRoute_grpcRouteEmptyMatch
) configuration (internal/service/appmesh/route_test.go
):
resource "aws_appmesh_route" "test" {
name = "test"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name
spec {
grpc_route {
match {}
action {
weighted_target {
virtual_node = aws_appmesh_virtual_node.test1.name
weight = 100
}
}
}
}
}
terraform-plugin-testing version
% go list -m github.com/hashicorp/terraform-plugin-testing/...
github.com/hashicorp/terraform-plugin-testing v1.6.0
References
Relates hashicorp/terraform-provider-aws#35054.
Relates hashicorp/terraform-provider-aws#35108.