{"record":{"id":"69480c66c65710a1","repo":"kubernetes/kops","slug":"failed-to-load-default-aws-config-w","errorCode":null,"errorMessage":"failed to load default aws config: %w","messagePattern":"failed to load default aws config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dnsprovider/pkg/dnsprovider/providers/aws/route53/route53.go","lineNumber":109,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load default aws config for STS client: %w\", err)\n\t\t}\n\n\t\tawsOptions = append(\n\t\t\tawsOptions,\n\t\t\tawsconfig.WithEC2IMDSRegion(func(o *awsconfig.UseEC2IMDSRegion) {\n\t\t\t\to.Client = imdsClient\n\t\t\t}),\n\t\t\tawsconfig.WithAssumeRoleCredentialOptions(func(aro *stscreds.AssumeRoleOptions) {\n\t\t\t\t// Ensure the STS client has a region configured, if discovered by IMDS\n\t\t\t\taro.Client = sts.NewFromConfig(stsCfg)\n\t\t\t}),\n\t\t)\n\t}\n\n\tcfg, err := awsconfig.LoadDefaultConfig(ctx, awsOptions...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load default aws config: %w\", err)\n\t}\n\n\t// AWS_REGION, IMDS, or config profiles can override this in LoadDefaultConfig above.\n\tif cfg.Region == \"\" {\n\t\tcfg.Region = \"us-east-1\"\n\t}\n\n\tsvc := route53.NewFromConfig(cfg)\n\n\treturn New(svc), nil\n}\n","sourceCodeStart":91,"sourceCodeEnd":121,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/dnsprovider/pkg/dnsprovider/providers/aws/route53/route53.go#L91-L121","documentation":"This is the final LoadDefaultConfig call in newRoute53 that produces the config used for the actual Route53 client. Any failure assembling the SDK config (credentials chain, region resolution, profiles, IMDS options) is wrapped here.","triggerScenarios":"newRoute53's main LoadDefaultConfig(ctx, awsOptions...) fails — typically because no credentials could be resolved by the default chain (env, profile, IMDS) or an option (WithEC2IMDSRegion using the custom imdsClient) errors.","commonSituations":"Running outside AWS with no ~/.aws credentials and no env vars; expired credentials in a profile; EC2 instance profile missing/IMDS unreachable (IMDSv2 hops limit); missing route53:GetHostedZones-style permission is NOT this error — this one is purely config assembly.","solutions":["Provide credentials: export AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY (and AWS_REGION) or configure a valid profile.","If on EC2, verify the instance has an instance profile and IMDSv2 is reachable (hops limit >= 1).","Check the wrapped error to identify which chain element failed (credential provider vs profile parse).","Set AWS_REGION explicitly to skip IMDS region resolution."],"exampleFix":"// before\n// no credentials configured\n// after\nexport AWS_ACCESS_KEY_ID=...\nexport AWS_SECRET_ACCESS_KEY=...\nexport AWS_REGION=us-east-1","handlingStrategy":"validation","validationCode":"// ensure the credential chain can resolve before calling the library\nif os.Getenv(\"AWS_ACCESS_KEY_ID\") == \"\" && os.Getenv(\"AWS_PROFILE\") == \"\" {\n    if _, err := os.Stat(filepath.Join(os.Getenv(\"HOME\"), \".aws\", \"credentials\")); err != nil {\n        return errors.New(\"no AWS credentials available: set env vars or a profile\")\n    }\n}","typeGuard":null,"tryCatchPattern":"var cfgErr *aws.ConfigLoadError // or inspect wrapped chain\nzone, err := dnsprovider.InitDnsProvider(\"aws-route53\", ...)\nif err != nil && strings.Contains(err.Error(), \"failed to load default aws config\") {\n    return fmt.Errorf(\"no AWS credentials/region resolvable: %w\", err)\n}","preventionTips":["Always export AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or a valid AWS_PROFILE.","Set AWS_REGION explicitly to avoid IMDS dependency.","On EC2, attach an instance profile and keep IMDSv2 reachable."],"tags":["aws","route53","credentials"],"backgroundTag":"aws-credentials-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}