kubernetes/kops · error
--region is required (when --external)
Error message
--region is required (when --external)
What it means
When deleting a cluster with --external (cluster not managed in the kOps state store / config not available), kOps discovers resources directly in AWS, which requires a region. If options.Region is empty it returns this error before any API call.
Source
Thrown at cmd/kops/delete_cluster.go:118
cmd.Flags().DurationVar(&options.interval, "interval", options.interval, "Time in duration to wait between deletion attempts")
return cmd
}
func RunDeleteCluster(ctx context.Context, f *util.Factory, out io.Writer, options *DeleteClusterOptions) error {
clusterName := options.ClusterName
if clusterName == "" {
return fmt.Errorf("--name is required (for safety)")
}
var cloud fi.Cloud
var cluster *kopsapi.Cluster
var err error
if options.External {
region := options.Region
if region == "" {
return fmt.Errorf("--region is required (when --external)")
}
tags := map[string]string{"KubernetesCluster": clusterName}
cloud, err = awsup.NewAWSCloud(region, tags)
if err != nil {
return fmt.Errorf("error initializing AWS client: %v", err)
}
} else {
cluster, err = GetCluster(ctx, f, clusterName)
if err != nil {
return err
}
}
wouldDeleteCloudResources := false
if !options.Unregister {
if cloud == nil {View on GitHub (pinned to 4c8573c808)
Solutions
- Pass `--region <aws-region>` together with `--external`.
- Set the KOPS_REGION environment variable.
- If the cluster is actually in the state store, drop --external so region is derived from the cluster spec.
Example fix
// before kops delete cluster --external --name cluster.example.com // after kops delete cluster --external --name cluster.example.com --region us-east-1
Defensive patterns
Strategy: validation
Validate before calling
if external {
region := os.Getenv("KOPS_REGION")
if region == "" {
return fmt.Errorf("--external requires --region")
}
args = append(args, "--region", region)
} Prevention
- Pair --external with --region every time.
- Set KOPS_REGION in the environment for AWS workflows.
- Prefer state-store deletion (omit --external) when the cluster is kOps-managed.
When it happens
Trigger: Running `kops delete cluster --external` without also passing `--region` (and no KOPS_REGION env var), so the AWS cloud client cannot be constructed.
Common situations: Cleaning up a cluster whose state store was lost; deleting clusters created outside kOps where the region cannot be inferred from the cluster config.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- --name is required (for safety)
- --name is required
- --name is required
- at least one channel URL is required
- error populating configuration: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/97c6ed8312d2d73f.
Report an issue: GitHub.