{"record":{"id":"f7e1b5d5d411a47f","repo":"hashicorp/nomad","slug":"failed-to-setup-imds-client-v","errorCode":null,"errorMessage":"failed to setup IMDS client: %v","messagePattern":"failed to setup IMDS client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/fingerprint/env_aws.go","lineNumber":94,"sourceCode":"\t)\n}\n\nfunc (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *FingerprintResponse) error {\n\tcfg := request.Config\n\n\ttimeout := AwsMetadataTimeout\n\n\t// Check if we should tighten the timeout\n\tif cfg.ReadBoolDefault(TightenNetworkTimeoutsConfig, false) {\n\t\ttimeout = 1 * time.Millisecond\n\t}\n\n\tctx, cancel := context.WithTimeout(context.TODO(), timeout)\n\tdefer cancel()\n\n\timdsClient, err := f.imdsClient(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to setup IMDS client: %v\", err)\n\t}\n\n\tif err := awsProbe(ctx, imdsClient); err != nil {\n\t\treturn wrapProbeError(err)\n\t}\n\n\t// Keys and whether they should be namespaced as unique. Any key whose value\n\t// uniquely identifies a node, such as ip, should be marked as unique. When\n\t// marked as unique, the key isn't included in the computed node class.\n\tkeys := map[string]bool{\n\t\t\"ami-id\":                      false,\n\t\t\"hostname\":                    true,\n\t\t\"instance-id\":                 true,\n\t\t\"instance-life-cycle\":         false,\n\t\t\"instance-type\":               false,\n\t\t\"local-hostname\":              true,\n\t\t\"local-ipv4\":                  true,\n\t\t\"public-hostname\":             true,","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/fingerprint/env_aws.go#L76-L112","documentation":"The AWS fingerprinter creates an EC2 IMDS (Instance Metadata Service) client before probing. f.imdsClient(ctx) builds the AWS SDK IMDS client (resolving region/endpoint config); if construction or configuration fails, the fingerprint returns this wrapped error and AWS attributes are not detected.","triggerScenarios":"Failure constructing the imds.Client — invalid AWS_* environment configuration interfering, endpoint resolution error, or context deadline exceeded while setting up the client.","commonSituations":"Non-EC2 environment with AWS env vars set that break IMDS defaults; IMDS endpoint unreachable within timeout (firewall, IMDSv2-only hop limit); misconfigured AWS_EC2_METADATA_SERVICE_ENDPOINT.","solutions":["Verify the instance can reach 169.254.169.254 (curl from the host)","Check AWS_EC2_METADATA_SERVICE_ENDPOINT for typos","Increase the fingerprint timeout if IMDSv2 token acquisition is slow","Clear stray AWS_* env vars leaking into the Nomad agent process","Confirm IMDS hop limit >=1 (or 2 for containers) when IMDSv2 is enforced"],"exampleFix":"// before\nexport AWS_EC2_METADATA_SERVICE_ENDPOINT=\"http://169.254.169.254:80\" // wrong port blocks client setup\n// after\nunset AWS_EC2_METADATA_SERVICE_ENDPOINT  # let SDK use default","handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(\"http://169.254.169.254/latest/meta-data/\", )\n// pre-check reachability before fingerprinting\nif err != nil { log.Println(\"IMDS unreachable; skipping aws fingerprint\") }","typeGuard":"func imdsReachable(ctx context.Context) bool { req, _ := http.NewRequestWithContext(ctx, http.MethodPut, \"http://169.254.169.254/latest/api/token\", nil); _, err := http.DefaultClient.Do(req); return err == nil }","tryCatchPattern":"imdsClient, err := f.imdsClient(ctx)\nif err != nil {\n    var rerr *retry.Error\n    if errors.As(err, &rerr) { /* handle retry/timeout */ }\n    return fmt.Errorf(\"failed to setup IMDS client: %w\", err)\n}","preventionTips":["Pre-flight check IMDS reachability before enabling the aws fingerprint","Unset stray AWS_* env vars in the agent's environment","Keep IMDS hop limit >=2 when token requests pass through a bridge"],"tags":["aws","imds","cloud-metadata"],"backgroundTag":"imds-client-setup-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}