kubernetes/kops · error

error rendering PublicKey: %v

Error message

error rendering PublicKey: %v

What it means

RenderTerraform failed to write the admin SSH public key as the aws_key_pair public_key file in the Terraform output — a Terraform-writer/VFS write error, not an SSH key parsing problem.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/sshkey.go:203

	}
	return nil
}

type terraformSSHKey struct {
	Name      *string                  `cty:"key_name"`
	PublicKey *terraformWriter.Literal `cty:"public_key"`
	Tags      map[string]string        `cty:"tags"`
}

func (_ *SSHKey) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *SSHKey) error {
	// We don't want to render a key definition when we're using one that already exists
	if e.IsExistingKey() {
		return nil
	}
	tfName := strings.ReplaceAll(*e.Name, ":", "")
	publicKey, err := t.AddFileResource("aws_key_pair", tfName, "public_key", e.PublicKey, false)
	if err != nil {
		return fmt.Errorf("error rendering PublicKey: %v", err)
	}

	tf := &terraformSSHKey{
		Name:      e.Name,
		PublicKey: publicKey,
		Tags:      e.Tags,
	}

	return t.RenderResource("aws_key_pair", tfName, tf)
}

// IsExistingKey will be true if the task has been initialized without using a public key
// this is when we want to use a key that is already present in AWS.
func (e *SSHKey) IsExistingKey() bool {
	return e.PublicKey == nil
}

func (e *SSHKey) TerraformLink() *terraformWriter.Literal {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check that the Terraform output directory is writable and not corrupted
  2. Re-run `kops update cluster --target=terraform` to regenerate the output
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/awstasks/sshkey.go:203 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/94aca8eefaf90a15. Report an issue: GitHub.