kubernetes/kops · error

failed to load default aws config: %w

Error message

failed to load default aws config: %w

What it means

loadAWSConfig calls awsconfig.LoadDefaultConfig with the computed region, retry and assume-role options (KOPS_AWS_ROLE_ARN); it failed, e.g. invalid region/role environment variables or no resolvable credentials/config sources.

Source

Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:295

	loadOptions := []func(*awsconfig.LoadOptions) error{
		awsconfig.WithRegion(region),
		awsconfig.WithClientLogMode(aws.LogRetries),
		awsconfig.WithLogger(awsLogger{}),
		awsconfig.WithRetryer(func() aws.Retryer {
			return retry.NewAdaptiveMode(func(ao *retry.AdaptiveModeOptions) {
				ao.StandardOptions = append(ao.StandardOptions, func(so *retry.StandardOptions) {
					so.MaxAttempts = ClientMaxRetries
				})
			})
		}),
	}

	// assumes the role before executing commands
	roleARN := os.Getenv("KOPS_AWS_ROLE_ARN")
	if roleARN != "" {
		cfg, err := awsconfig.LoadDefaultConfig(ctx, loadOptions...)
		if err != nil {
			return aws.Config{}, fmt.Errorf("failed to load default aws config: %w", err)
		}
		stsClient := sts.NewFromConfig(cfg)
		assumeRoleProvider := stscredsv2.NewAssumeRoleProvider(stsClient, roleARN)

		loadOptions = append(loadOptions, awsconfig.WithCredentialsProvider(assumeRoleProvider))
	}

	return awsconfig.LoadDefaultConfig(ctx, loadOptions...)
}

func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error) {
	ctx := context.TODO()
	raw := getCloudInstancesFromRegion(region)

	if raw == nil {
		c := &awsCloudImplementation{
			region: region,
			instanceTypes: &instanceTypes{

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify AWS_REGION/AWS_DEFAULT_REGION and KOPS_AWS_ROLE_ARN are set to valid values
  2. Check that credentials resolve via the default chain (env vars, shared config, instance profile)
  3. Run `aws sts get-caller-identity` to confirm the chain works outside kOps
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:295 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/1e95f7126cae36c0. Report an issue: GitHub.