kubernetes/kops · error

error rendering PublicKey

Error message

error rendering PublicKey: %v

What it means

Wraps TerraformTarget.AddFileResource failure while writing the SSH public key as a Terraform file asset for the digitalocean_ssh_key resource. Fires on I/O/path failures writing to the Terraform output, not on key content problems.

Solutions

  1. Check write permissions and disk space in the output directory
  2. Inspect the wrapped error
  3. Re-run Terraform generation
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/dotasks/sshkey.go:177 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/680a232eb7100ff6. Report an issue: GitHub.

Appendix: source

Thrown at upup/pkg/fi/cloudup/dotasks/sshkey.go:177

	}

	return nil
}

type terraformSSHKey struct {
	Name      *string                  `cty:"name"`
	PublicKey *terraformWriter.Literal `cty:"public_key"`
}

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("digitalocean_ssh_key", tfName, "public_key", e.PublicKey, false)
	if err != nil {
		return fmt.Errorf("error rendering PublicKey: %v", err)
	}

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

	return t.RenderResource("digitalocean_ssh_key", 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 the cloud.
func (e *SSHKey) IsExistingKey() bool {
	return e.PublicKey == nil
}

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

View on GitHub (pinned to 4c8573c808)