kubernetes/kops · error
pass in the cloud provider explicitly using --cloud: %w
Error message
pass in the cloud provider explicitly using --cloud: %w
What it means
When --cloud is not specified, NewCluster tries clouds.GuessCloudForPath on the state-store path to infer the provider. If inference fails (path not recognizable as belonging to a cloud), it wraps the error with advice to pass --cloud explicitly.
Source
Thrown at upup/pkg/fi/cloudup/new_cluster.go:330
}
cluster.Spec.API.Access = opt.AdminAccess
if len(opt.SSHAccess) != 0 {
cluster.Spec.SSHAccess = opt.SSHAccess
} else {
cluster.Spec.SSHAccess = opt.AdminAccess
}
if len(opt.Zones) == 0 {
return nil, fmt.Errorf("must specify at least one zone for the cluster (use --zones)")
}
allZones := sets.NewString()
allZones.Insert(opt.Zones...)
allZones.Insert(opt.ControlPlaneZones...)
if opt.CloudProvider == "" {
cloud, err := clouds.GuessCloudForPath(cluster.Spec.ConfigStore.Base)
if err != nil {
return nil, fmt.Errorf("pass in the cloud provider explicitly using --cloud: %w", err)
}
klog.V(2).Infof("Inferred %q cloud provider from state store %q", cloud, cluster.Spec.ConfigStore.Base)
opt.CloudProvider = string(cloud)
}
var cloud fi.Cloud
switch api.CloudProviderID(opt.CloudProvider) {
case api.CloudProviderAWS:
cluster.Spec.CloudProvider.AWS = &api.AWSSpec{}
cloudTags := map[string]string{}
awsCloud, err := awsup.NewAWSCloud(opt.Zones[0][:len(opt.Zones[0])-1], cloudTags)
if err != nil {
return nil, err
}
cloud = awsCloud
case api.CloudProviderAzure:
cluster.Spec.CloudProvider.Azure = &api.AzureSpec{View on GitHub (pinned to 4c8573c808)
Solutions
- Pass --cloud explicitly, e.g. --cloud aws (or gce, do, hetzner, openstack, azure, scaleway, linode, metal)
- Set opt.CloudProvider in NewClusterOptions
- Fix the state-store path/credentials so GuessCloudForPath can infer the provider
Example fix
// before kops create cluster --name c.example.com --zones us-east-1a --state vfs:///tmp/state // after kops create cluster --name c.example.com --cloud aws --zones us-east-1a --state vfs:///tmp/state
Defensive patterns
Strategy: validation
Validate before calling
if opt.CloudProvider == "" {
return fmt.Errorf("--cloud is required when the state store path cannot be inferred")
} Try / catch
_, err := NewCluster(opt, cs)
if err != nil && strings.Contains(err.Error(), "pass in the cloud provider explicitly") {
// set opt.CloudProvider and retry
} Prevention
- Always pass --cloud explicitly in scripts
- Use a cloud-specific state store (s3:// for AWS) so inference works
- Fix state-store credentials so GuessCloudForPath can read the path
When it happens
Trigger: `kops create cluster` without --cloud and with a --state path (e.g. a generic vfs path, file:// store, or inaccessible S3 path) from which no cloud provider can be guessed.
Common situations: Using a file/memfs state store in tests; S3 state store where credentials prevent reading the path; users migrating configs to a neutral storage backend.
Related errors
- cannot infer cloud provider from path: %q
- cloud provider %v does not support the terraform target
- DNS not implemented on azureCloud
- Error too many '=' (%d) in %s
- at least one channel URL is required
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/4ca0b9ad6e148168.
Report an issue: GitHub.