kubernetes/kops · error

error querying ec2 metadata service (for region): %v

Error message

error querying ec2 metadata service (for region): %v

What it means

The EC2 instance-metadata (IMDS) query for the region failed during node-identity setup on the node. IMDS calls can be transient (startup races, proxy/IMDSv2 restrictions), so this often resolves on retry once metadata service is reachable.

Source

Thrown at pkg/nodeidentity/aws/identify.go:71

	// cache is a cache of nodeidentity.Info
	cache expirationcache.Store
	// cacheEnabled indicates if caching should be used
	cacheEnabled bool
}

// New creates and returns a nodeidentity.Identifier for Nodes running on AWS
func New(ctx context.Context, cacheNodeidentityInfo bool) (nodeidentity.Identifier, error) {
	config, err := awsconfig.LoadDefaultConfig(ctx, awslog.WithAWSLogger())
	if err != nil {
		return nil, fmt.Errorf("error loading AWS config: %v", err)
	}

	imdsClient := imds.NewFromConfig(config)

	regionResp, err := imdsClient.GetRegion(ctx, &imds.GetRegionInput{})
	if err != nil {
		return nil, fmt.Errorf("error querying ec2 metadata service (for region): %v", err)
	}

	config.Region = regionResp.Region
	ec2Client := ec2.NewFromConfig(config)

	return &nodeIdentifier{
		ec2Client:    ec2Client,
		cache:        expirationcache.NewTTLStore(stringKeyFunc, cacheTTL),
		cacheEnabled: cacheNodeidentityInfo,
	}, nil
}

// stringKeyFunc is a string as cache key function
func stringKeyFunc(obj interface{}) (string, error) {
	key := obj.(*nodeidentity.Info).InstanceID
	return key, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure IMDS is reachable from the node (hop limit, no blocked 169.254.169.254)
  2. Retry node registration; kubelet/nodeup will re-attempt identification
  3. Check for restrictive DHCP/network ACL settings blocking link-local metadata
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/nodeidentity/aws/identify.go:71 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/9d68d3f87291dd8c. Report an issue: GitHub.