hashicorp/terraform · error

invalid provider type

Error message

invalid provider type %q in provider matching pattern %q: must either be the wildcard * or a provider type name

What it means

Thrown when the provider-type segment (parts[1], i.e. the final segment after an optional host is stripped) is neither '*' nor accepted by addrs.ParseProviderPart. ParseProviderPart requires a lowercase name: ASCII letters and digits with internal hyphens, not starting or ending with a hyphen, not starting with a digit, and within length limits. Uppercase, underscores, dots, or a leading digit/trailing hyphen all fail.

Solutions

  1. Lowercase the type segment and use only letters, digits, and internal hyphens (e.g. 'hashicorp/aws').
  2. Replace underscores/dots in the type with hyphens.
  3. If you want any type, use '*' as the final segment.
  4. Confirm the segment is the type, not the namespace — order is host?/namespace/type.

Example fix

// before
include = ["hashicorp/AWS_EKS"]

// after
include = ["hashicorp/aws-eks"]
Defensive patterns

Strategy: validation

Validate before calling

import "github.com/hashicorp/terraform/internal/addrs"

func validTypeSegment(t string) error {
    if t == "*" {
        return nil
    }
    return addrs.ParseProviderPart(t) // same rule the parser applies
}

Prevention

When it happens

Trigger: Patterns like 'hashicorp/AWS' (uppercase), 'hashicorp/aws_eks' (underscore), 'hashicorp/terraform-provider' is fine but 'hashicorp/-aws' (leading hyphen), 'hashicorp/aws.v2' (dot), or 'hashicorp/2aws' (leading digit). Triggered at multi_source.go:172-174 via normalizeProviderNameOrWildcard -> addrs.ParseProviderPart.

Common situations: Pasting a provider type with the display casing (e.g. from docs showing 'AWS'); using underscores thinking they are allowed like in other ecosystems; adding a version suffix with a dot; a trailing hyphen from truncation.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/ebee7a8b70e48768. Report an issue: GitHub.

Appendix: source

Thrown at internal/getproviders/multi_source.go:174

			givenHost := parts[0]
			if givenHost == "*" {
				host = svchost.Hostname(Wildcard)
			} else {
				normalHost, err := svchost.ForComparison(givenHost)
				if err != nil {
					return nil, fmt.Errorf("invalid hostname in provider matching pattern %q: %s", str, err)
				}

				// The remaining code below deals only with the namespace/type portions.
				host = normalHost
			}

			parts = parts[1:]
		}

		pType, err := normalizeProviderNameOrWildcard(parts[1])
		if err != nil {
			return nil, fmt.Errorf("invalid provider type %q in provider matching pattern %q: must either be the wildcard * or a provider type name", parts[1], str)
		}
		namespace, err := normalizeProviderNamespaceOrWildcard(parts[0])
		if err != nil {
			return nil, fmt.Errorf("invalid registry namespace %q in provider matching pattern %q: must either be the wildcard * or a literal namespace", parts[1], str)
		}

		ret[i] = addrs.Provider{
			Hostname:  host,
			Namespace: namespace,
			Type:      pType,
		}

		if ret[i].Hostname == svchost.Hostname(Wildcard) && !(ret[i].Namespace == Wildcard && ret[i].Type == Wildcard) {
			return nil, fmt.Errorf("invalid provider matching pattern %q: hostname can be a wildcard only if both namespace and provider type are also wildcards", str)
		}
		if ret[i].Namespace == Wildcard && ret[i].Type != Wildcard {
			return nil, fmt.Errorf("invalid provider matching pattern %q: namespace can be a wildcard only if the provider type is also a wildcard", str)
		}

View on GitHub (pinned to d32a084675)