{"record":{"id":"9d68d3f87291dd8c","repo":"kubernetes/kops","slug":"error-querying-ec2-metadata-service-for-region-9d68d3","errorCode":null,"errorMessage":"error querying ec2 metadata service (for region): %v","messagePattern":"error querying ec2 metadata service \\(for region\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodeidentity/aws/identify.go","lineNumber":71,"sourceCode":"\n\t// cache is a cache of nodeidentity.Info\n\tcache expirationcache.Store\n\t// cacheEnabled indicates if caching should be used\n\tcacheEnabled bool\n}\n\n// New creates and returns a nodeidentity.Identifier for Nodes running on AWS\nfunc New(ctx context.Context, cacheNodeidentityInfo bool) (nodeidentity.Identifier, error) {\n\tconfig, err := awsconfig.LoadDefaultConfig(ctx, awslog.WithAWSLogger())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error loading AWS config: %v\", err)\n\t}\n\n\timdsClient := imds.NewFromConfig(config)\n\n\tregionResp, err := imdsClient.GetRegion(ctx, &imds.GetRegionInput{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error querying ec2 metadata service (for region): %v\", err)\n\t}\n\n\tconfig.Region = regionResp.Region\n\tec2Client := ec2.NewFromConfig(config)\n\n\treturn &nodeIdentifier{\n\t\tec2Client:    ec2Client,\n\t\tcache:        expirationcache.NewTTLStore(stringKeyFunc, cacheTTL),\n\t\tcacheEnabled: cacheNodeidentityInfo,\n\t}, nil\n}\n\n// stringKeyFunc is a string as cache key function\nfunc stringKeyFunc(obj interface{}) (string, error) {\n\tkey := obj.(*nodeidentity.Info).InstanceID\n\treturn key, nil\n}\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodeidentity/aws/identify.go#L53-L89","documentation":"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.","triggerScenarios":"Thrown at pkg/nodeidentity/aws/identify.go:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure IMDS is reachable from the node (hop limit, no blocked 169.254.169.254)","Retry node registration; kubelet/nodeup will re-attempt identification","Check for restrictive DHCP/network ACL settings blocking link-local metadata"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}